-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
VTF morph targeting with multiple meshes sharing same position/normal attributes #23095
Comments
Ok this is way harder than I thought. Since each morph textures are an array of every morph target, we need a map from "set of morph target positions/normals" to the texture. We cannot create textures for each individual morph targets. I was thinking about changing the key of the WeakMap I need your help @Mugen87 . First of all is this a problem that is worth resolved? |
Why can't you share a single geometry if position and normal data are identical?
In my opinion, no. The implementation assumes that vertex data are organized on a geometry level. It was planned to expand the data support in |
I'm afraid we can't support this use case in |
That sounds very reasonable. I was not sure how common this kind of buffer structure is among the scene.
I probably have to implement this as my next action. Thank you for your quick response as usual! |
Let me ask about this in a separated discussion. |
To address the issue that morph textures consumes gigantic amount of VRAM See: mrdoob/three.js#23095
To address the issue that morph textures consumes gigantic amount of VRAM See: mrdoob/three.js#23095
For the reasons described in #17089, having one buffer for every BufferGeometry is not as efficient as sharing buffers. I don't think we need to solve that now, but it's a pretty common layout for glTF files and if there are problems with using morph targets we'll eventually run into that again. Perhaps we can discuss it in #17089. |
fyi, I've added a utility function to three-vrm, that makes morph textures compact against such models |
To address the issue that morph textures consumes gigantic amount of VRAM See: mrdoob/three.js#23095
Describe the bug
Context: I'm a contributor of VRM, which is a humanoid-oriented glTF extension which is intended to be used as humanoid avatars.
I noticed vram consumptions of glTF models are increasing starting from Three.js r133, sometimes loading single humanoid glTF is enough to knock-off my WebGL context.
I compared between r132 and r133 using greggman/webgl-memory and and I spotted an unforgivable difference at the texture memory consumption between them.
(I can't provide the model I used for the experiment since reasons, I'm sorry)
r133 has a big improvement on morph targeting part, enabling using 8 or more morph targets at the same time using VTF morph targeting (I mean, I appreciate this change a lot).
#22293
I've looked into the code behind the VTF morph targeting, and I noticed that, despite the model shares a single position/normal attributes between meshes the morph target textures are generated for each meshes.
three.js/src/renderers/webgl/WebGLMorphtargets.js
Lines 53 to 156 in 1a241ef
I can blame the structure of model itself of course, since it should have only necessary part of VBOs for each meshes plus morph targets should only be applied to necessary parts, but since the issue does not happen in r132 or prior, I want to fix this from Three.js side.
I think I can try to fix this part.
Tangential issues
I also noticed I can't free these textures when I unload the model.
Is there any way to unload the morph target textures?
Live example
https://glitch.com/edit/#!/three-r133-vtf-morph-memory-leak
Platform
WebGL1Renderer
. Only happens with WebGL2.The text was updated successfully, but these errors were encountered: