diff --git a/examples/README.md b/examples/README.md index 29979f5498e38..73c734937337f 100644 --- a/examples/README.md +++ b/examples/README.md @@ -190,6 +190,7 @@ Example | File | Description Example | File | Description --- | --- | --- +`animate_shader` | [`shader/animate_shader.rs`](./shader/animate_shader.rs) | Shows how to animate a shader by accessing a time uniform variable `array_texture` | [`shader/array_texture.rs`](./shader/array_texture.rs) | Illustrates how to create a texture for use with a texture2DArray shader uniform variable `hot_shader_reloading` | [`shader/hot_shader_reloading.rs`](./shader/hot_shader_reloading.rs) | Illustrates how to load shaders such that they can be edited while the example is still running `mesh_custom_attribute` | [`shader/mesh_custom_attribute.rs`](./shader/mesh_custom_attribute.rs) | Illustrates how to add a custom attribute to a mesh and use it in a custom shader diff --git a/examples/shader/animate_shader.rs b/examples/shader/animate_shader.rs index cf3c743bbd653..b394324428bfc 100644 --- a/examples/shader/animate_shader.rs +++ b/examples/shader/animate_shader.rs @@ -11,7 +11,7 @@ use bevy::{ }; /// This example shows how to animate a shader, by passing the global `time.seconds_since_startup()` -/// via a 'TimeComponent` to the shader +/// via a 'TimeComponent` to the shader. pub fn main() { App::build() .add_plugins(DefaultPlugins) @@ -78,30 +78,30 @@ fn setup( mut meshes: ResMut>, mut render_graph: ResMut, ) { - // Create a new shader pipeline + // 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 a `RenderResourcesNode` to our `RenderGraph`. This will bind `TimeComponent` to our shader + // Add a `RenderResourcesNode` to our `RenderGraph`. This will bind `TimeComponent` to our shader. render_graph.add_system_node( "time_component", RenderResourcesNode::::new(true), ); // Add a `RenderGraph` edge connecting our new "time_component" node to the main pass node. This - // ensures that "time_component" runs before the main pass + // ensures that "time_component" runs before the main pass. render_graph .add_node_edge("time_component", base::node::MAIN_PASS) .unwrap(); - // Spawn a quad and insert the `TimeComponent` + // Spawn a quad and insert the `TimeComponent`. commands .spawn_bundle(MeshBundle { mesh: meshes.add(Mesh::from(shape::Quad { - size: Vec2::new(5.0, 5.0), - flip: true, + size: Vec2::new(400.0, 400.0), + flip: false, })), render_pipelines: RenderPipelines::from_pipelines(vec![RenderPipeline::new( pipeline_handle, @@ -111,11 +111,8 @@ fn setup( }) .insert(TimeComponent { value: 0.0 }); - // Spawn a camera - commands.spawn_bundle(PerspectiveCameraBundle { - transform: Transform::from_xyz(0.0, 0.0, -8.0).looking_at(Vec3::ZERO, -Vec3::Y), - ..Default::default() - }); + // Spawn a camera. + commands.spawn_bundle(OrthographicCameraBundle::new_2d()); } /// In this system we query for the `TimeComponent` and global `Time` resource, and set `time.seconds_since_startup()`