Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TiledLightsNode: Fix cache-key performance #30130

Merged
merged 7 commits into from
Dec 16, 2024

Conversation

sunag
Copy link
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.

Copy link

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
12 checks passed
@sunag sunag deleted the dev-tiled-performance branch December 16, 2024 18:58
@ligaofeng0901
Copy link
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.

2 participants