Skip to content

Conversation

@mrdoob
Copy link
Owner

@mrdoob mrdoob commented Nov 6, 2025

Related issue: #32190

Description

Fixes energy conservation issues in the physically-based lighting model when metalness is between 0 and 1.

The furnace test was losing energy for intermediate metalness values due to incorrect application of the Fdez-Agüera multiscattering formula, which is designed for pure dielectric OR conductor F0 values, not blended ones.

This fix follows the same approach used in the WebGLRenderer and matches the implementation used in EEVEE/Frostbite:

  1. Store base diffuse color (before metalness reduction) and compute diffuse contribution separately
  2. Compute specular color for dielectric path (F0 based on IOR) separately from the blended specular color
  3. Compute multiscattering separately for dielectric (F0=specularColor) and metallic (F0=baseColor) paths
  4. Mix the results based on metalness
  5. Use the dielectric path for diffuse energy conservation

Changes:

  • Added diffuseContribution and specularColorBlended PropertyNodes
  • Updated MeshStandardNodeMaterial and MeshPhysicalNodeMaterial to compute material properties correctly
  • Modified PhysicalLightingModel.computeMultiscattering() to accept F0 parameter
  • Updated PhysicalLightingModel.indirectSpecular() to compute separate multiscattering paths
  • Updated all BRDF calls to use appropriate color values

@mrdoob mrdoob added this to the r182 milestone Nov 6, 2025
@github-actions
Copy link

github-actions bot commented Nov 6, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 356.24
86.47
356.24
86.47
+0 B
+0 B
WebGPU 610.29
171.21
610.61
171.3
+320 B
+94 B
WebGPU Nodes 608.9
170.95
609.22
171.04
+320 B
+96 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 487.87
121.22
487.87
121.22
+0 B
+0 B
WebGPU 679.12
186.42
679.39
186.53
+273 B
+113 B
WebGPU Nodes 621.11
169.71
621.11
169.71
+0 B
+0 B

@mrdoob
Copy link
Owner Author

mrdoob commented Nov 6, 2025

@sunag looks good?

@mrdoob
Copy link
Owner Author

mrdoob commented Nov 6, 2025

Oh, looks like webgpu_loader_gltf_iridescence broke.
I'll continue tomorrow...

@sunag
Copy link
Collaborator

sunag commented Nov 6, 2025

@sunag looks good?

Yes, that's great.

@mrdoob mrdoob merged commit a8418f3 into dev Nov 7, 2025
10 checks passed
@mrdoob mrdoob deleted the webgpu-furnace branch November 7, 2025 03:27
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.

3 participants