Search Unity

Geometry Shader - not visible in Depth Pass

Discussion in 'Shaders' started by Atair, Oct 16, 2017.

  1. Atair

    Atair

    Joined:
    Oct 16, 2015
    Posts:
    42
    Hello,
    I have a simple Point Cloud geometry shader that emits little billboards for each vertex (Meshtopology is Points). Everything works fine, except that the created geometry is not showing up in the depth buffer. (if i interpret this correctly from the frame debugger)

    So image effects like SSAO or DOF don't work. I found some threads that try to deal with shadow casting, which i think is based on the same problem, but it seems there is no clear/easy solution.

    In my case i don't need lights or shadows, but only the geometry to show up in the depth pass (for volumetric effects)

    I hope this is simpler than getting the whole lightning pipeline to work.. any ideas?
    thanks
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    You need a custom shadow caster pass with the same geometry shader. The shadow caster pass is used for generating the depth pass, in addition to the shadow maps.
     
  3. Atair

    Atair

    Joined:
    Oct 16, 2015
    Posts:
    42
    i feared that.. so that means it (more or less) doubles the instruction count? As i have to basically copy paste the whole pass.

    In case of a point cloud shader i read about another technique where i create the billboard mesh upfront, but collapsed into a single point, and use the vertex shader to expand them to billboards.
    Would that be a workaround, and if yes, at lower cost?
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Is that "doubling the instruction count"? Yes, but that's not really the way to think about it. It means it'll be running a version of the shader a second time for the depth. But that has to happen no matter what because that's how you get the depth texture when using the forward rendering path.

    As for using a mesh of a bunch of quads to do the work, that will possibly be faster than a geometry shader. I would just copy over the geometry shader stuff into a custom shadow caster pass first and see how that is.