Bojo
Bojo

Reputation: 313

XNA: Textures close to each other in 3D are clipping

I'm drawing two quads that are positioned almost concurrent with one another. The only difference being one is higher vertically than the other.

When the camera is close to the quads, everything draws fine.

However, if I am further away, it appears as if the graphics are fighting with one another to see who can draw first. The graphic kind of shows what's going on.

The floor, black, is fighting with the ice texture. It results in drawing random lines when the camera zooms and rotates from a far distance.

The Black Lines aren't supposed to be there

What steps do I need to do to show the graphics correctly?

Upvotes: 0

Views: 231

Answers (1)

comingstorm
comingstorm

Reputation: 26117

This kind of thing is caused by resolution limits in the depth value. There are a few things you can do to avoid it:

  • Most likely: your "near" and "far" distances have been set unnecessarily far apart. If the far/near ratio is too large, the depth resolution near the far clipping plane will be bad. If a fixed set of near/far planes can't handle all possible camera views, you might look into adjusting them dynamically based on the position of your camera, or the visible objects in your scene.
  • The obvious: try increasing the separation of your objects. Sometimes the problem is that the surfaces have simply been specified too close together.
  • Cheat: you can add a depth bias to tweak problem objects. This is hacky and fragile, but it sometimes works. In your case, I'd guess that the floor is supposed to be farther down than anything else -- so if you don't want to actually move it down, you can add a depth bias instead.
  • As a last resort: If none of the above adjustments is possible, you may need to increase the resolution of your depth buffer. I don't know exactly what XNA exposes in this respect, so I'll just mention it as a possibility.

Upvotes: 2

Related Questions