-
Notifications
You must be signed in to change notification settings - Fork 115
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
Support InterleavedBufferAttributes in VRMUtils #1532
Conversation
If I understand correctly, this PR includes:
Is this correct? When do you need InterleavedBufferAttributes to work over three-vrm? I heard that gltf-transform might export models with interleaved accessors. Does the change in Also, if you find a part that is unclear or lacking descriptions inside these codes, feel free to comment. |
That is correct.
I started working on extensions for gltf-transform to support vrm 1.0 files (https://github.com/mrxz/vrm-transform). By default gltf-transform does indeed interleave vertex data. My goal is to optimize it for WebXR running on devices like the Meta Quest 2/3. Interleaved vertex data is recommended for these mobile GPUs.
Yes, the performance is impacted slightly. Here are some test results I gathered on my machine comparing the time each function takes before and after the changes:
The last two vrm models were converted to VRM 1.0 using UniVRM. As can be seen, the As a heads-up: I have found several places in three-vrm that can be optimized quite considerably (incl. springbones). So there will be more PRs coming once I've cleaned up my changes. One of these changes focusses on sharing a |
True. Thank you for the explanation.
I really appreciate the result table. it seems it's not well impacted about
The original motivation for why we needed to So it might be the high time to get rid of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really appreciate the contribution. Thank you very much! 😍
Loading a VRM file with interleaved vertex attributes works for the most part, but the
VRMUtils
removeUnnecessaryVertices
andremoveUnnecessaryJoints
did not support it.For
removeUnnecessaryJoints
the code is changed to usesetComponent
andgetComponent
which handle indexing into the array internally. The function now works with bothBufferAttribute
andInterleavedBufferAttribute
For
removeUnnecessaryVertices
an additional step is added at the start. It iterates over the index attribute and keeps track of which vertices are used by the geometry. In case all vertices are used, further processing is skipped as there are no unnecessary vertices. This can save quite a bit of processing time :-)In case not all vertices are used, it builds the index mappings (
originalIndexNewIndexMap
/newIndexOriginalIndexMap
) based on the order the vertices appear in the vertex buffers. This should preserve any optimizations done to the vertex buffers for cache/fetching efficiency.Interleaved buffers with unnecessary vertices is NOT supported by this PR. I have a working implementation, but it comes at a performance cost (~30-40% slower), so decided to not include it.