Game Development Community

Z-Fighting

by Shayne Gelo · in Torque Game Engine Advanced · 01/30/2006 (2:59 pm) · 1 replies

I'm working with a simulation of a very large (100+ miles) geo-specific terrain. One of the problems I've run into is z-fighting when objects are placed close to the terrain surface and viewed from a distance. I have a couple thoughts on how to approach this, but any feedback would be very helpful as I'm running up against a deadline.

Use 32-bit Z-buffer

This seems a simple solution, but it doesn't seem to work, at least on my card (Radeon X600). When setting up the AutoDepthStencilFormat in gfxD3DDevice.cpp, TSE currently uses D3DFMT_D24S8 (24 bits for Z, 8 bits for stencil). I tried changing this to D3DFMT_D32, but CreateDevice fails with D3DERR_NOTAVAILABLE. I can't seem to find any authoritative information about whether this is supported on my card or not. I'd be interested to know if anyone else can get it to work.

Move front clipping plane back

Most of our objects are reasonably far away, so this is a definite option. Ideally, it would be nice to be able to adjust both clipping planes on the fly. If someone could just point me towards the appropriate place in the code, that would be really helpful.

Change scale

I would assume that the units are already scaled before the Z-buffer processing. However, if they're not, it might help to make the scale of the world smaller. Any feedback about whether this might help would be great.

In summary:

1. Is using 32-bit z-buffers possible (reasonable)?

2. What do I need to do to move the clipping planes around?

3. Would it help to change the scale of my simulation?

4. Any other suggestions?

#1
03/10/2006 (1:42 am)
How about trying a W buffer, it goes something like this:

device->SetRenderState(D3DRS_ZENABLE, D3DZB_USEW);