Expose ssao radius#24267
Open
GageHowe wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR exposes the SSAO sampling radius as a public configuration option on ScreenSpaceAmbientOcclusion, wiring the value through the render pipeline via a new settings uniform and updating the SSAO shader to consume it.
Changes:
- Add
radius: f32toScreenSpaceAmbientOcclusionwith a default matching the previously hardcoded shader value. - Upload a combined SSAO settings uniform (radius + constant object thickness) and update the SSAO shader to read from it.
- Extend the
ssaoexample to allow interactive radius adjustment and display the current value.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| examples/3d/ssao.rs | Adds Left/Right controls and on-screen text for the new SSAO radius setting. |
| crates/bevy_pbr/src/ssao/ssao.wgsl | Replaces the hardcoded effect radius with a uniform-driven radius in the SSAO compute shader. |
| crates/bevy_pbr/src/ssao/mod.rs | Adds the public radius field, defines a default, and uploads a settings uniform buffer to the shader. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Expose the SSAO sampling radius as a public configuration option on
ScreenSpaceAmbientOcclusion.
Right now Bevy exposes SSAO quality and constant object thickness, but the effect
radius is still hardcoded internally in the SSAO shader. That makes it impossible for
users to tune the size of the occlusion effect from app code.
Solution
Add a radius: f32 field to ScreenSpaceAmbientOcclusion and preserve existing behavior
by defaulting it to the shader’s previous hardcoded value.
To wire that through cleanly, the SSAO render path now uploads a small SSAO settings
uniform containing both radius and constant_object_thickness, and the SSAO shader
reads settings.radius instead of a hardcoded constant.
The SSAO example was also updated to expose the new setting interactively so the
feature is discoverable and easy to validate.
Testing
I tested this by:
with Left / Right
Parts that could use more testing:
How reviewers can test this:
existing behavior
Platform tested:
Platforms not tested: