Download

Theoretical accurate skinning

Hi, I’m wondering if UE4 code has good skinning implementation. For example when we look at SkeletalRenderCPUSkin.cpp, exactly in the SkinVertexChunk function, we could examine that the matrices that affects tangents in vertices have full transformation carried with (scale, position, rotation). But for me it seems it should be rather to use rotation only matrices for vertex tangents components, and only full matrices for vertex position components. I make this assumption because imo scale should only affect position of vertex but not the normals (or tangents), which may cause artifacts after the mesh was skinned.

Am I right in this case? Could someone explain me this implementation point of view a little bit? Thanks in advance for replies :slight_smile:

Probably no, because tangents depend on the positions of neighbouring vertices (angles of connecting edges). I guess it is cheaper to derive that information from the full bone matrices rather than iterating through all mesh components and calculate those on a mesh level at runtime.

I understand that calulating tangents from vertices directly will be not efficient. But I’m scoping rather on the just matrix multiplication only. Because I’ve seen some artifacts, when the normals on the surface are inverted according to negative scale component of matrices (normals seems to be derived from tangents). When I’m changing the code responsible to this stuff (namely multiplaying tangents by the same matrices as the positions were multiplied, but with scale reverted to 1,1,1) the artifacts disappears, and everything (including shading also) looks fine.

Thats interesting, so you are using the absolute value of scale (always positive). Which would make sense, in maya for example normal calculation is taken care of in the shape node itself so those types of issues dont appear. However that means that a deforming mesh in maya is extremely slow (comparatively, its still fast, but it could be way faster if it wasnt evaluating normals update every frame).

This is somewhat affecting me too as my character rigs do have bones in them that scale. I have not come across a case where my bones reach negative values, but it kinda would make sense to adress that somehow.