Skip to content

Conversation

@atlv24
Copy link
Contributor

@atlv24 atlv24 commented Jan 18, 2026

Objective

Solution

  • change the example to make it easier to tell if the reflection is actually matching
  • fix the assets because the reflection doesnt actually match
  • throw the assets into the asset repo Add pccm example assets bevy_asset_files#7

Testing

  • running the example

pcwalton and others added 5 commits January 18, 2026 10:43
Bevy doesn't currently ever apply parallax correction to cubemaps, so
reflections are rendered as though the environment were infinitely far
away. This is often acceptable for outdoor scenes in which the
environment is very distant, but for indoor scenes and dense
environments this is undesirable. The standard solution for this problem
is *parallax correction*, in which each reflection probe is augmented
with a bounding box, and a raytrace is performed against the bounding
box in order to determine the proper direction for sampling the cubemap.

This commit implements parallax correction in Bevy in an opt-in manner.
Add the `ParallaxCorrect` component to a `LightProbe` with an
`EnvironmentMapLight` in order to opt into it. The bounding box used for
parallax correction is assumed to be identical to the bounding box of
the influence of the reflection probe itself. This is a reasonable
default and matches what Blender does; it's what you want when you have,
for example, a cubemap that captures the interior of a rectangular room.
However, a future follow-up PR may wish to extend this so that the
bounding box used for parallax correction might not coincide with the
bounding box used for the influence of the reflection probe. This would
require increasing the GPU size of the light probe data, so in order to
keep this patch small and self-contained, I opted to defer this
potential future enhancement to a follow-up.

The patch is generally straightforward, adding only the minimal
enhancements to the `LightProbe` trait and the GPU representation of
light probes needed to propagate the parallax correction flag through
the rendering pipeline.

Additionally, this commit fixes a bug whereby the transform of each
cubemap reflection probe wasn't being taken into account in the shader.
I believe that this was being masked because most cubemaps are rendered
in world space and therefore most cubemap reflection probes have an
identity rotation.

A new example, `pccm`, has been added, demonstrating the effect of
parallax correction. It shows a scene consisting of an outer textured
cube with an inner rotating reflective cube. The outer textured cube
contains a reflection probe containing a snapshot of the scene
(prerendered in Blender). Parallax correction can be toggled on and off
in the example in order to demonstrate its effect.
@atlv24
Copy link
Contributor Author

atlv24 commented Jan 18, 2026

This is what the example looks like now
{4A270AEF-D44C-46D4-A0F1-110F71F46E99}

@atlv24 atlv24 added A-Rendering Drawing game state to the screen S-Blocked This cannot move forward until something else changes labels Jan 18, 2026
@atlv24
Copy link
Contributor Author

atlv24 commented Jan 18, 2026

(blocked until assets pr merges)

@alice-i-cecile
Copy link
Member

Merged assets PR :)

@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible M-Release-Note Work that should be called out in the blog due to impact D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward and removed S-Blocked This cannot move forward until something else changes labels Jan 18, 2026
@alice-i-cecile alice-i-cecile added this to the 0.19 milestone Jan 18, 2026
Copy link
Contributor

@pcwalton pcwalton left a comment

Choose a reason for hiding this comment

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

Up to y’all whether this review counts given that this is 99% my code, but LGTM anyway :)

@alice-i-cecile
Copy link
Member

Up to y’all whether this review counts given that this is 99% my code, but LGTM anyway :)

I'll say that your review + vero's review sums to 1 approval :)

Copy link
Contributor

@superdump superdump left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@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 Jan 19, 2026
@alice-i-cecile alice-i-cecile changed the title Rebase + tweak PCCM example (#22288) Parallax-corrected cubemaps for reflection probes (adopted) Jan 20, 2026
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 20, 2026
Merged via the queue into bevyengine:main with commit dd230f2 Jan 20, 2026
44 checks passed
@atlv24 atlv24 deleted the ad/pccm branch January 26, 2026 03:36
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-Feature A new feature, making something new possible D-Straightforward Simple bug fixes and API improvements, docs, test and examples M-Release-Note Work that should be called out in the blog due to impact S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants