Skip to content

Commit 8a51d39

Browse files
authored
Move advanced shader examples to separate category (#20415)
# Objective - Some shader examples are much more complicated than others. It can be confusing for new users that simple example and advanced examples are next to each other ## Solution - Introduce a new "shader_advanced" example category - I'm open to other names, but I named it like that so both folders are next to each other ## Testing N/A ## Notes We should maybe consider a different name than "shader" because some of them aren't that much about shaders. It could be advanced_rendering or something like that. I'm opened to moving more example to this. I just picked the one that felt the most advanced to me. I didn't move the compute_game_of_life example because, while it is complex, the complexity is unavoidable if you want to run a compute shader right now. I also plan on simplifying it a bit and introduce a plugin to make it much easier but as it is today I think it's okay to stay there.
1 parent 50a0ceb commit 8a51d39

File tree

9 files changed

+74
-65
lines changed

9 files changed

+74
-65
lines changed

Cargo.toml

Lines changed: 67 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2804,28 +2804,6 @@ A shader in its most common usage is a small program that is run by the GPU per-
28042804
There are also compute shaders which are used for more general processing leveraging the GPU's parallelism.
28052805
"""
28062806

2807-
[[example]]
2808-
name = "custom_vertex_attribute"
2809-
path = "examples/shader/custom_vertex_attribute.rs"
2810-
doc-scrape-examples = true
2811-
2812-
[package.metadata.example.custom_vertex_attribute]
2813-
name = "Custom Vertex Attribute"
2814-
description = "A shader that reads a mesh's custom vertex attribute"
2815-
category = "Shaders"
2816-
wasm = true
2817-
2818-
[[example]]
2819-
name = "custom_post_processing"
2820-
path = "examples/shader/custom_post_processing.rs"
2821-
doc-scrape-examples = true
2822-
2823-
[package.metadata.example.custom_post_processing]
2824-
name = "Post Processing - Custom Render Pass"
2825-
description = "A custom post processing effect, using a custom render pass that runs after the main pass"
2826-
category = "Shaders"
2827-
wasm = true
2828-
28292807
[[example]]
28302808
name = "shader_defs"
28312809
path = "examples/shader/shader_defs.rs"
@@ -2916,29 +2894,6 @@ description = "A shader that uses WESL"
29162894
category = "Shaders"
29172895
wasm = true
29182896

2919-
[[example]]
2920-
name = "custom_shader_instancing"
2921-
path = "examples/shader/custom_shader_instancing.rs"
2922-
doc-scrape-examples = true
2923-
2924-
[package.metadata.example.custom_shader_instancing]
2925-
name = "Instancing"
2926-
description = "A shader that renders a mesh multiple times in one draw call using low level rendering api"
2927-
category = "Shaders"
2928-
wasm = true
2929-
2930-
[[example]]
2931-
name = "custom_render_phase"
2932-
path = "examples/shader/custom_render_phase.rs"
2933-
doc-scrape-examples = true
2934-
2935-
[package.metadata.example.custom_render_phase]
2936-
name = "Custom Render Phase"
2937-
description = "Shows how to make a complete render phase"
2938-
category = "Shaders"
2939-
wasm = true
2940-
2941-
29422897
[[example]]
29432898
name = "automatic_instancing"
29442899
path = "examples/shader/automatic_instancing.rs"
@@ -2994,17 +2949,6 @@ description = "A shader that shows how to reuse the core bevy PBR shading functi
29942949
category = "Shaders"
29952950
wasm = true
29962951

2997-
[[example]]
2998-
name = "texture_binding_array"
2999-
path = "examples/shader/texture_binding_array.rs"
3000-
doc-scrape-examples = true
3001-
3002-
[package.metadata.example.texture_binding_array]
3003-
name = "Texture Binding Array (Bindless Textures)"
3004-
description = "A shader that shows how to bind and sample multiple textures as a binding array (a.k.a. bindless textures)."
3005-
category = "Shaders"
3006-
wasm = false
3007-
30082952
[[example]]
30092953
name = "storage_buffer"
30102954
path = "examples/shader/storage_buffer.rs"
@@ -3016,9 +2960,74 @@ description = "A shader that shows how to bind a storage buffer using a custom m
30162960
category = "Shaders"
30172961
wasm = true
30182962

2963+
# Shaders advanced
2964+
[[package.metadata.example_category]]
2965+
name = "Shaders - advanced"
2966+
description = """
2967+
These examples demonstrate how to use the lower level rendering apis exposed from bevy.
2968+
2969+
These are generally simplified examples of bevy's own rendering infrastructure.
2970+
"""
2971+
2972+
[[example]]
2973+
name = "custom_vertex_attribute"
2974+
path = "examples/shader_advanced/custom_vertex_attribute.rs"
2975+
doc-scrape-examples = true
2976+
2977+
[package.metadata.example.custom_vertex_attribute]
2978+
name = "Custom Vertex Attribute"
2979+
description = "A shader that reads a mesh's custom vertex attribute"
2980+
category = "Shaders"
2981+
wasm = true
2982+
2983+
[[example]]
2984+
name = "custom_post_processing"
2985+
path = "examples/shader_advanced/custom_post_processing.rs"
2986+
doc-scrape-examples = true
2987+
2988+
[package.metadata.example.custom_post_processing]
2989+
name = "Post Processing - Custom Render Pass"
2990+
description = "A custom post processing effect, using a custom render pass that runs after the main pass"
2991+
category = "Shaders"
2992+
wasm = true
2993+
2994+
[[example]]
2995+
name = "custom_shader_instancing"
2996+
path = "examples/shader_advanced/custom_shader_instancing.rs"
2997+
doc-scrape-examples = true
2998+
2999+
[package.metadata.example.custom_shader_instancing]
3000+
name = "Instancing"
3001+
description = "A shader that renders a mesh multiple times in one draw call using low level rendering api"
3002+
category = "Shaders"
3003+
wasm = true
3004+
3005+
[[example]]
3006+
name = "custom_render_phase"
3007+
path = "examples/shader_advanced/custom_render_phase.rs"
3008+
doc-scrape-examples = true
3009+
3010+
[package.metadata.example.custom_render_phase]
3011+
name = "Custom Render Phase"
3012+
description = "Shows how to make a complete render phase"
3013+
category = "Shaders"
3014+
wasm = true
3015+
3016+
[[example]]
3017+
name = "texture_binding_array"
3018+
path = "examples/shader_advanced/texture_binding_array.rs"
3019+
doc-scrape-examples = true
3020+
3021+
[package.metadata.example.texture_binding_array]
3022+
name = "Texture Binding Array (Bindless Textures)"
3023+
description = "A shader that shows how to bind and sample multiple textures as a binding array (a.k.a. bindless textures)."
3024+
category = "Shaders"
3025+
wasm = false
3026+
3027+
30193028
[[example]]
30203029
name = "specialized_mesh_pipeline"
3021-
path = "examples/shader/specialized_mesh_pipeline.rs"
3030+
path = "examples/shader_advanced/specialized_mesh_pipeline.rs"
30223031
doc-scrape-examples = true
30233032

30243033
[package.metadata.example.specialized_mesh_pipeline]
@@ -4187,7 +4196,7 @@ wasm = false
41874196

41884197
[[example]]
41894198
name = "custom_phase_item"
4190-
path = "examples/shader/custom_phase_item.rs"
4199+
path = "examples/shader_advanced/custom_phase_item.rs"
41914200
doc-scrape-examples = true
41924201

41934202
[package.metadata.example.custom_phase_item]

examples/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -458,26 +458,26 @@ Example | Description
458458
[Animated](../examples/shader/animate_shader.rs) | A shader that uses dynamic data like the time since startup
459459
[Array Texture](../examples/shader/array_texture.rs) | A shader that shows how to reuse the core bevy PBR shading functionality in a custom material that obtains the base color from an array texture.
460460
[Compute - Game of Life](../examples/shader/compute_shader_game_of_life.rs) | A compute shader that simulates Conway's Game of Life
461-
[Custom Render Phase](../examples/shader/custom_render_phase.rs) | Shows how to make a complete render phase
462-
[Custom Vertex Attribute](../examples/shader/custom_vertex_attribute.rs) | A shader that reads a mesh's custom vertex attribute
463-
[Custom phase item](../examples/shader/custom_phase_item.rs) | Demonstrates how to enqueue custom draw commands in a render phase
461+
[Custom Render Phase](../examples/shader_advanced/custom_render_phase.rs) | Shows how to make a complete render phase
462+
[Custom Vertex Attribute](../examples/shader_advanced/custom_vertex_attribute.rs) | A shader that reads a mesh's custom vertex attribute
463+
[Custom phase item](../examples/shader_advanced/custom_phase_item.rs) | Demonstrates how to enqueue custom draw commands in a render phase
464464
[Extended Bindless Material](../examples/shader/extended_material_bindless.rs) | Demonstrates bindless `ExtendedMaterial`
465465
[Extended Material](../examples/shader/extended_material.rs) | A custom shader that builds on the standard material
466466
[GPU readback](../examples/shader/gpu_readback.rs) | A very simple compute shader that writes to a buffer that is read by the cpu
467-
[Instancing](../examples/shader/custom_shader_instancing.rs) | A shader that renders a mesh multiple times in one draw call using low level rendering api
468467
[Instancing](../examples/shader/automatic_instancing.rs) | Shows that multiple instances of a cube are automatically instanced in one draw call
468+
[Instancing](../examples/shader_advanced/custom_shader_instancing.rs) | A shader that renders a mesh multiple times in one draw call using low level rendering api
469469
[Material](../examples/shader/shader_material.rs) | A shader and a material that uses it
470470
[Material](../examples/shader/shader_material_2d.rs) | A shader and a material that uses it on a 2d mesh
471471
[Material - Bindless](../examples/shader/shader_material_bindless.rs) | Demonstrates how to make materials that use bindless textures
472472
[Material - GLSL](../examples/shader/shader_material_glsl.rs) | A shader that uses the GLSL shading language
473473
[Material - Screenspace Texture](../examples/shader/shader_material_screenspace_texture.rs) | A shader that samples a texture with view-independent UV coordinates
474474
[Material - WESL](../examples/shader/shader_material_wesl.rs) | A shader that uses WESL
475475
[Material Prepass](../examples/shader/shader_prepass.rs) | A shader that uses the various textures generated by the prepass
476-
[Post Processing - Custom Render Pass](../examples/shader/custom_post_processing.rs) | A custom post processing effect, using a custom render pass that runs after the main pass
476+
[Post Processing - Custom Render Pass](../examples/shader_advanced/custom_post_processing.rs) | A custom post processing effect, using a custom render pass that runs after the main pass
477477
[Shader Defs](../examples/shader/shader_defs.rs) | A shader that uses "shaders defs" (a bevy tool to selectively toggle parts of a shader)
478-
[Specialized Mesh Pipeline](../examples/shader/specialized_mesh_pipeline.rs) | Demonstrates how to write a specialized mesh pipeline
478+
[Specialized Mesh Pipeline](../examples/shader_advanced/specialized_mesh_pipeline.rs) | Demonstrates how to write a specialized mesh pipeline
479479
[Storage Buffer](../examples/shader/storage_buffer.rs) | A shader that shows how to bind a storage buffer using a custom material.
480-
[Texture Binding Array (Bindless Textures)](../examples/shader/texture_binding_array.rs) | A shader that shows how to bind and sample multiple textures as a binding array (a.k.a. bindless textures).
480+
[Texture Binding Array (Bindless Textures)](../examples/shader_advanced/texture_binding_array.rs) | A shader that shows how to bind and sample multiple textures as a binding array (a.k.a. bindless textures).
481481

482482
### State
483483

0 commit comments

Comments
 (0)