Remove unused material (#1898)
This doesn't do anything and complicates the example.
This commit is contained in:
parent
5c4f3554f9
commit
5bccb67aa3
@ -1,11 +1,8 @@
|
|||||||
use bevy::{
|
use bevy::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
reflect::TypeUuid,
|
|
||||||
render::{
|
render::{
|
||||||
mesh::{shape, VertexAttributeValues},
|
mesh::{shape, VertexAttributeValues},
|
||||||
pipeline::{PipelineDescriptor, RenderPipeline},
|
pipeline::{PipelineDescriptor, RenderPipeline},
|
||||||
render_graph::{base, AssetRenderResourcesNode, RenderGraph},
|
|
||||||
renderer::RenderResources,
|
|
||||||
shader::{ShaderStage, ShaderStages},
|
shader::{ShaderStage, ShaderStages},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -14,15 +11,10 @@ use bevy::{
|
|||||||
fn main() {
|
fn main() {
|
||||||
App::build()
|
App::build()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_asset::<MyMaterialWithVertexColorSupport>()
|
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup.system())
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RenderResources, Default, TypeUuid)]
|
|
||||||
#[uuid = "0320b9b8-b3a3-4baa-8bfa-c94008177b17"]
|
|
||||||
struct MyMaterialWithVertexColorSupport;
|
|
||||||
|
|
||||||
const VERTEX_SHADER: &str = r#"
|
const VERTEX_SHADER: &str = r#"
|
||||||
#version 450
|
#version 450
|
||||||
layout(location = 0) in vec3 Vertex_Position;
|
layout(location = 0) in vec3 Vertex_Position;
|
||||||
@ -56,8 +48,6 @@ fn setup(
|
|||||||
mut pipelines: ResMut<Assets<PipelineDescriptor>>,
|
mut pipelines: ResMut<Assets<PipelineDescriptor>>,
|
||||||
mut shaders: ResMut<Assets<Shader>>,
|
mut shaders: ResMut<Assets<Shader>>,
|
||||||
mut meshes: ResMut<Assets<Mesh>>,
|
mut meshes: ResMut<Assets<Mesh>>,
|
||||||
mut materials: ResMut<Assets<MyMaterialWithVertexColorSupport>>,
|
|
||||||
mut render_graph: ResMut<RenderGraph>,
|
|
||||||
) {
|
) {
|
||||||
// Create a new shader pipeline
|
// Create a new shader pipeline
|
||||||
let pipeline_handle = pipelines.add(PipelineDescriptor::default_config(ShaderStages {
|
let pipeline_handle = pipelines.add(PipelineDescriptor::default_config(ShaderStages {
|
||||||
@ -65,25 +55,6 @@ fn setup(
|
|||||||
fragment: Some(shaders.add(Shader::from_glsl(ShaderStage::Fragment, FRAGMENT_SHADER))),
|
fragment: Some(shaders.add(Shader::from_glsl(ShaderStage::Fragment, FRAGMENT_SHADER))),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Add an AssetRenderResourcesNode to our Render Graph. This will bind
|
|
||||||
// MyMaterialWithVertexColorSupport resources to our shader
|
|
||||||
render_graph.add_system_node(
|
|
||||||
"my_material_with_vertex_color_support",
|
|
||||||
AssetRenderResourcesNode::<MyMaterialWithVertexColorSupport>::new(true),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Add a Render Graph edge connecting our new "my_material" node to the main pass node. This
|
|
||||||
// ensures "my_material" runs before the main pass
|
|
||||||
render_graph
|
|
||||||
.add_node_edge(
|
|
||||||
"my_material_with_vertex_color_support",
|
|
||||||
base::node::MAIN_PASS,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// Create a new material
|
|
||||||
let material = materials.add(MyMaterialWithVertexColorSupport {});
|
|
||||||
|
|
||||||
// create a generic cube
|
// create a generic cube
|
||||||
let mut cube_with_vertex_colors = Mesh::from(shape::Cube { size: 2.0 });
|
let mut cube_with_vertex_colors = Mesh::from(shape::Cube { size: 2.0 });
|
||||||
|
|
||||||
@ -128,16 +99,14 @@ fn setup(
|
|||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
// cube
|
// cube
|
||||||
commands
|
commands.spawn_bundle(MeshBundle {
|
||||||
.spawn_bundle(MeshBundle {
|
mesh: meshes.add(cube_with_vertex_colors), // use our cube with vertex colors
|
||||||
mesh: meshes.add(cube_with_vertex_colors), // use our cube with vertex colors
|
render_pipelines: RenderPipelines::from_pipelines(vec![RenderPipeline::new(
|
||||||
render_pipelines: RenderPipelines::from_pipelines(vec![RenderPipeline::new(
|
pipeline_handle,
|
||||||
pipeline_handle,
|
)]),
|
||||||
)]),
|
transform: Transform::from_xyz(0.0, 0.0, 0.0),
|
||||||
transform: Transform::from_xyz(0.0, 0.0, 0.0),
|
..Default::default()
|
||||||
..Default::default()
|
});
|
||||||
})
|
|
||||||
.insert(material);
|
|
||||||
// camera
|
// camera
|
||||||
commands.spawn_bundle(PerspectiveCameraBundle {
|
commands.spawn_bundle(PerspectiveCameraBundle {
|
||||||
transform: Transform::from_xyz(3.0, 5.0, -8.0).looking_at(Vec3::ZERO, Vec3::Y),
|
transform: Transform::from_xyz(3.0, 5.0, -8.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user