Skip to content

Fix iridescence energy conservation for mixed materials#32309

Merged
mrdoob merged 3 commits into
devfrom
iridescence
Nov 19, 2025
Merged

Fix iridescence energy conservation for mixed materials#32309
mrdoob merged 3 commits into
devfrom
iridescence

Conversation

@mrdoob

@mrdoob mrdoob commented Nov 19, 2025

Copy link
Copy Markdown
Owner

Related issue: #31350

Description

This PR fixes an issue where iridescence was not correctly calculated for materials with intermediate metalness values (mixed dielectric/metallic), leading to incorrect energy conservation.

Before After
Screenshot 2025-11-19 at 11 31 50 Screenshot 2025-11-19 at 11 31 56

Changes

  • Split iridescenceFresnel into iridescenceFresnelDielectric and iridescenceFresnelMetallic in the PhysicalMaterial struct.
  • Updated lights_fragment_begin.glsl.js to calculate these separately using specularColor (0.04) and diffuseColor (base color) respectively.
  • Updated lights_physical_pars_fragment.glsl.js to use the correct Fresnel term for dielectric and metallic paths in RE_IndirectSpecular_Physical.
  • Applied the same logic to WebGPURenderer in src/nodes/functions/PhysicalLightingModel.js, splitting iridescenceFresnel and iridescenceF0 calculation and usage.

This aligns the behavior with Khronos glTF expectations and fixes the issue reported in #31350.

(Solved in a single prompt using https://antigravity.google/ with Gemini 3.0)

@mrdoob mrdoob added this to the r182 milestone Nov 19, 2025
@github-actions

github-actions Bot commented Nov 19, 2025

Copy link
Copy Markdown

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 356.28
86.49
356.68
86.53
+391 B
+43 B
WebGPU 616.52
173.1
616.83
173.15
+309 B
+43 B
WebGPU Nodes 615.13
172.85
615.43
172.9
+309 B
+44 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 488.15
121.31
488.54
121.36
+391 B
+42 B
WebGPU 688.76
189.02
689.07
189.06
+309 B
+42 B
WebGPU Nodes 630.48
172.25
630.48
172.25
+0 B
+0 B

@mrdoob mrdoob changed the title WebGLRenderer: Fix iridescence energy conservation for mixed materials. Fix iridescence energy conservation for mixed materials Nov 19, 2025
@mrdoob

mrdoob commented Nov 19, 2025

Copy link
Copy Markdown
Owner Author

@sunag Does the TSL port look good to you?

@mrdoob mrdoob mentioned this pull request Nov 19, 2025
@sunag

sunag commented Nov 19, 2025

Copy link
Copy Markdown
Collaborator

@sunag Does the TSL port look good to you?

Yes, it looks great to me.

@sunag

sunag commented Nov 19, 2025

Copy link
Copy Markdown
Collaborator

(Solved in a single prompt using https://antigravity.google/ with Gemini 3.0)

👀

@mrdoob mrdoob merged commit 8acf22c into dev Nov 19, 2025
10 checks passed
@mrdoob mrdoob deleted the iridescence branch November 19, 2025 23:04
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