Search Unity

Custom Graphic mesh UVs correct in script but are unset in shader

Discussion in 'UGUI & TextMesh Pro' started by keenanwoodall, Feb 22, 2021.

  1. keenanwoodall

    keenanwoodall

    Joined:
    May 30, 2014
    Posts:
    598
    I'm working on a path/line renderer for UGUI. I'd like to pack info into each vertex so I can do stuff to the mesh in a shader.

    Right now the normals, tangents and uvs are correct:
    kkYi8ufvpJ.gif

    However I want to pack some extra info into the texture coordinates. The U and V channels correctly store the standard UVs but I want to store distance along the path in the W channel. I have debugged the values and have verified I'm setting the W channel to the correct value on the C# side, but all channels after U and V are always 0 in the shader.
    upload_2021-2-22_15-23-17.png

    Does UGUI only support the first two UV channels? The AddVert function takes Vector4s for UVs so I assumed I could use the whole vector

    [edit] So my current workaround is to use the first two channels of uv1 and uv2 in addition to uv0 for my extra data, but I'd prefer to pack as much info into one UV set as possible so I don't have to enable extra texture coordinates in the Canvas.
    t0OaAXyHPB.gif
     
    Last edited: Feb 25, 2021