Hi,
We are faced the same issues in our HDRP FPS game. For preventing wall clipping we are stack to custom passes, because two camera setup are not feathable and custom shaders not solve our problems either.
We are managed to avoid flickering, but there are another problem: ambient occlusion from objects behind passes through first person objects.
First setup for no flickering and no ambient occlusion:
I. Create separate layer for first person objects; exclude it form camera culling mask.
II. Create CustomPassVolume game object with Before Post Process injection point.
III. Inherit DrawRenderersCustomPass and override Execute method:
protected override void Execute(CustomPassContext context)
{
int ambientOcclusionTextureID = Shader.PropertyToID("_AmbientOcclusionTexture");
context.cmd.SetGlobalTexture(ambientOcclusionTextureID , TextureXR.GetBlackTexture());
base.Execute(context);
}
IV. Add this custom pass to previously created CustomPassVolume.
V. Set Filters Layer Mask to first person objects layer.
First setup is ready and working fine, but we don’t want to disable ambient occlusion on our arms and weapons.
Second setup, that should work fine, but it’s don’t:
I. Create separate layer for first person objects; exclude it form camera culling mask.
II. Create CustomPassVolume game object with After Opaque Depth And Normal injection point.
III. Add to it two DrawRenderersCustomPass.
IV. On both passes set Filters Layer Mask to first person objects layer.
V. On first pass set Target Color Buffer to None and Target Depth Buffer to Camera. Check Override Depth and set Depth Test to Always. Enable Write Depth.
VI. On second pass set Target Color Buffer to Camera and Target Depth Buffer to Camera. Check Override Depth and set Depth Test to Less Equal. Enable Write Depth.
This setup should just draw opaque geometry with overrided depth on top of other opaque geometry, but it is has flickering shadows and lighting and also have ambient occlusion on top of first person geometry. Seems to me like a bug, because Ambient Occlusion in HDRP code base calculated after After Opaque Depth And Normal injection point.