1
1
use bevy:: {
2
2
prelude:: * ,
3
- reflect:: TypeUuid ,
4
3
render:: {
5
4
mesh:: { shape, VertexAttributeValues } ,
6
5
pipeline:: { PipelineDescriptor , RenderPipeline } ,
7
- render_graph:: { base, AssetRenderResourcesNode , RenderGraph } ,
8
- renderer:: RenderResources ,
9
6
shader:: { ShaderStage , ShaderStages } ,
10
7
} ,
11
8
} ;
@@ -14,15 +11,10 @@ use bevy::{
14
11
fn main ( ) {
15
12
App :: build ( )
16
13
. add_plugins ( DefaultPlugins )
17
- . add_asset :: < MyMaterialWithVertexColorSupport > ( )
18
14
. add_startup_system ( setup. system ( ) )
19
15
. run ( ) ;
20
16
}
21
17
22
- #[ derive( RenderResources , Default , TypeUuid ) ]
23
- #[ uuid = "0320b9b8-b3a3-4baa-8bfa-c94008177b17" ]
24
- struct MyMaterialWithVertexColorSupport ;
25
-
26
18
const VERTEX_SHADER : & str = r#"
27
19
#version 450
28
20
layout(location = 0) in vec3 Vertex_Position;
@@ -56,34 +48,13 @@ fn setup(
56
48
mut pipelines : ResMut < Assets < PipelineDescriptor > > ,
57
49
mut shaders : ResMut < Assets < Shader > > ,
58
50
mut meshes : ResMut < Assets < Mesh > > ,
59
- mut materials : ResMut < Assets < MyMaterialWithVertexColorSupport > > ,
60
- mut render_graph : ResMut < RenderGraph > ,
61
51
) {
62
52
// Create a new shader pipeline
63
53
let pipeline_handle = pipelines. add ( PipelineDescriptor :: default_config ( ShaderStages {
64
54
vertex : shaders. add ( Shader :: from_glsl ( ShaderStage :: Vertex , VERTEX_SHADER ) ) ,
65
55
fragment : Some ( shaders. add ( Shader :: from_glsl ( ShaderStage :: Fragment , FRAGMENT_SHADER ) ) ) ,
66
56
} ) ) ;
67
57
68
- // Add an AssetRenderResourcesNode to our Render Graph. This will bind
69
- // MyMaterialWithVertexColorSupport resources to our shader
70
- render_graph. add_system_node (
71
- "my_material_with_vertex_color_support" ,
72
- AssetRenderResourcesNode :: < MyMaterialWithVertexColorSupport > :: new ( true ) ,
73
- ) ;
74
-
75
- // Add a Render Graph edge connecting our new "my_material" node to the main pass node. This
76
- // ensures "my_material" runs before the main pass
77
- render_graph
78
- . add_node_edge (
79
- "my_material_with_vertex_color_support" ,
80
- base:: node:: MAIN_PASS ,
81
- )
82
- . unwrap ( ) ;
83
-
84
- // Create a new material
85
- let material = materials. add ( MyMaterialWithVertexColorSupport { } ) ;
86
-
87
58
// create a generic cube
88
59
let mut cube_with_vertex_colors = Mesh :: from ( shape:: Cube { size : 2.0 } ) ;
89
60
@@ -128,16 +99,14 @@ fn setup(
128
99
] ) ,
129
100
) ;
130
101
// cube
131
- commands
132
- . spawn_bundle ( MeshBundle {
133
- mesh : meshes. add ( cube_with_vertex_colors) , // use our cube with vertex colors
134
- render_pipelines : RenderPipelines :: from_pipelines ( vec ! [ RenderPipeline :: new(
135
- pipeline_handle,
136
- ) ] ) ,
137
- transform : Transform :: from_xyz ( 0.0 , 0.0 , 0.0 ) ,
138
- ..Default :: default ( )
139
- } )
140
- . insert ( material) ;
102
+ commands. spawn_bundle ( MeshBundle {
103
+ mesh : meshes. add ( cube_with_vertex_colors) , // use our cube with vertex colors
104
+ render_pipelines : RenderPipelines :: from_pipelines ( vec ! [ RenderPipeline :: new(
105
+ pipeline_handle,
106
+ ) ] ) ,
107
+ transform : Transform :: from_xyz ( 0.0 , 0.0 , 0.0 ) ,
108
+ ..Default :: default ( )
109
+ } ) ;
141
110
// camera
142
111
commands. spawn_bundle ( PerspectiveCameraBundle {
143
112
transform : Transform :: from_xyz ( 3.0 , 5.0 , -8.0 ) . looking_at ( Vec3 :: ZERO , Vec3 :: Y ) ,
0 commit comments