@regalir wrote:
And while, at first, it seems obvious that the exported normals should not be dependent on the skin deformation at a given time, I am not sure that this assumption still hold true if the deformation is actually a combination of skins, blend shapes and/or vertex caches and by the way each of these systems interact with each other. I guess that in my previous posts I created more confusion than provided answers. I apologize for that!
It seems obvious because it's correct. The assumption does hold true, end of story. You can't defend the indefensible and no amount of word salad can change it. (All those systems interacting! You mean the systems I'm also doing in my own engine? And so on.)
But this is a Maya bug, and not the FBX SDK at all obviously. Your team has been winning for a long time, otherwise support for FBX wouldn't be critical in every 3D package and engine.
What's likely is someone from Alias in 2002 or something had a late night out partying on LotR money and wrote the data out from the deformed normals array and not the mesh, clocked out and called it a day.
When Alias wrote the OBJ export, there was no skinning, so they would have used the deformed normals, because had to use the deformed geometry. When it came time to write the FBX export, they perhaps copied code and used the deformed normals by mistake.
It was never corrected because it's probably rarely encountered. Most skinned meshes are going to be put into bind pose for export, and a lot of times animations are placed in separate files. But my example is just a simple animated mesh in one file, and it breaks.
Having calculated deformations for one pose on import is totally useless to 100% of people importing from FBX, so Maya should make a correction. Otherwise, why not deform the geometry too? Because it doesn't make sense. You'd have to unwind all deformations to get the geometry, what a pain! Just like you have to unwind all deformations to get the normals. Doesn't make sense.
I'm concerned that the solution proposed calculates the smoothing based on deformed normals. It's probably fine, but I can see theoretical issues where normals could be smoothed when they weren't supposed to be. Hmm. I'm surprised FBX doesn't know about hard/soft edges and they have to be computed from normals in the first place. Such dirty workarounds for one mistake!
And thanks for your help. This workaround is probably satisfactory, but I'll need to try it. I know you are trying to solve an issue for us rather than take a challenge to the Maya team. They wouldn't be able to defend it but they have a big ship that moves slowly and they probably wouldn't prioritize a fix even if they acknowledge it. But I would be happy to still report it to them and it would be interesting to see their answer.
Let me put the cherry on top for you and for @ilan.keshet also. Here's Blender importing a Maya mesh (not using FBX SDK) and the normals are wrong in the exact same way as in my engine:
In the above example, you can see that Blender then deforms the mesh into the pose, meaning the normals are now double-transformed (creating the very dark wing). Blender's devs didn't catch the issue; @ilan.keshet and I did.
Blender offers the option to not accept the normals, in which case Blender re-computes the normals:
...and hard edges are lost... ooooof!
So they are trusting the export purely as FBX describes it. They may be unaware of the Maya export issue, but it would require something like what we're discussing to work around it, at least partly.
But no workaround appears to solve the matter. All of this can be avoided if the normals were not baked, and it would be nice to see future versions of Maya not have this problem. All our suffering would end!
Dave