Skip to content

[Bugfix] Use single-bounce reflectance for IBL diffuse energy conservation - #1329

Merged
untoldengine merged 2 commits into
developfrom
issue/1296
Oct 10, 2026
Merged

untoldengine merged 2 commits into
developfrom
issue/1296

Conversation

@untoldengine

Copy link
Copy Markdown
Owner

Summary

  • computeIBLContribution attenuated the diffuse term by the full multi-bounce-compensated reflectance from environmentReflectance, 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.
  • Factored the single-bounce term out into a new singleBounceReflectance helper (ShadersUtils.h/.metal), and switched the diffuse-energy-conservation term in computeIBLParts (LightShader.metal) to use it, leaving the fully compensated value for the specular term only.
  • Rebuilt the .metallib kernels for all platforms via buildkernels.sh.

Test plan

  • EnvironmentReflectionShadingTests (10 tests) pass, including the existing testAWhiteSurfaceGivesBackAllTheLightWhateverItsFinish and testARoughColoredMetalStaysWithinItsColor.
  • Added testARoughHighF0SurfaceDiffuseGivesUpOnlyTheSingleBounceShare, targeting a roughness-1.0, F0≈0.5 material where the single-bounce and multi-bounce-compensated reflectance clearly diverge.
  • Verified the new test fails when the fix is reverted (confirms it actually catches the regression), and passes with the fix restored.

Closes #1296

…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
@untoldengine
untoldengine merged commit a2b154d into develop Oct 10, 2026
4 checks passed
@untoldengine
untoldengine deleted the issue/1296 branch October 10, 2026 00:04
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)
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.

[Bug] IBL diffuse term uses multi-bounce-compensated reflectance instead of single-bounce

1 participant