Skip to content

TiledLightsNode: Fix cache-key performance#30130

Merged
sunag merged 7 commits intomrdoob:devfrom
sunag:dev-tiled-performance
Dec 16, 2024
Merged

TiledLightsNode: Fix cache-key performance#30130
sunag merged 7 commits intomrdoob:devfrom
sunag:dev-tiled-performance

Conversation

@sunag
Copy link
Copy Markdown
Collaborator

@sunag sunag commented Dec 16, 2024

Related issue: #30062

Description

Improve cache-key performance by removing PointLights cache-key:
There's no need to recreate the shader when adding or removing PointLights in Tiled Lights.

Comment thread examples/jsm/tsl/lighting/TiledLightsNode.js Fixed
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Dec 16, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 339.24
79.02
339.24
79.02
+0 B
+0 B
WebGPU 486.17
134.89
486.17
134.89
+1 B
-6 B
WebGPU Nodes 485.63
134.79
485.64
134.79
+1 B
-3 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 465.13
112.08
465.13
112.08
+0 B
+0 B
WebGPU 555.32
150.32
555.29
150.3
-28 B
-21 B
WebGPU Nodes 511.24
140.09
511.21
140.06
-28 B
-23 B

@sunag sunag marked this pull request as ready for review December 16, 2024 07:48
@sunag sunag added this to the r172 milestone Dec 16, 2024
@sunag sunag merged commit d7b6a32 into mrdoob:dev Dec 16, 2024
@sunag sunag deleted the dev-tiled-performance branch December 16, 2024 18:58
@ligaofeng0901
Copy link
Copy Markdown
Contributor

Hello @sunag
in https://github.com/mrdoob/three.js/blob/dev/examples/jsm/tsl/lighting/TiledLightsNode.js#L71 . The method customCacheKey depends on this._compute, which is initialized in method _create.

But I found customCacheKey is invoked before _create, it cause an error Cannot read properties of null (reading 'getCacheKey')

The example https://github.com/mrdoob/three.js/blob/dev/examples/webgpu_lights_tiled.html works fine because setSize of light node is called in renderLoop in https://github.com/mrdoob/three.js/blob/dev/examples/webgpu_lights_tiled.html#L190

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