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:
I’ve set the quad output node’s Z Write Mode to on and it’s set to opaque as well:
I’ve set up a custom forward renderer config with the blit pass happening before post processing:
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!
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:
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?
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.