Skip to content

TSL: Share EON directional albedo in indirect lighting. - #34660

Merged
Mugen87 merged 2 commits into
devfrom
codex/shared-eon-albedo
Sep 26, 2026
Merged

Mugen87 merged 2 commits into
devfrom
codex/shared-eon-albedo

Conversation

@mrdoob

@mrdoob mrdoob commented Sep 25, 2026

Copy link
Copy Markdown
Owner

With diffuse roughness enabled, PhysicalLightingModel constructs the same EON_DirectionalAlbedo graph in both indirectDiffuse() and indirectSpecular().

Create one shared node in start() and reuse it in both methods. This preserves the existing method signatures and multiplication order.

For a material lighting graph with diffuse roughness and one directional light (WGSL):

Before After
Registered nodes 474 424
Node allocations 842 750

This saves 50 registered nodes and 92 allocations per material graph. The same reduction was measured with 0, 1, and 4 direct lights on both WGSL and GLSL.

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

πŸ“¦ Bundle size

Full ESM build, minified and gzipped.

Before After Diff
Core 389.92
102.29
389.92
102.29
+0 B
+0 B
WebGL 372.59
87.13
372.59
87.13
+0 B
+0 B
WebGPU 427.23
114.94
427.28
114.95
+58 B
+14 B
WebGPU Nodes 713.9
196.03
713.96
196.06
+58 B
+23 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 517.23
124.23
517.23
124.23
+0 B
+0 B
WebGPU 767.44
205.57
767.5
205.59
+58 B
+22 B
WebGPU Nodes 713.35
192.1
713.35
192.1
+0 B
+0 B

@mrdoob mrdoob added this to the r187 milestone Sep 25, 2026
@mrdoob
mrdoob requested a review from Mugen87 September 25, 2026 10:08
@Mugen87

Mugen87 commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

That looks good but I've realized now something: It's maybe better to give the EON BRDFs a layout like other BRDF functions:

} ).setLayout( {
name: 'V_GGX_SmithCorrelated',
type: 'float',
inputs: [
{ name: 'alpha', type: 'float' },
{ name: 'dotNL', type: 'float' },
{ name: 'dotNV', type: 'float' }
]
} ); // validated

That should further improve the build performance since it better scales with multiple lights. Layout functions are built once and then cached. Calling a plain Fn more than once runs the JS callback again and creates a fresh copy of the whole sub node graph.

That's not a problem when executing the shader but it affects build time.

@Mugen87

Mugen87 commented Sep 26, 2026

Copy link
Copy Markdown
Collaborator

Merging. The suggested layout Fn changes can be done separately.

@Mugen87
Mugen87 merged commit 1af6de5 into dev Sep 26, 2026
10 checks passed
@mrdoob

mrdoob commented Sep 26, 2026

Copy link
Copy Markdown
Owner Author

Thank you!

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