Jump to content
  • Advertisement
Sign in to follow this  
ArthurD

DX11 [DX11] Depth Bug

This topic is 2544 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

I have a bug in the depth of my program that causes a very weird looking glitch.

I made a video of the problem here :

Note that in this video, the model is simply rotating clockwise. However, because the depth is "inverted", it seems to change its rotation a few times.

[media]
[/media]

There are 2 bugs, but I think they are linked to each other :

- The part of the model that is displayed is not the closest one, but the one that is the farthest away instead.
- The model gets bigger as it gets away from the camera instead of becoming smaller.

If I invert the depth DepthFunc, the first problem is solved and it is always the closest polygons that are displayed, but the second problem is still present which makes me think that I didn't solve the bug, just worked around.

The problem is that I do not know exactly where to look for the problem, so I don't know exactly what part of the code to show you.

I thought that I had failed my projection Matrix, but I don't see anything wrong with it :



const float SCREEN_DEPTH = 100000.0f;
const float SCREEN_NEAR = 0.1f;


fieldOfView = (float)D3DX_PI / 4.0f;
screenAspect = (float)screenWidth / (float)screenHeight;

D3DXMatrixPerspectiveFovLH(&m_projectionMatrix, fieldOfView, screenAspect, SCREEN_NEAR , SCREEN_DEPTH );




And here is the depth description :




depthStencilDesc.DepthEnable = true;
depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
depthStencilDesc.DepthFunc = D3D11_COMPARISON_LESS;



Thanks for your time reading this, any help is welcome!

Share this post


Link to post
Share on other sites
Advertisement
Your near and far planes are probably too far to have adequate precision in the depth buffer. Try bringing your far plane back to 1000 or so.

Share this post


Link to post
Share on other sites

- The part of the model that is displayed is not the closest one, but the one that is the farthest away instead.

Looks like the cull mode is wrong. Try to invert it.

Not sure about your other problem. Rather sounds like a bug in your camera/view logic.

Share this post


Link to post
Share on other sites
Thanks unbird! I didn't quite catch that the cull mode was the cause of this bug, it solved it all. Thanks a lot!

And thank you MJP, I had not thought of the problems my far plane could create, I changed it to a more reasonable value.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!