Search Unity

Use vertex attributes in shader graph

Discussion in 'Shader Graph' started by Makio64, Oct 6, 2019.

  1. Makio64

    Makio64

    Joined:
    Nov 9, 2014
    Posts:
    27
    Hi,

    Is there a way to access custom vertex attributes from shader graph?

    Thanks in advance.
     
    starkr likes this.
  2. BenMora

    BenMora

    Joined:
    Jul 6, 2021
    Posts:
    7
    I came here hoping to find the answer. I'm guessing you are a seasoned professional Unity dev by now, but I'll throw in my two cents anyway.
    I think that the only channels for attributes are Vertex Color, and UV channels. So if you have your own custom float or Vector2, you'd just store it in one of the UV channels. If you have a Vector3, store it in Vertex Color.
     
  3. Ne0mega

    Ne0mega

    Joined:
    Feb 18, 2018
    Posts:
    755
    You can get all vertex attributes via shadergraph, (except bone weights I think) via Geometry nodes, (Input- Geometry) including vertex index.

    For custom ones, good idea to pack custom data into one of the extra uv channels or color if you dont need the actual color.

    I use color for vertex masks sometimes.
     
    Last edited: Sep 5, 2023