Is there a way to get the animation transform for vertices of a skinned mesh?

Geometry shader implementations you’re going to see are all using geometry shader’s adjacency data. Unity does not support adjacency data in the geometry shader, nor does any other real time game engine FYI. It’s purely a thing that academics play with that sees no real world usage. You’re going to have to stick to your asset postprocessor.

For a single extra normal, you just set the tangent vector to the normal you want to use. But for 3 extra normals you’ll want to use the tangent space trick I mentioned. That’s really the only one that’ll work with Unity’s skinned meshes. In script you’ll want to take the normal and tangent of each vertex you’re encoding into, use those to create a matrix, get it’s inverse, and then transform your normal into that space using the inverse of the matrix. Something like this:
C# code:

// extract the normal & tangent from the vertex data, calculate the bitangent
Vector3 normal = mesh.normals[currentIndex];
Vector4 tangentAndBitangentSign = mesh.tangents[currentIndex];
Vector3 tangent = tangentAndBitangentSign; // implicit cast to Vector3
Vector3 bitangent = Vector3.Cross(normal, tangent).normalize * tangentAndBitangentSign.w;

// construct the tangent to object space matrix, and its inverse
Matrix4x4 tangentToObject = new Matrix4x4();
objectToTangent.SetRow(0, tangent); // note, these might need to be SetColumn(). I forget which one is correct
objectToTangent.SetRow(1, bitangent);
objectToTangent.SetRow(2, normal);
Matrix4x4 objectToTangent = tangentToObject.inverse;

// apply the object to tangent space transform to the object space normals and store them
mesh.SetUV(2, objectToTangent.MultiplyVector(adjacentNormalA));
mesh.SetUV(3, objectToTangent.MultiplyVector(adjacentNormalB));
mesh.SetUV(4, objectToTangent.MultiplyVector(smoothedNormal));

Shader code:

float3 normal = v.normal.xyz;
float3 tangent = v.tangent.xyz;
float3 bitangent = normalize(cross(normal, tangent)) * v.tangent.w;
float3x3 tangentToObject = float3x3(tangent, bitangent, normal);
float3 objectSpaceSmoothedNormal = mul(tangentToObject, v.texcoord4.xyx); // or wherever you've packed the smooth normal
1 Like