Repository navigation
[Bugfix] Use single-bounce reflectance for IBL diffuse energy conservation - #1329
Merged
Merged
Conversation
…ation computeIBLContribution attenuated diffuse by the multi-bounce-compensated reflectance from environmentReflectance, which conflates two different things: the energy specular's own approximation needs restored via later bounces, and the share a surface diverts away from diffuse in the first place. Factor the single-bounce term out into singleBounceReflectance and use that for the diffuse term instead, keeping the compensated value for specular only. Fixes #1296
miogds
added a commit
to miolabs/UntoldEngine
that referenced
this pull request
Oct 10, 2026
Sync fork develop with upstream: per-eye shading, LOD hidden parts, IBL diffuse (untoldengine#1285, untoldengine#1324, untoldengine#1329)
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.
Summary
computeIBLContributionattenuated the diffuse term by the full multi-bounce-compensated reflectance fromenvironmentReflectance, instead of the single-bounce reflectance. The multi-bounce compensation exists to restore energy lost by specular's own approximation, not to measure how much a surface diverts away from diffuse scattering.singleBounceReflectancehelper (ShadersUtils.h/.metal), and switched the diffuse-energy-conservation term incomputeIBLParts(LightShader.metal) to use it, leaving the fully compensated value for the specular term only..metallibkernels for all platforms viabuildkernels.sh.Test plan
EnvironmentReflectionShadingTests(10 tests) pass, including the existingtestAWhiteSurfaceGivesBackAllTheLightWhateverItsFinishandtestARoughColoredMetalStaysWithinItsColor.testARoughHighF0SurfaceDiffuseGivesUpOnlyTheSingleBounceShare, targeting a roughness-1.0, F0≈0.5 material where the single-bounce and multi-bounce-compensated reflectance clearly diverge.Closes #1296