One Mesh, Two UVs, Transforming Texture

Hello, I’ve made a mesh, and I have two copies with different UV maps.

I would like to transform the shape of a texture by remapping/projecting UV-A to UV-B.

Has anyone transplanted UVs from mesh to another (DX11)?

This is done differently, you have to apply both uv maps to your mesh in 3d editor, then export it in format supporting multi tex coords (such as collada).
Then you can add line in your vs_in:
struct VS_IN
{ pos : POSITION;
uv0: TEXCOORD0;
uv1: TEXCOORD1; }

then you use it normally in a shader
i guess you can upload your models, if that sounds bit complicated…

as anto said, i would prepare the data differently, one mesh with two sets of UV coordinates. then in the shader you can easily morph between them with a Lerp and it is very efficient because everything happens on the GPU.

in order to do that you need to add the extra UV coordindates channel in the shader that you are using. so clone the shader, add the extra channel and a morph parameter. something like:

//make an input pin for the morph parameter
float Morph;

vs2ps VS(
    float4 Pos : POSITION,
    float4 TexCd : TEXCOORD0,
    float4 TexCd2 : TEXCOORD1)
{
    //inititalize all fields of output struct with 0
    vs2ps Out = (vs2ps)0;

    //transform position
    Out.Pos = mul(Pos, tWVP);

    //morph the two UV channels
    float2 morphed = lerp(TexCd, TexCd2, Morph);

    //transform texturecoordinates
    Out.TexCd = mul(morphed, tTex);

    return Out;
}

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.