Texture UVs: Transitioning between multiple UV sets

I am using an imported mesh with a skinned mesh renderer. The blend shape value changes during runtime. The problem is that the texture UVs become stretched when the mesh is deforming.
So the imported UV0 is only accurate for blendshape 0. With blendshape 100, the UVs are too visibly stretched.
I can create multiple UV sets in the model. Is there a way to transition between multiple texture UVs so that when the mesh is deforming the texture UVs can be recalculated, something like an average value between multiple UVs? Is this something that needs to be done at a shader level, or scripting level?

Right now I think a solution would be to create a special version of the standard shader, and instruct the shader to use a certain UV channel in the mesh for texture UVs. And in a script, continuously alter the UV channel based on the current blendshape weight. Is this a viable solution? Or is there an easier solution I am missing?

Thanks

maybe helpfull Rendering 3

1 Like

Ok, thanks for the link.
It looks useful.

2616986--183635--uv.jpg

Off the top of my head, I’m thinking:

meshRenderer.uv2 = new Vector2 [numberOfUvCoordinates]; //UV2 is the newly calculated UV channel

//Called only when the blendshape value changes. Re-calculate the UVs to be used
void OnBlendshapeValueChange()
{
  for(int i=0; i < numberOfUvCoordinates; i++)
  {
    Vector2 uv0Coordinate = meshRenderer.UV0 [i];
    Vector2 uv1Coordinate = meshRenderer.UV1 [i];

    //Calculate the new UV value based on the current blendshape value
    Vector2 newUVvalue= Vector2.Lerp (uv0Coordinate , uv1Coordinate , currentBlendshapeValue / 100.0f);
    meshRenderer.uv2 [i] = newUVvalue;
  }
}

The shader code would then use UV2 for the texture UVs.
I have no idea if this is the right solution to use, or if this would even work.
The other issue to worry about is the GI system overwrites certain UV channels during runtime, if using realtime GI (If I understand how the GI system works).

I have exactly have the same problem like yours, but didn’t find any solution.Have you got any proper solution and can you please help me about this problem.I am new in unity3D and I know basic level level of scripting knowledge.
Thanks.

Sorry, I can’t help you. I haven’t looked into doing this since I created the post. The link supplied above is most likely the solution.