Skinned mesh normals

I’m trying to displace vertices of a skinned mesh (one bone per vertex). I was able to move its vertices by setting the CFrame of each bone, but its normals still point upward. I calculated the correct normals for each vertex, and tried setting the normal by setting the bone CFrame like this:

--normal and bitangent switch places because bones all point upwards

bone.CFrame = CFrame.fromMatrix(position, tangent, normal, bitangent)

This doesn’t look quite right - there are no specular highlights, though I can see them before the mesh is displaced.

Is there a correct method of setting normals for a skinned mesh bone?

The CFrame math looks right. and I’m pretty sure the code for normal calculation is correct (calculating normals for gerstner waves - based on this)

2 Likes

What you are doing should work, but there may be something wrong with your normal/tangent/bitangent calculation.

I simplified the height calculation to a sine wave, and now the normals look right. Setting each bone’s CFrame to the TBN matrix at its position is indeed the correct way to set its normal.

Thank you for your help!