Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17560

[D3D12] Depth Buffer problem (maybe)

$
0
0

Hi, community.

 

I have a bug with Screen Space Ambient Occlusion and I suspect is the depth buffer information I use.

 

Depth Stencil View Format is DXGI_FORMAT_D24_UNORM_S8_UINT

Depth Stencil Shader Resource View Format is DXGI_FORMAT_R24_UNORM_X8_TYPELESS

Then its values should be between [0, 1]

 

I made a test to check if depth buffer is sampled correctly. This is the pixel shader (geometry is a full-screen quad). I disabled depth test.

struct Input {
	float4 mPosH : SV_POSITION;
};

Texture2D<float> DepthTexture : register(t0);

struct Output {
	float4 mColor : SV_Target0;
};

Output main(const in Input input){
	Output output = (Output)0;

	const int3 screenCoord = int3(input.mPosH.xy, 0);
	const float depthNDC = DepthTexture.Load(screenCoord);
	output.mColor = float4(depthNDC, depthNDC, depthNDC, 1.0f);
	
	return output;
}

Near Z is 1.0f

Far Z is 2000.0f

so I expect to get total white (1.0f, 1.0f, 1.0f) when the object is at 2000.0f Z and total black (0.0f, 0.0f, 0.0f) when object is at 1.0f Z

 

I recorded the following video, and if I modify Far Z to something like 500.0f or 5000.0f, I get the same black-white gradient results than the video.

That is why I think something is wrong.

 

https://www.youtube.com/watch?v=J6ZEoElU_Qo

 

Thoughts? Am I missing something?


Viewing all articles
Browse latest Browse all 17560

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>