Skip to content

Expose ssao radius#24267

Open
GageHowe wants to merge 3 commits into
bevyengine:mainfrom
GageHowe:expose-ssao-radius
Open

Expose ssao radius#24267
GageHowe wants to merge 3 commits into
bevyengine:mainfrom
GageHowe:expose-ssao-radius

Conversation

@GageHowe
Copy link
Copy Markdown
Contributor

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:

  • Running cargo check -p bevy_pbr --quiet
  • Building and running cargo build --example ssao
  • Launching target/debug/examples/ssao and verifying the example starts successfully
  • Verifying that the new radius control can be adjusted interactively in the example
    with Left / Right

Parts that could use more testing:

  • Visual validation across a wider range of scenes and camera scales
  • Broader GPU/platform coverage, since I only tested locally

How reviewers can test this:

  1. Run cargo build --example ssao
  2. Launch target/debug/examples/ssao
  3. Use Left / Right to decrease/increase SSAO radius
  4. Confirm that larger values produce broader occlusion while the default matches
    existing behavior

Platform tested:

  • Linux (EndeavourOS)

Platforms not tested:

  • Windows
  • macOS
  • Web targets

Copilot AI review requested due to automatic review settings May 12, 2026 16:44
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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: f32 to ScreenSpaceAmbientOcclusion with 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 ssao example 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.

Comment thread crates/bevy_pbr/src/ssao/ssao.wgsl Outdated
Comment thread crates/bevy_pbr/src/ssao/mod.rs
@GageHowe
Copy link
Copy Markdown
Contributor Author

GageHowe commented May 12, 2026

Screenshot_20260512_113536 Screenshot_20260512_113619 Screenshot_20260512_113723 Screenshot_20260512_113800-1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants