Describe the bug π¬
Hello,
Thank you for this great tool!
When exporting my scene, i saw that some of my objects has incorrect render.
After investigating, i manage to find that object with skinmeshrenderer, with blendshape and multiple frame are impacted.
I have done some research, and in ExporterMeshes.cs i saw the comment that say gltf support only one frame in ExportBlendShapes function :
// As described above, a blend shape can have multiple frames. Given that glTF only supports a single frame
// per blend shape, we'll always use the final frame (the one that would be for when 100% weight is applied).
int frameIndex = meshObj.GetBlendShapeFrameCount(blendShapeIndex) - 1;
But when getting the weight index, 0 is used in GetBlendShapeWeights function
var frameWeight = meshObj.GetBlendShapeFrameWeight(blendShapeIndex, 0);
weights.Add(smr.GetBlendShapeWeight(blendShapeIndex) / frameWeight);
I think, and in my case it works, that the code should be as the following, and getting the last frame
var frameCount = meshObj.GetBlendShapeFrameCount(blendShapeIndex);
var frameWeight = meshObj.GetBlendShapeFrameWeight(blendShapeIndex, frameCount - 1);
weights.Add(smr.GetBlendShapeWeight(blendShapeIndex) / frameWeight);
or simply
weights.Add(smr.GetBlendShapeWeight(blendShapeIndex) / 100);
but i don't really know if the last weight can be different than 100
To giving some more details, in my test with the current code, frameWeight = 16.666
smr.GetBlendShapeWeight(blendShapeIndex) = 55.5555
And the result smr.GetBlendShapeWeight(blendShapeIndex) / frameWeight = 3.3333
I don't think weight should be higher than 1. After importing the glb in another tool, it looks like it is because result is 333% so it have done more than expected in weight
Steps to reproduce π’
I attach an exemple prefab in unitypackage in zip file to reproduce and see difference between unity en glb export when changing the blendshape value
- Import the unity package
- Modify the blendshape value more than 50%
- Export as glb
- See difference unity viewer and glb viewer
Files to reproduce the issue β»
coussin.zip
Editor Version π²
2022.3
Render Pipeline and version
URP
UnityGLTF Version
2.18.7
Operating System π©βπ»
iOS, Windows, Android
When does this problem happen?
Additional Info π
No response
Validations π©Ή
Describe the bug π¬
Hello,
Thank you for this great tool!
When exporting my scene, i saw that some of my objects has incorrect render.
After investigating, i manage to find that object with skinmeshrenderer, with blendshape and multiple frame are impacted.
I have done some research, and in ExporterMeshes.cs i saw the comment that say gltf support only one frame in ExportBlendShapes function :
But when getting the weight index, 0 is used in GetBlendShapeWeights function
I think, and in my case it works, that the code should be as the following, and getting the last frame
or simply
weights.Add(smr.GetBlendShapeWeight(blendShapeIndex) / 100);but i don't really know if the last weight can be different than 100
To giving some more details, in my test with the current code, frameWeight = 16.666
smr.GetBlendShapeWeight(blendShapeIndex) = 55.5555
And the result smr.GetBlendShapeWeight(blendShapeIndex) / frameWeight = 3.3333
I don't think weight should be higher than 1. After importing the glb in another tool, it looks like it is because result is 333% so it have done more than expected in weight
Steps to reproduce π’
I attach an exemple prefab in unitypackage in zip file to reproduce and see difference between unity en glb export when changing the blendshape value
Files to reproduce the issue β»
coussin.zip
Editor Version π²
2022.3
Render Pipeline and version
URP
UnityGLTF Version
2.18.7
Operating System π©βπ»
iOS, Windows, Android
When does this problem happen?
Additional Info π
No response
Validations π©Ή