Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dynamic uniform buffer in post processing example #13540

Merged
merged 1 commit into from
Jun 14, 2024

Conversation

jgayfer
Copy link
Contributor

@jgayfer jgayfer commented May 27, 2024

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.

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 GPU (as
the combination of `ExtractComponentPlugin` and `UniformComponentPlugin`
extracts + sends _all_ of our `PostProcessSetting` components).

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).
Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@jgayfer jgayfer changed the title Use dynamic uniform buffer for post process settings Use dynamic uniform buffer in post processing example May 27, 2024
@JMS55 JMS55 requested a review from IceSentry May 28, 2024 02:25
Copy link
Contributor

@IceSentry IceSentry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Would be nice to actually take advantage of it in an example, but it's not required

@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen C-Examples An addition or correction to our examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jun 1, 2024
@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jun 13, 2024
@alice-i-cecile alice-i-cecile added this to the 0.14 milestone Jun 13, 2024
@mockersf mockersf added this pull request to the merge queue Jun 14, 2024
Merged via the queue into bevyengine:main with commit 061baa4 Jun 14, 2024
32 checks passed
mockersf pushed a commit that referenced this pull request Jun 14, 2024
# 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Examples An addition or correction to our examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants