Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Using Vertex Color or 2nd UV to Store Position Doesn't Work?

Discussion in 'Shader Graph' started by funny123456, Mar 4, 2022.

  1. funny123456

    funny123456

    Joined:
    Sep 20, 2019
    Posts:
    14
    I have an object formed by multiple planes in different angle. I want to rotate each plane with an angle by the axis of {0, 1, 0} in shader graph.

    For testing, the mesh I am using have both vertex color and 2nd uv storing the center point of each plane. I exported the mesh as a fbx and import it into Unity. Then In the shader graph, I did something like (vertex position) - (vertex color), or (vertex position) - (2nduv). I expect all the planes will go to the origin but it doesn't happen and I am frustraed.

    I really appreciate it if anyone can help me.

    I attched my scene to make things more clear

    My shader graph
    Capture3.PNG

    Original mesh (with vertex color and 2nd UV storing centroid position of each plane, using vertex color and 2nd UV at the same time is just for testing)
    Capture2.PNG

    What I want to achieve in shader graph
    Capture.PNG
     

    Attached Files:

  2. funny123456

    funny123456

    Joined:
    Sep 20, 2019
    Posts:
    14
    What I get Capture4.PNG
     
  3. funny123456

    funny123456

    Joined:
    Sep 20, 2019
    Posts:
    14
    In Unity, uv although is a float 4, only the first 2 components can be used. So It is not enought to store a 3D positon (x,y,z). Vertex color in Unity only has 0-1 range so it is not useful either. Seems like using tangent is the way to go.
     
  4. funny123456

    funny123456

    Joined:
    Sep 20, 2019
    Posts:
    14
    Using multiple uv coordinates is also valid.