Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Can you Graphics.DrawProcedural without a MeshFilter ?

Discussion in 'Shaders' started by vladstorm_, Aug 9, 2017.

  1. vladstorm_

    vladstorm_

    Joined:
    Nov 26, 2013
    Posts:
    184
    Hi unity,

    I just spent a half of a day trying figure out why nothing is shown in the scene when i'm using
    Graphics.DrawProcedural. Then I figured out that I need to add a MeshFilter and create a mesh with the same amount of triangles I'm drawing. I don't understand why I need that.

    I'm generating geometry in a Compute Shader and drawing the geometry from a ComputeBuffer. So all my triangle and vertices data inside the ComputeBuffer. Why do I need to add a MeshFilter with a mesh?
    Is there a way to draw procedural without using a MeshFilter?

    Best,
    Vladimir.
     
  2. grizzly

    grizzly

    Joined:
    Dec 5, 2012
    Posts:
    356
  3. vladstorm_

    vladstorm_

    Joined:
    Nov 26, 2013
    Posts:
    184
    wow / cool / thank you. ill try.
    just wonder how can i get current reflection probes there and texture behind to make refractive shaders. - is it possible to get those textures inside frag/surf pass when you use Graphics.DrawProceduralIndirect ?
     
  4. grizzly

    grizzly

    Joined:
    Dec 5, 2012
    Posts:
    356
    Well, certain Graphics.Draw* methods operate outside of the normal rendering pipeline in what's called "immediate mode" (please see docs). They are not fully integrated with lighting, shadows (depth) and render queues etc... Command Buffers were introduce to allow better integration here and Unity have kindly proved us with similar methods which I recommend having a look into;

    https://docs.unity3d.com/ScriptReference/Rendering.CommandBuffer.DrawProceduralIndirect.html
     
    vladstorm_ likes this.
  5. vladstorm_

    vladstorm_

    Joined:
    Nov 26, 2013
    Posts:
    184
    So, I just tested some scenes and apparently you can use Graphics.DrawProcedural without a MeshFilter and MeshRenderer.