Skip to content

NodeMaterial: Remove shadowPositionNode fallback to reduce CPU load.#32699

Merged
Mugen87 merged 2 commits into
mrdoob:devfrom
Mugen87:dev4
Jan 9, 2026
Merged

NodeMaterial: Remove shadowPositionNode fallback to reduce CPU load.#32699
Mugen87 merged 2 commits into
mrdoob:devfrom
Mugen87:dev4

Conversation

@Mugen87

@Mugen87 Mugen87 commented Jan 9, 2026

Copy link
Copy Markdown
Collaborator

Related issue: #32675

Description

When investigating #32675, I have found out the root cause for the performance regression in r176 was #30962. I couldn't explain why #30962 increases the CPU load until I remember there were issues with Object.defineProperty(). I've simply removed the call from NodeMaterial and the CPU load reduced noticeably (from 46% to 34 % measured with Chrome Task Manager).

The example from #32675 (comment) is a bit of a edge case because it creates many individual materials (10000) but something similar can also happen in real-world scenarios with many individual render items.

I did not add real getter/setter as a replacement since that would include shadowPositionNode into getMaterialCacheKey(). Given the deprecated status, I think it's okay to bump the property now and get less CPU load in exchange.

@github-actions

github-actions Bot commented Jan 9, 2026

Copy link
Copy Markdown

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 355.36
84.47
355.36
84.47
+0 B
+0 B
WebGPU 621.33
172.53
621.11
172.47
-221 B
-61 B
WebGPU Nodes 619.93
172.29
619.71
172.23
-221 B
-58 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 487.31
119.25
487.31
119.25
+0 B
+0 B
WebGPU 692.57
187.86
692.34
187.8
-222 B
-56 B
WebGPU Nodes 642.37
175.08
642.14
175.03
-222 B
-54 B

@Mugen87 Mugen87 added this to the r183 milestone Jan 9, 2026
@Mugen87 Mugen87 merged commit 3881563 into mrdoob:dev Jan 9, 2026
10 checks passed
@sunag

sunag commented Jan 9, 2026

Copy link
Copy Markdown
Collaborator

I think this will need refactoring as well?

image

@Mugen87

Mugen87 commented Jan 9, 2026

Copy link
Copy Markdown
Collaborator Author

I'm not sure. I did not see a CPU lload reduction when removing the Object.defineProperty() usage in other classes e.g. Node. Maybe it's because shadowPositionNode had a setter?

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