[DX11] Depth-issue for near objects

Started by
1 comment, last by mind in a box 13 years, 7 months ago
Hi,

I am implementing the LightPrePass at the moment into my engine, and now I have problems with rendering close geometry.
Here is a picture which shows the problem, and I think it has something to do with the depth.


Here are the DepthStencil-States I create:
	D3D11_DEPTH_STENCIL_DESC dsDesc;	// Depth test parameters	dsDesc.DepthEnable = true;	dsDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;	dsDesc.DepthFunc = D3D11_COMPARISON_LESS;	// Stencil test parameters	dsDesc.StencilEnable = true;	dsDesc.StencilReadMask = 0xFF;	dsDesc.StencilWriteMask = 0xFF;	// Stencil operations if pixel is front-facing	dsDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;	dsDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR;	dsDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;	dsDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;	// Stencil operations if pixel is back-facing	dsDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;	dsDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR;	dsDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;	dsDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;	// Create depth stencil state	DXUTGetD3D11Device()->CreateDepthStencilState(&dsDesc, &LPP_DepthStencilState);	dsDesc.DepthFunc = D3D11_COMPARISON_EQUAL;	dsDesc.StencilEnable = false;	// Create depth stencil state	DXUTGetD3D11Device()->CreateDepthStencilState(&dsDesc, &Scene_DepthState);


This is how I render them:
DXUTGetD3D11DeviceContext()->OMSetDepthStencilState(LPP_DepthStencilState, 0);	RenderWorld(LPP_DepthStencilState); //Render world	TheScene->Params.SceneInfo.bFirstLightPrePass=false; //Back to normal again	//Render everything which wants to be lighting	LPP_Renderer->PrepareForLightPass();	RenderLighting();		TheScene->Params.SceneInfo.LightBuffer=LPP_Renderer->GetLightBuffer()->ShaderResView;	LPP_Renderer->PrepareForSecondPass(RenderTargetView,DepthStencilView);	//PPInterface.BeginWorldRender();	DXUTGetD3D11DeviceContext()->OMSetDepthStencilState(Scene_DepthState, 0);	RenderWorld(Scene_DepthState); //Render world


The format is DXGI_FORMAT_R32_TYPELESS for the texture, DXGI_FORMAT_D32_FLOAT for the DepthStencilView and DXGI_FORMAT_R32_FLOAT for the ShaderResourceView.

I haven't got such issues before, so I hope I just missed a little thing.
Advertisement
It looks like you incorrectly set the near and far plane. Try setting the near distance to nothing lower then .1 and set the far to a reasonable number nothing massive.

When you have a giant frustum with a near of like . 0001 up to 1000000 it really takes the precision out of depth testing.
When I set it from 1 to 1000 nothing changes...

Edit: One wired thing: The normals of the mesh seem to cause it. Sometimes the walls are unaffected, while the ground right under it are distorted.

This topic is closed to new replies.

Advertisement