DirectX Glitchy Graphics

Started by
2 comments, last by adt7 14 years, 2 months ago
Hello all. So, I've been working on a 3d pong clone in DirectX 10, and I've been battling a mean glitch. For some reason, anything that intersects with anything else seems to overlap in seemingly random places. If you look at the linked screen shot below, there is a jagged pattern to the quad walls where they overlap, but the ball that is in the cube is seemingly completely random. I noticed it overlaps less when the objects are closer to the camera, and gets awful when they are far away. I can post any code requested, but I have no idea where to start. Here is a screen capture from the game. http://mynameismatt.net/wp-content/uploads/2010/02/glitch.jpg Also, here is my Depth Buffer: depthStencilDesc.Width = 1024; depthStencilDesc.Height = 768 depthStencilDesc.MipLevels = 1; depthStencilDesc.ArraySize = 1; depthStencilDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; depthStencilDesc.SampleDesc.Count = 1; depthStencilDesc.SampleDesc.Quality = 0; depthStencilDesc.Usage = D3D10_USAGE_DEFAULT; depthStencilDesc.BindFlags = D3D10_BIND_DEPTH_STENCIL; depthStencilDesc.CPUAccessFlags = 0; depthStencilDesc.MiscFlags = 0; And I am sure to clear it each time. Not sure if that's relevant.
Advertisement
What parameters are you using for your projection matrix? You'll want to make your near and far planes as close as you possibly can.
Well, it was
Z-Near: 0.0001f;
& Z-Far: 1000.0f;

So, I changed it to 0.1f & 100.0f. That cleared it up immediately.
Thank you very much!! I didn't know that had anything to do with it.

I very very much appreciate it.
The problem you were having is commonly known as z-fighting. It's caused by a lack of precision in the depth buffer, which is generally a symptom of your near/far range being too far apart, as MJP has already pointed out.

This topic is closed to new replies.

Advertisement