Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Declaring array/buffer properties in ShaderGraph or VFXGraph; why not?

Discussion in 'Graphics Experimental Previews' started by PhilSA, Feb 3, 2020.

  1. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    I am not an expert in this, but I often think of situations where I would really want to declare something like a StructuredBuffer in my shaders, or an array of points in VFX Graph. It's often way more convenient than storing data in textures, and very useful for doing stuff with compute shaders, etc...

    Is there a reason why it's preferable not to have the option? Are textures always a better idea? Or would it be too difficult to add this feature?
     
  2. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,683
    Hardware limitation - StructuredBuffer require SM5 (full support) SM4 (pixel and compute shaders), opposite - textures is basic thing which runs on every shader models and hardwares :)
     
    PhilSA likes this.
  3. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    Thanks for the explanation. I do feel like the HDRP could/should have this feature though, since it kinda has the mission statement of "not being limited by old common-denomitator hardware or tech"
     
  4. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,683
    Yep, definitely for things like HDRP it'll be good feature
     
  5. jffonseca

    jffonseca

    Joined:
    Mar 4, 2020
    Posts:
    13
    Any updates on this? Did you found a way to read buffers on shadergraph? i dont understand why is this not possibl!
     
  6. MaxWitsch

    MaxWitsch

    Joined:
    Jul 6, 2015
    Posts:
    114
    In SG you can declare arrays in a custom fuction node outside the function.
    However, for accesing and work with the data you also need to do that in the custom function, since Shadergraph has no datatype for arrays or buffers, nor has it any way to iterate throug arrays or buffers.

    And in the beta of 2021.2 vfx graph has a datatype for buffers for (floats, vectors and matrices)
    Cheers
     
  7. vx4

    vx4

    Joined:
    Dec 11, 2012
    Posts:
    181
    for VFXGraph you can use GraphicsBuffer now.
     
    ToxicTree likes this.