Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Graphics.DrawProcedural + Surface shader = reflection probes don't work. please help

Discussion in 'Shaders' started by vladstorm_, Jul 24, 2017.

  1. vladstorm_

    vladstorm_

    Joined:
    Nov 26, 2013
    Posts:
    184
    Hi,

    I use compute shaders to generate geometry.
    I use Graphics.DrawProcedural to render geometry.

    Code (CSharp):
    1. material.SetPass(0);
    2. Graphics.DrawProcedural(MeshTopology.Triangles, _count, 1)
    then i wrote my Surface shader to render surface of the geometry. It works but it doesn't get the current reflection probe! It should work automatically coz its a surface shader.
    How can I force it to use the current reflection probe?

    P/s I'm turning off Mesh Renderer on the game object because it renders other things anyways.
     
  2. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    I've been really struggling with this recently, and I cannot make shadows/environment lighting work either. Do you have an example to share?

    Basically, if there was an example somewhere of using StructuredBuffers of vertices, normals, uvs, etc.... in a surface shader to draw properly lit/shaded geometry drawn with Graphics.DrawProcedural, it would save my life
     
    Last edited: Oct 30, 2017
  3. Przemyslaw_Zaworski

    Przemyslaw_Zaworski

    Joined:
    Jun 9, 2017
    Posts:
    327
    Some clues:
    procedural meshes (function Graphics.DrawMeshInstancedIndirect ) with surface shader:
    Code (CSharp):
    1. https://github.com/keijiro/NoiseBall2
    simple Graphics.DrawProcedural example:
    Code (CSharp):
    1. https://forum.unity.com/threads/commandbuffer-drawprocedural-examples.417733/
    My simple examples of using compute shaders (codes included in movies descriptions):

     
    kosowski likes this.
  4. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
  5. icormier

    icormier

    Joined:
    Aug 26, 2021
    Posts:
    16
    @Luckymouse Any luck on this one. I have having the same issue in 2020.3