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::{
|
||||
prelude::*,
|
||||
reflect::TypeUuid,
|
||||
render::{
|
||||
mesh::{shape, VertexAttributeValues},
|
||||
pipeline::{PipelineDescriptor, RenderPipeline},
|
||||
render_graph::{base, AssetRenderResourcesNode, RenderGraph},
|
||||
renderer::RenderResources,
|
||||
shader::{ShaderStage, ShaderStages},
|
||||
},
|
||||
};
|
||||
@ -14,15 +11,10 @@ use bevy::{
|
||||
fn main() {
|
||||
App::build()
|
||||
.add_plugins(DefaultPlugins)
|
||||
.add_asset::<MyMaterialWithVertexColorSupport>()
|
||||
.add_startup_system(setup.system())
|
||||
.run();
|
||||
}
|
||||
|
||||
#[derive(RenderResources, Default, TypeUuid)]
|
||||
#[uuid = "0320b9b8-b3a3-4baa-8bfa-c94008177b17"]
|
||||
struct MyMaterialWithVertexColorSupport;
|
||||
|
||||
const VERTEX_SHADER: &str = r#"
|
||||
#version 450
|
||||
layout(location = 0) in vec3 Vertex_Position;
|
||||
@ -56,8 +48,6 @@ fn setup(
|
||||
mut pipelines: ResMut<Assets<PipelineDescriptor>>,
|
||||
mut shaders: ResMut<Assets<Shader>>,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut materials: ResMut<Assets<MyMaterialWithVertexColorSupport>>,
|
||||
mut render_graph: ResMut<RenderGraph>,
|
||||
) {
|
||||
// Create a new shader pipeline
|
||||
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))),
|
||||
}));
|
||||
|
||||
// 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
|
||||
let mut cube_with_vertex_colors = Mesh::from(shape::Cube { size: 2.0 });
|
||||
|
||||
@ -128,16 +99,14 @@ fn setup(
|
||||
]),
|
||||
);
|
||||
// cube
|
||||
commands
|
||||
.spawn_bundle(MeshBundle {
|
||||
mesh: meshes.add(cube_with_vertex_colors), // use our cube with vertex colors
|
||||
render_pipelines: RenderPipelines::from_pipelines(vec![RenderPipeline::new(
|
||||
pipeline_handle,
|
||||
)]),
|
||||
transform: Transform::from_xyz(0.0, 0.0, 0.0),
|
||||
..Default::default()
|
||||
})
|
||||
.insert(material);
|
||||
commands.spawn_bundle(MeshBundle {
|
||||
mesh: meshes.add(cube_with_vertex_colors), // use our cube with vertex colors
|
||||
render_pipelines: RenderPipelines::from_pipelines(vec![RenderPipeline::new(
|
||||
pipeline_handle,
|
||||
)]),
|
||||
transform: Transform::from_xyz(0.0, 0.0, 0.0),
|
||||
..Default::default()
|
||||
});
|
||||
// camera
|
||||
commands.spawn_bundle(PerspectiveCameraBundle {
|
||||
transform: Transform::from_xyz(3.0, 5.0, -8.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user