Question: How to perform a cutoff / intersect / occlude / stencil cut of some parts of objects (that are not “visible” due to being rendered over by other objects)?
I am trying to write normal information for a set of objects (that belong to a specific layer) into a texture, that I can then use for future post processing calculations. This is done using a ScriptableRenderPass.
This is a simplified example. There will be many ground objects etc.
It feels like this should be a common scenario and that the framework should support these kind of things (even if it means rendering the entire screen again).
For example, could I somehow perform a ZTest in my shader graph, comparing the vertex positions with the camera depth texture and simply color them black?
Thanks for the reply. I glanced at that video before, but doesn’t feel like a render feature will solve it for me, as I need to write this to a texture.
Thanks a lot! I tried using the RenderStateBlock before in my attempts, but never passed a long the cameraDepthTargetHandle for my render target.
In addition to this, the normal DrawRenderers simply didn’t work for me.
I reverse engineered the Render Feature functionality and used the RenderingUtils.DrawRendererListWithRenderStateBlock that Unity use internally instead (source). This worked.
Well, celebrated a bit too early.
Turns out I get the reverse problem instead when I have a large object that I need the normals for, while some smaller object happens to be on top of it. From what I can tell, my effect is simply not worth doing in post processing.