I have a mesh with skeleton animation and I have some additional skeleton animation changing the shape of the mesh. The rendering was strange and I found that the default calculations for the animated skeleton do not consider the shape of the actual mesh and uses the ‘original’ normals instead.
I’ve created a trivial example how it looks like.
I use custom NME material and additional animation for this transform but I hope that this example shows enough.
I consider that for this particular parts made separately and I can recalculate normals for them but I failed in my attempts. I think it should be some usage of getNormalsData/setVerticesData but I’m really stuck
adding @Evgeni_Popov as he is the best at this
Welcome aboard!
Your mesh normals are wrong in the glb file. If I remove them, the rendering is correct:
The result is flat shaded because only one normal is calculated for each face (in the shader), but you can still see that the shading is correct.
You should fix the normals in your DCC tool.
1 Like
Thank you for your answer. Unfortunately I’ve tried to remove normals and it didn’t work for the whole case.
I’ve updated playground with NME material
I have two textures morphed one to another, I’ve replaced them with trivial colors. With NME material I don’t have shadows when normals where removed so looks like I still need to recalculate them
You have to compute the normal using the derivatives of the world position:
However, it would be easier to just have the correct normals in the glb file.
2 Likes
Thank you sooo much. At least now I understand the math behind.
I’ve tried with fixing normals in file and failed.
Can you explain what I missed with the original file during export?
https://github.com/bagiran/BabylonTests/raw/main/s0.blend
As I understand I have an initial shape of pankake and then normals exports for it whitout updateble state.
Sorry, I know ~0 of Blender!
Maybe @PatrickRyan will be able to help on this one?
@BagiraN, there are a couple of things going on here. The first is that if you don’t want to export your normals to glTF for any reason, you can deselect them in the export window rather than needing to delete them in code:
The next thing to remember is that your mesh starts your timeline as a sphere scaled down to 1% in height. The render you see in Blender is recalculating the normals of the mesh each frame as the sphere is scaled. What is exported if you include normals, however, is the normal at the first frame of animation. This means that your exported mesh normals will be derived from the squashed sphere. You can somewhat fix this by reversing your animation the animation with your mesh as a sphere, and then squash it. This will export with normals that look spherical and smooth, but you will quickly notice that as your sphere squishes in the animation, the normals still render as though the mesh is still spherical.
The better way to do this for such a drastic delta is with morph targets (shape keys). This is because your morph target also has normals that can be exported and when you interpolate between the base mesh and your morph target, the normals will also interpolate. This will give you a smooth transition between spherical normals and squashed normals and each state will reflect light correctly.
2 Likes
Thank you very much for the answer. To be honest I know about exporting normals, but with information that my normals ‘are wrong’ I thought that it can be a different way to have them right. I’ve tried to use the animation in backward direction and with ‘ball’ normals render is a little bit better but still looks suspicious.
I’ve also thought about morphing, but I have this ‘inflation’ as part of complex animation of the toad, so making separation on ‘the other animations’ and morphing can be tricky, especially when gluing them back together. So that was the reason why I searched for normals recalculation. I decided that some sacrifice in performance is cheaper than full rework of existing model.
1 Like
Looks like I did right things but they’re not worked for me and normals recalculation was the right decision. May be I come again later with normals smoothing, but there more information about smoothing normals in shaders so I still get chance to do it by myself.
Thank you very much againg, it was great to meet such a knowledgeable person
2 Likes