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

WebGPURenderer, NodeMaterial: same variant between different Skeletons? #27741

Closed
0b5vr opened this issue Feb 13, 2024 · 2 comments · Fixed by #27753
Closed

WebGPURenderer, NodeMaterial: same variant between different Skeletons? #27741

0b5vr opened this issue Feb 13, 2024 · 2 comments · Fixed by #27753
Assignees

Comments

@0b5vr
Copy link
Collaborator

0b5vr commented Feb 13, 2024

Description

Currently, the NodeMaterial system creates different shader program variants between different skeletons, resulting in a long compilation time.
Is it possible to use the same program variant between skinned mesh with different skeletons?

Related: #27398

Context:

In three-vrm, we are using a function called removeUnnecessaryJoints, which generates skeletons for each mesh to prevent exceeding the maximum uniform count on mobile devices.

The function body:
https://github.com/pixiv/three-vrm/blob/v2.0.10/packages/three-vrm/src/VRMUtils/removeUnnecessaryJoints.ts

Solution

Currently, we are dispatching variants by adding skeleton uuid to the cache key.

cacheKey += object.skeleton.uuid + ',';

it would be nice if we could put a bone count instead and make it work properly, for example.
Probably we have to modify how we upload bone matrices as a uniform array? since it's not working as is.

Alternatives

Alternatively, I can change the removeUnnecessaryJoints to create less skeletons when there are many meshes but I'm yet to come up with a way.
I can align the bone count between skeletons by adding dummy bones at the tails of arrays.

Additional context

I think this is pretty much the bare minimum to check the behavior.

https://glitch.com/edit/#!/denim-valley-echinodon

@sunag
Copy link
Collaborator

sunag commented Feb 13, 2024

it would be nice if we could put a bone count instead and make it work properly, for example.
Probably we have to modify how we upload bone matrices as a uniform array? since it's not working as is.

Sounds good define a bone count as part of cache key, I think that some modifications will be necessary in SkinningNode to this work properly, maybe manage reference nodes like we did in MorphNode, I will have to check that.

@0b5vr
Copy link
Collaborator Author

0b5vr commented Feb 14, 2024

I think this is pretty much the bare minimum to check the behavior.

https://glitch.com/edit/#!/denim-valley-echinodon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants