Search Unity

Feature Request Array Properties

Discussion in 'Shader Graph' started by UserNobody, Apr 23, 2021.

  1. UserNobody

    UserNobody

    Joined:
    Oct 3, 2019
    Posts:
    144
    Hello there,
    I just recently found out that there's no way in creating float/color or whatever arrays in Shader Graph. There is the only Texture2DArray, which is cool. but I don't understand why there aren't any other types of array support.

    I really need to pass a vector array and now just have no idea what to do... Will this be ever implemented?
     
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    Hi,

    Maybe a workaround might be that you write the values to a texture and then read at a specific index (coordinate.) You could encode your vectors to colors?
     
  3. UserNobody

    UserNobody

    Joined:
    Oct 3, 2019
    Posts:
    144
    Hey there, I mean this is pretty much the only choice I have. However, it would be cool to have the ability to just send an array of any data. Is would be just more clean, optimal, performant. So I hope Unity will have this implemented at some point. I really like Shader Graph, although it's kind of limited as of now... Not that flexible in comparison to something like Amplify Shaders.
     
    DDoop likes this.
  4. brgishy

    brgishy

    Joined:
    Jul 9, 2013
    Posts:
    31
    Hello,

    I too think this would be an amazing feature to add. I'm working on a material combining system and I need the ability to have Float[] and Color[] shader properties. It would be great if Shader Graph made this possible.
     
  5. hickv

    hickv

    Joined:
    Oct 31, 2018
    Posts:
    40
    I haven't tested it with arrays, but you can create variables manually when using Custom Node setup with a file. They don't show up in the inspector. Try creating the arrays manually in the file and access them using C#, it might work.
     
  6. brgishy

    brgishy

    Joined:
    Jul 9, 2013
    Posts:
    31
    Thanks @hickv, I didn't know you can do that. Feels hacky, but it is working and might make a good workaround for the moment. I can't get this data to properly save to the material so I'll need to set this data at runtime. Still hoping Unity will add this feature though.
     
    DDoop likes this.
  7. DDoop

    DDoop

    Joined:
    Jul 6, 2021
    Posts:
    2
    Can you please share the code/scene you used that worked? I've been struggling with this for a few days.
     
  8. brgishy

    brgishy

    Joined:
    Jul 9, 2013
    Posts:
    31