Hello,
From what I see, the result is expected because your scriptable render passes rely on a side effect from other cameras.
Here's what I see in RenderDoc:
- First all opaque objects are rendered, including your object in the scene with the ShaderGraph reading the `_TerrainSurfaceDepth` texture.
- Next is the TerrainDepth pass, generating the depth texture `_TerrainSurfaceDepth` by drawing the terrain
- Lastly, transparent objects are rendered.
The problem is that you're reading the `_TerrainSurfaceDepth` texture in ShaderGraph before the TerrainDepth initialize its data correctly, which means that instead it's reading whatever was in the texture before.
What happens with the preview in the inspector is that the TerrainDepth pass clears the _TerrainSurfaceDepth texture and then when the game view / scene view renders, it can only read black hence the flickering between valid and cleared data.
To fix this issue, you can move your scriptable render feature to another injection point before the rendering of opaque objects. For example, "BeforeRenderingOpaques" would work well as the _TerrainSurfaceDepth will be initialized correctly before being used when opaque objects are rendered.