bevy/examples/shader
James Gayfer 061baa4ff7
Use dynamic uniform buffer in post processing example (#13540)
# Objective

While learning about shaders and pipelines, I found this example to be
misleading; it wasn't clear to me how the node knew what the correct
"instance" of `PostProcessSettings` we should send to the shader (as the
combination of `ExtractComponentPlugin` and `UniformComponentPlugin`
extracts + sends _all_ of our `PostProcessSetting` components to the
GPU).

The goal of this PR is to clarify how to target the view specific
`PostProcessSettings` in the shader when there are multiple cameras.

## Solution

To accomplish this, we can use a dynamic uniform buffer for
`PostProcessSettings`, querying for the relevant `DynamicUniformIndex`
in the `PostProcessNode` to get the relevant index to use with the bind
group.

While the example in its current state is _correct_, I believe that fact
that it's intended to showcase a per camera post processing effect
warrants a dynamic uniform buffer (even though in the context of this
example we have only one camera, and therefore no adverse behaviour).

## Testing

- Run the `post_processing` example before and after this change,
verifying they behave the same.

## Reviewer notes

This is my first PR to Bevy, and I'm by no means an expert in the world
of rendering (though I'm trying to learn all I can). If there's a better
way to do this / a reason not to take this route, I'd love to hear it!

Thanks in advance.
2024-06-14 18:04:13 +00:00
..
animate_shader.rs Highlight dependency on shader files in examples (#13824) 2024-06-12 14:16:01 +00:00
array_texture.rs Highlight dependency on shader files in examples (#13824) 2024-06-12 14:16:01 +00:00
compute_shader_game_of_life.rs Handle wgsl errors in the game of life example (#13624) 2024-06-03 13:31:56 +00:00
custom_vertex_attribute.rs Highlight dependency on shader files in examples (#13824) 2024-06-12 14:16:01 +00:00
extended_material.rs Highlight dependency on shader files in examples (#13824) 2024-06-12 14:16:01 +00:00
fallback_image.rs Highlight dependency on shader files in examples (#13824) 2024-06-12 14:16:01 +00:00
gpu_readback.rs Highlight dependency on shader files in examples (#13824) 2024-06-12 14:16:01 +00:00
post_processing.rs Use dynamic uniform buffer in post processing example (#13540) 2024-06-14 18:04:13 +00:00
shader_defs.rs Highlight dependency on shader files in examples (#13824) 2024-06-12 14:16:01 +00:00
shader_instancing.rs Highlight dependency on shader files in examples (#13824) 2024-06-12 14:16:01 +00:00
shader_material.rs Highlight dependency on shader files in examples (#13824) 2024-06-12 14:16:01 +00:00
shader_material_2d.rs Highlight dependency on shader files in examples (#13824) 2024-06-12 14:16:01 +00:00
shader_material_glsl.rs Highlight dependency on shader files in examples (#13824) 2024-06-12 14:16:01 +00:00
shader_material_screenspace_texture.rs Highlight dependency on shader files in examples (#13824) 2024-06-12 14:16:01 +00:00
shader_prepass.rs Highlight dependency on shader files in examples (#13824) 2024-06-12 14:16:01 +00:00
texture_binding_array.rs Highlight dependency on shader files in examples (#13824) 2024-06-12 14:16:01 +00:00