Search Unity

Question Albedo based on vertex position

Discussion in 'Shader Graph' started by froztwolf_unity, Jun 21, 2020.

  1. froztwolf_unity

    froztwolf_unity

    Joined:
    Nov 21, 2018
    Posts:
    20
    Hi.
    I have a bunch of boxes that I'm updating every frame to represent some underlying data.
    As they are GPU instanced, I'm trying to set up a texture that will let me colour each box based on the number it represents (0 to 1)

    I tried to make a shader that uses world position to determine the albedo, but can only get it to work in the fragment mode.
    upload_2020-6-21_18-35-15.png

    The idea here is that the tallest boxes would be completely green and the shortest ones completely red.

    How can I get either the world position of the mesh itself, or of the top vertices, in Shader Graph so I can set a single albedo for each box (per frame)?
     

    Attached Files: