HDRP Post-process : Depth OK in the scene view but black in game view

Hi all,

I created a custom Post-process in HDRP 7.1.2 (on the 2019.3.b6), using the tools Create → Shader/HDRP/PostProcess, and the definition script with Create → Rendering/C#PostprocessingVolume.

I managed to get everything working good in the scene view, but I have an issue with the game view.

I removed almost everything and it seems the Depth is in cause.
I set my shader code as this:

float4 CustomPostProcess(Varyings input) : SV_Target
{    
        float depth = LoadCameraDepth(input.positionCS.xy);    
        return depth;
}

It is working as expected in the Scene view, I can see my objects going from white to black the further they are.

However, in the Game view, everything is black. I tried to make some operations on the Depth value, but without success, as if it were always 0 in game.

Did I miss something on the Camera ?

Hello,

I tried to repro on my side but i’m getting expected results for the depth, can you make a repro project so we can have a look ?

Hello,

Thanks for your answer.

I tried on a fresh new project, and it works as it should.
My current project comes from 2018.3 (built-in deferred) and we are evaluating the risks and costs of moving to HDRP.
Things are running smoothly, the only issue so far is the camera Depth.

I removed the post processing stack before installing HDRP, but there was a lot of stuff around like Amplify SE, which I removed afterwards.

I will continue to search and use the frame debugger, there may be something somewhere that clear the depth.

Strange thing is the HDRP Depth of Field is working fine, and I suppose it is also based on camera Depth which is really intriguing.

My bad, I made something wrong in my shader and that was causing the issue.

My scene is quite large and therefore the depth appeared black because of this.

In 2018.3, I was using this trick and it worked fine:

depth = depth * _ProjectionParams.z;

However in 2019.3 HDRP the results are not the same at all. I tried the LinearEyeDepth function instead and now everything is ok:

float depth = LinearEyeDepth(depthCamera, _ZBufferParams);

Having access to all the built-in post process code is awesome and very helpful!

Glad you found your issue :slight_smile: