Skip to content

Commit

Permalink
Remove unused material (bevyengine#1898)
Browse files Browse the repository at this point in the history
This doesn't do anything and complicates the example.
  • Loading branch information
cart authored and jihiggins committed Apr 18, 2021
1 parent dfe9776 commit f3f42c9
Showing 1 changed file with 8 additions and 39 deletions.
47 changes: 8 additions & 39 deletions examples/shader/mesh_custom_attribute.rs
Original file line number Diff line number Diff line change
@@ -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},
},
};
Expand All @@ -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;
Expand Down Expand Up @@ -56,34 +48,13 @@ 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 {
vertex: shaders.add(Shader::from_glsl(ShaderStage::Vertex, VERTEX_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
let mut cube_with_vertex_colors = Mesh::from(shape::Cube { size: 2.0 });

Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit f3f42c9

Please sign in to comment.