Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

LWRP, VFX particles and depth buffer

Discussion in 'Graphics Experimental Previews' started by dr_benway, Jul 8, 2019.

  1. dr_benway

    dr_benway

    Joined:
    Mar 28, 2018
    Posts:
    3
    Hi there!

    I'm doing an experiment to try creating a screen-space fluid shader for VFX graph particles. I'm hoping I can achieve the effect by rendering the particle system and passing the screen through a scriptable render pass that blits it with my shader. The effect relies on using the depth buffer, so I've set up a simple test shader which adds the normalised depth as a red tint. This seems to work fine for regular opaque objects, but it looks like VFX particles are not writing any depth.

    This screenshot shows the particles rendering over the top of some cubes. The particles are fully opaque, so the parts of the cube in the background showing through are just the cube's depth being added as a red tint:

    capture3.PNG
    I've set the quad output node's Z Write Mode to on and it's set to opaque as well:

    capture5.PNG

    I've set up a custom forward renderer config with the blit pass happening before post processing:
    capture4.PNG

    Is there any specific reason that this would be happening or is it just not possible to use the depth info in this way for VFX particles? Is there a better way to do this that I should look into? Any tips or pointers would be much appreciated!
     
  2. dr_benway

    dr_benway

    Joined:
    Mar 28, 2018
    Posts:
    3
    After digging around some more, I've found that the problem seems to be that the depth texture is being generated during the depth pass, and the LWRP quad output shader doesn't define one, so they're not rendered to the depth texture. I modified VFXParticleQuad.template on my machine to include PassDepth.template on line 7 and now the particle depth is coming through correctly:

    withdepth.PNG

    I'm assuming the missing depth pass is intentional though and also making this change properly would require me to fork VFX graph or at least all the LWRP shaders, which I really don't want to do. Does anyone have any thoughts on the right approach here or why this is the case?
     
    fct509, zorbaq and ShiftedClock like this.
  3. fct509

    fct509

    Joined:
    Aug 15, 2018
    Posts:
    111
    I would also like to know this. I was just looking at the Linear 01 Depth of the VFX Heretic Character today, and I ended finding zero depth data.
     
    nasos_333 likes this.
  4. MattDavis

    MattDavis

    Joined:
    Aug 11, 2013
    Posts:
    16
    Looking into this in 2022.1, it seems like VFX particles now generate a depth pass, but not a DepthNormals pass. Meaning that all opaque VFX particles become invisible when using any effect which requires DepthNormals, such as SSAO (Depth Normals mode) and our custom Outline effect.

    Am I mistaken? Does anyone have any info on this?
     
  5. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,521
    I still cant get the depth in Unity 2022.3.18, no matter what i tried