Skip to content

Conversation

mrdoob
Copy link
Owner

@mrdoob mrdoob commented Oct 22, 2025

Description

This PR implements proper energy conservation in the physical lighting model by ensuring that diffuse and specular reflections correctly account for the Fresnel effect.

Previously, the diffuse term did not account for energy taken by specular reflection, causing materials to appear over-bright, especially at grazing angles. This violated the fundamental principle that reflected energy cannot exceed incident energy.

The implementation modifies RE_Direct_Physical and RE_IndirectDiffuse_Physical to attenuate the diffuse contribution by (1.0 - F), where F is the Fresnel term. This ensures total reflected energy (diffuse + specular) does not exceed incident energy, and diffuse contribution properly decreases as specular increases, particularly at grazing angles.

The changes result in more physically accurate rendering, especially for metallic and glossy surfaces. Materials no longer appear over-bright at grazing angles, metals show reduced diffuse at high metalness values, and Fresnel response is more accurate across all viewing angles.

Performance impact is minimal - the implementation reuses the existing Fresnel calculation with one additional multiply per light source.

For comparison:
https://raw.githack.com/mrdoob/three.js/webgl-pbr/examples/index.html

@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
350.58
84.88
+474 B
+73 B
WebGPU 604.15
169.43
604.15
169.43
+0 B
+0 B
WebGPU Nodes 602.76
169.19
602.76
169.19
+0 B
+0 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 481.77
119.56
482.24
119.64
+474 B
+76 B
WebGPU 673.57
184.88
673.57
184.88
+0 B
+0 B
WebGPU Nodes 615.56
168.12
615.56
168.12
+0 B
+0 B

@mrdoob
Copy link
Owner Author

mrdoob commented Oct 22, 2025

Not sure about this one.

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