Search Unity

Help Wanted DrawMeshInstancedIndirect and Shader Graph

Discussion in 'Shader Graph' started by Aaron-Meyers, Aug 2, 2019.

  1. Aaron-Meyers

    Aaron-Meyers

    Joined:
    Dec 8, 2009
    Posts:
    164
    I'm evaluating LWRP/Shader Graph for a project that would rely heavily on DrawMeshInstancedIndirect. I'm unclear on how/if it would work with Shader Graph. Its not apparent how I'd access something like unity_InstanceID from a Shader Graph. I guess I don't really know how you'd read from a StructuredBuffer inside a ShaderGraph either! I don't see an option for it in the Blackboard section.

    Maybe doing instanced rendering that relies on a StructuredBuffer for each instances info would be more of a job for Visual Effect Graph?

    I'm just trying to wrap my head around how this would work with LWRP. Any insight appreciated!
     
    foxnne likes this.
  2. thomh_unity

    thomh_unity

    Unity Technologies

    Joined:
    Feb 19, 2019
    Posts:
    8
    Hello Aaron-Meyers,

    DrawMeshInstancedIndirect is not currently supported in Shader Graph.

    This feature is on the road-map but not yet planned.
     
  3. edan_unity

    edan_unity

    Joined:
    Sep 20, 2017
    Posts:
    1
    Ya I am having the similar issue as well. At the moment I had to flatten the instances if I want to use shader graph rather than copy-and-pasting the whole big chunk of shader code from github. It will be great if there is a way to "hack" around through some custom functions.
     
  4. Aaron-Meyers

    Aaron-Meyers

    Joined:
    Dec 8, 2009
    Posts:
    164
    Thanks for clarifying that. So in the meantime, is Visual Effect Graph a viable option?

    To get more specific, I have been working on a lot of projects visualizing point cloud data and I use DrawMeshInstancedIndirect to draw meshes (usually cubes) at each point contained in a packed buffer for each frame.

    I haven't really dug into VEG yet, but the examples I've seen seem to suggest that StructuredBuffers containing custom structs are supported, but that's just my intuition. Can you confirm if drawing hundred of thousands of cubes from such a buffer in one draw call would be possible using VEG?
     
  5. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    143
    It's possible to do something along these lines using Texture2D and Texture3D as your buffers. Check out Keijiro's stuff using the VFX Graph on Github.