Skip to content

Shaders: Fix iridescence IBL multiscattering and transposed XYZ_TO_REC709. - #33984

Merged
mrdoob merged 4 commits into
devfrom
webgl-iridescence-fix
Jul 8, 2026
Merged

mrdoob merged 4 commits into
devfrom
webgl-iridescence-fix

Conversation

@mrdoob

@mrdoob mrdoob commented Jul 7, 2026 •

Copy link
Copy Markdown
Owner

Related issue: #32309 #26489

Description

Two iridescence fixes that make the WebGL and WebGPU backends match:

  1. The WebGL renderer passed the view-angle iridescence Fresnel into computeMultiscatteringIridescence(), which expects a normal-incidence F0. The DFG LUT already models the angular falloff, so Fresnel was double-counted, over-brightening grazing environment reflections on iridescent materials. Now converts via Schlick_to_F0() like the WebGPU renderer. (Regression from Fix iridescence energy conservation for mixed materialsΒ #32309.)

  2. The WebGPU renderer's XYZ_TO_REC709 matrix in evalIridescence was transposed, shifting all iridescence hues (visible when comparing webgpu_loader_gltf_iridescence against the WebGL version): GLSL mat3() takes its values column-major, while TSL's all-numeric mat3() builds a row-major Matrix3, so GLSL literals must be transposed when ported.

Includes cleanup on both sides: the split Fresnels are now locals instead of struct members, and the unused iridescenceF0 is removed.

Verified byte-identical against a reference implementation across view angles and both metalness paths; with both fixes the two backends render iridescence pixel-identically. Direct lighting unaffected.

@mrdoob mrdoob added this to the r186 milestone Jul 7, 2026
@github-actions

github-actions Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

πŸ“¦ Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 365.81
86.96
365.85
86.97
+36 B
+13 B
WebGPU 677.75
187.76
677.65
187.74
-106 B
-14 B
WebGPU Nodes 675.79
187.43
675.69
187.42
-106 B
-12 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 509.08
123.99
509.12
124.01
+36 B
+14 B
WebGPU 758.38
204.59
758.28
204.58
-106 B
-11 B
WebGPU Nodes 708.34
192.16
708.34
192.16
+0 B
+0 B

…iscattering.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mrdoob
mrdoob force-pushed the webgl-iridescence-fix branch from 59c4ea9 to 0cd0f34 Compare July 7, 2026 23:51
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

πŸ–ΌοΈ E2E screenshot tests

βœ… All examples render correctly again (run).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mrdoob mrdoob changed the title Shaders: Use iridescence F0 instead of view-angle Fresnel in IBL multiscattering. Shaders: Fix iridescence IBL multiscattering and transposed XYZ_TO_REC709. Jul 8, 2026
@mrdoob
mrdoob merged commit adf2145 into dev Jul 8, 2026
14 of 15 checks passed
@mrdoob
mrdoob deleted the webgl-iridescence-fix branch July 8, 2026 01:34
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.

1 participant