diff --git a/examples/README.md b/examples/README.md index 6ab8ef7f5892b..8113cc818201e 100644 --- a/examples/README.md +++ b/examples/README.md @@ -239,16 +239,23 @@ Example | File | Description ## Shaders +These examples demonstrate how to implement different shaders in user code. + +A shader in its most common usage is a small program that is run by the GPU per-vertex in a mesh (a vertex shader) +or per-affected-screen-fragment (a fragment shader.) The GPU executes these programs in a highly parallel way. + +There are also compute shaders which are used for more general processing leveraging the GPU’s parallelism. + Example | File | Description --- | --- | --- -`animate_shader` | [`shader/animate_shader.rs`](./shader/animate_shader.rs) | Shows how to pass changing data like the time since startup into a shader. -`compute_shader_game_of_life` | [`shader/compute_shader_game_of_life.rs`](./shader/compute_shader_game_of_life.rs) | A compute shader simulating Conway's Game of Life -`custom_vertex_attribute` | [`shader/custom_vertex_attribute.rs`](./shader/custom_vertex_attribute.rs) | Illustrates creating a custom shader material that reads a mesh's custom vertex attribute. -`shader_defs` | [`shader/shader_defs.rs`](./shader/shader_defs.rs) | Demonstrates creating a custom material that uses "shaders defs" (a tool to selectively toggle parts of a shader) -`shader_instancing` | [`shader/shader_instancing.rs`](./shader/shader_instancing.rs) | A custom shader showing off rendering a mesh multiple times in one draw call. -`shader_material` | [`shader/shader_material.rs`](./shader/shader_material.rs) | Illustrates creating a custom material and a shader that uses it -`shader_material_glsl` | [`shader/shader_material_glsl.rs`](./shader/shader_material_glsl.rs) | A custom shader using the GLSL shading language. -`shader_material_screenspace_texture` | [`shader/shader_material_screenspace_texture.rs`](./shader/shader_material_screenspace_texture.rs) | A custom shader sampling a texture with view-independent UV coordinates. +`animate_shader` | [`shader/animate_shader.rs`](./shader/animate_shader.rs) | A shader that uses dynamic data like the time since startup. +`compute_shader_game_of_life` | [`shader/compute_shader_game_of_life.rs`](./shader/compute_shader_game_of_life.rs) | A compute shader that simulates Conway's Game of Life. +`custom_vertex_attribute` | [`shader/custom_vertex_attribute.rs`](./shader/custom_vertex_attribute.rs) | A shader that reads a mesh's custom vertex attribute. +`shader_defs` | [`shader/shader_defs.rs`](./shader/shader_defs.rs) | A shader that uses "shaders defs" (a bevy tool to selectively toggle parts of a shader). +`shader_instancing` | [`shader/shader_instancing.rs`](./shader/shader_instancing.rs) | A shader that renders a mesh multiple times in one draw call. +`shader_material` | [`shader/shader_material.rs`](./shader/shader_material.rs) | A shader and a material that uses it. +`shader_material_glsl` | [`shader/shader_material_glsl.rs`](./shader/shader_material_glsl.rs) | A shader that uses the GLSL shading language. +`shader_material_screenspace_texture` | [`shader/shader_material_screenspace_texture.rs`](./shader/shader_material_screenspace_texture.rs) | A shader that samples a texture with view-independent UV coordinates. ## Stress Tests diff --git a/examples/shader/animate_shader.rs b/examples/shader/animate_shader.rs index dd46d6293d985..98a5cc6a5ebdb 100644 --- a/examples/shader/animate_shader.rs +++ b/examples/shader/animate_shader.rs @@ -1,5 +1,6 @@ -//! Shows how to pass changing data like the time since startup into a shader, using a custom -//! specialized pipeline. +//! A shader that uses dynamic data like the time since startup. +//! +//! This example uses a specialized pipeline. use bevy::{ core_pipeline::Transparent3d, diff --git a/examples/shader/compute_shader_game_of_life.rs b/examples/shader/compute_shader_game_of_life.rs index 37a8c609b6f3b..d45f9baf5bf76 100644 --- a/examples/shader/compute_shader_game_of_life.rs +++ b/examples/shader/compute_shader_game_of_life.rs @@ -1,4 +1,4 @@ -//! A compute shader simulating Conway's Game of Life. +//! A compute shader that simulates Conway's Game of Life. //! //! Compute shaders use the GPU for computing arbitrary information, that may be independent of what //! is rendered to the screen. diff --git a/examples/shader/custom_vertex_attribute.rs b/examples/shader/custom_vertex_attribute.rs index 989ab6c7dfff7..d325057cb8ea1 100644 --- a/examples/shader/custom_vertex_attribute.rs +++ b/examples/shader/custom_vertex_attribute.rs @@ -1,4 +1,4 @@ -//! Illustrates creating a custom shader material that reads a mesh's custom vertex attribute. +//! A shader that reads a mesh's custom vertex attribute. use bevy::{ ecs::system::{lifetimeless::SRes, SystemParamItem}, diff --git a/examples/shader/shader_defs.rs b/examples/shader/shader_defs.rs index e355ab6fafd11..f96579663ef70 100644 --- a/examples/shader/shader_defs.rs +++ b/examples/shader/shader_defs.rs @@ -1,5 +1,4 @@ -//! Demonstrates creating a custom material that uses "shaders defs", a tool that enables -//! conditional compilation in shaders. +//! A shader that uses "shaders defs" (a bevy tool to selectively toggle parts of a shader) use bevy::{ core_pipeline::Transparent3d, diff --git a/examples/shader/shader_instancing.rs b/examples/shader/shader_instancing.rs index b3b04219e4e0f..3dce17c00587d 100644 --- a/examples/shader/shader_instancing.rs +++ b/examples/shader/shader_instancing.rs @@ -1,4 +1,4 @@ -//! A custom shader showing off rendering a mesh multiple times in one draw call. +//! A shader that renders a mesh multiple times in one draw call. use bevy::{ core_pipeline::Transparent3d, diff --git a/examples/shader/shader_material.rs b/examples/shader/shader_material.rs index 5ef4c0ed3f926..797357bb2898e 100644 --- a/examples/shader/shader_material.rs +++ b/examples/shader/shader_material.rs @@ -1,4 +1,4 @@ -//! Illustrates creating a custom material and a shader that uses it. +//! A shader and a material that uses it. use bevy::{ ecs::system::{lifetimeless::SRes, SystemParamItem}, diff --git a/examples/shader/shader_material_glsl.rs b/examples/shader/shader_material_glsl.rs index df74841af3160..03bc4078ad273 100644 --- a/examples/shader/shader_material_glsl.rs +++ b/examples/shader/shader_material_glsl.rs @@ -1,4 +1,4 @@ -//! A custom shader using the GLSL shading language. +//! A shader that uses the GLSL shading language. use bevy::{ ecs::system::{lifetimeless::SRes, SystemParamItem}, diff --git a/examples/shader/shader_material_screenspace_texture.rs b/examples/shader/shader_material_screenspace_texture.rs index ebe30ee49b0cc..d4a10aa4d78a8 100644 --- a/examples/shader/shader_material_screenspace_texture.rs +++ b/examples/shader/shader_material_screenspace_texture.rs @@ -1,4 +1,4 @@ -//! A custom shader sampling a texture with view-independent UV coordinates. +//! A shader that samples a texture with view-independent UV coordinates. use bevy::{ ecs::system::{lifetimeless::SRes, SystemParamItem},