Skip to content

Conversation

@mrdoob
Copy link
Owner

@mrdoob mrdoob commented Oct 22, 2025

Related issue: #32072 #32089

Description

This PR simplifies the multi-scattering compensation in the GGX BRDF for direct lighting, aligning both WebGL and WebGPU implementations with the standard Fdez-Agüera approximation.

Previously, BRDF_GGX_Multiscatter used a complex dual-DFG approach that computed separate energy terms for both view and light directions. This has been simplified to use a single DFG lookup based on the view direction only, matching the approach already used in computeMultiscattering for indirect lighting.

The simplified implementation:

  • Uses one DFG lookup instead of two (better performance)
  • Matches the standard Fdez-Agüera formula from the paper "Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting"
  • Provides consistent multi-scattering behavior between direct and indirect lighting
  • Maintains proper energy conservation for rough metallic surfaces

Changes:

  • src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js - Simplified BRDF_GGX_Multiscatter
  • src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js - Updated TSL implementation to match

Reference: http://www.jcgt.org/published/0008/01/03/

For comparison:
https://raw.githack.com/mrdoob/three.js/multiscattering/examples/index.html

@mrdoob mrdoob added this to the r181 milestone Oct 22, 2025
@github-actions
Copy link

github-actions bot commented Oct 22, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 350.11
84.81
349.63
84.67
-480 B
-134 B
WebGPU 604.15
169.43
604
169.37
-151 B
-57 B
WebGPU Nodes 602.75
169.19
602.6
169.13
-151 B
-60 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 481.77
119.56
481.29
119.42
-480 B
-139 B
WebGPU 673.57
184.91
673.42
184.85
-151 B
-54 B
WebGPU Nodes 615.56
168.12
615.56
168.12
+0 B
+0 B

@mrdoob
Copy link
Owner Author

mrdoob commented Oct 23, 2025

Lets keep Fdez-Agüera for IBL and the bidirectional formulation for discrete lights.

@mrdoob mrdoob closed this Oct 23, 2025
@mrdoob mrdoob deleted the multiscattering branch October 23, 2025 01:24
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