Depth banding problem

Hi,

I’m trying to use depth in unity for an SSAO effect I’m making.

I’m using the _CameraDepthNormalsTexture sampler and decode it like this :

float4 DepthNormal = tex2D( _CameraDepthNormalsTexture, screenPos );
float3 norm;
float SceneDepth;
DecodeDepthNormal(DepthNormal, SceneDepth, norm);

But this give me this result :

As you can see there’s a lot of banding and this is causing this in my SSAO :

Am I doing something wrong ? Any of you experienced that problem ?

Thank you for your help !

Hi Charkes

I can’t see your pictures but I’m also stuck on an AO problem having to do with a very chunky _CameraDepthNormalsTexture.

First, your code is right, insofar as it’s exactly what Unity recommends to reconstruct depth and normals from this texture.

I’ve noticed that _CameraDepthNormalsTexture is a lot chunkier than _CameraDepthTexture (what you get in DepthTextureMode.Depth mode). This is because the DepthNormals texture stores depth linearly, whereas Depth does so non-linearly, like a real hardware depth buffer.

This picture illustrates the pain I am suffering. Like you _CameraDepthNormalsTexture is causing bad banding problems with an AO technique.