meshoptimizer
meshoptimizer copied to clipboard
The hierarchy is not preserved when using -kn -noq
i am using glTFast plugin for Unity to load glb files and i when i try to use gltfpack to optimize the model, i found that i have to pass (-noq -kn) parameter to keep name (which is what i need). But the problem here that it moves the mesh to be a child of the node
this is the source model

and this is the optimized one with gltfpack

So, how exactly can we preserve the hierarchy with both child-parent relation and names?
This is required by KHR_mesh_quantization extension as the extra node specifies the dequantization transform. The only way to preserve the hierarchy completely is to disable quantization via -noq.
thank your reply. Actually i also disable quantization because after that i use draco comoression using (gltf-transform). so i use -noq -kn and still the issue here.
If you are passing -noq then you'd need to upload a glTF model that has its hierarchy changed when both options are passed.
sorry but i didn't get it from your last reply. Isn't it suppose for no quantization and keeping nodes to work together? i mean that after using the tool i should have an optimized model but the heirarchy shouldn't be changed if i pass those two options
Yes, that's correct.
So this is a bug then, because this is not the case for any model i try with. at least in unity
Actually, sorry, I think the above is wrong.
Looking at the code, I think gltfpack will always insert a new node for a mesh. This may be necessary in certain cases because glTF requires that there only be one mesh per node, and the processing pipeline could in theory generate more than one mesh so it's done that way for simplicity.
The quantization will indeed affect whether the extra node gets a transform but it doesn't affect whether the node is added at all - I think I remembered this incorrectly because three.js treats these a little differently, but from the glTF perspective there's indeed going to be an extra node.
Thank you for your fast response. It's very sad that this great tool isn't support such thing. I think i have to deal with it then inside unity. But it would be great if there is a solution for that in the future. Thanks
I am on the same page with @AhmadMansy . I would like to exchange optimised and non-optimised gltfs without further code changes. This would fit my dev workflow much better.
The core issue really here is that it's impossible to use quantization without changing the nodes. While gltfpack provides no-quantization mode, it's not as efficient and not the primary purpose of the tool. From this perspective really it's the case that applications need to adapt to a potentially changing node structure, since "optimized glTF" and "preserved node structure" are goals that fight each other.
The only possibility here is that gltfpack supports non-quantized mode in a special way where it takes extra care to not modify the hierarchy at all. I haven't looked yet into how easy it would be to reconcile with the existing path.
thank you the last part of your reply is the key and is exactly what i am looking for. I really appreciate your concern.