TSL: Support layout functions with uniforms shared across materials - #33666
TSL: Support layout functions with uniforms shared across materials#33666shotamatsuda wants to merge 5 commits into
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
|
TBH, I find it not ideal that an additional flag would have to be used to avoid this issue. Can't the layout functions be cached per node builder by default? |
I agree, but it will have broader performance ramifications, I suppose, when layout functions are cached per material by default, since all the complex functions like those in |
|
I roughly measured the performance difference in the first frame involving node building in Cache per backend: approx. 100-105ms |
|
Although it needs further testing, by detecting whether a layout function has uniforms, it appears that the user-set "shared" flag will be unnecessary. |
Related issue: #31325
Description
This PR adds support for using layout functions with uniforms shared across different materials, by caching them per material when they contain uniform nodes.
Layout functions are built and cached per backend for the first material, and associated uniforms become invalid for other materials. This causes the following situation to fail.
With this PR, the example above works. Nested layout functions that includes uniforms are also supported.