Is it ok to require 24 bit Depth buffer?

Started by
6 comments, last by roos 19 years, 4 months ago
Hi, I'm writing a game using DirectX, but I guess this is a general enough question I can post it in this section... I have a race track which is "glued" like a decal on to a terrain, i.e. rendered 0.5 units (feet) above the terrain. The problem is, when you view a portion of the race track which is far away (say, 1000 feet or so), there's some Z-fighting between the terrain and the track. To solve this, I changed to a 24 bit depth buffer (i.e. D3DFMT_D24S8)... So, my question is, does anyone know if this is a reasonable thing to do, considering the game is targeting cards along the lines of Geforce2 and higher? Or, could this seriously mess up compatability? If it is a problem, does anyone know if there's any good way to deal with Z-fighting? I have heard one method is to modify the near clipping plane when rendering the track, so that its Z-values are slightly offset from the terrain. This does help somewhat, but not completely... Thanks a lot! roos
Advertisement
Perhaps you could change the zbias for different pieces of the track depending on how far away they are? It won't affect the screenspace position of the pieces so it won't have discontinuities; it *might* show through the terrain in places you don't want it to, but that depends on your terrain (specifically, I think you'd have to have bunch of thin walls very near a faraway piece of track).

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

Quote:Original post by roos
So, my question is, does anyone know if this is a reasonable thing to do, considering the game is targeting cards along the lines of Geforce2 and higher? Or, could this seriously mess up compatability?


It's a perfectly reasonable thing to do. 24-bit depth buffers are supported on those cards, and even some previous to that generation so I see no problem with compatibility.

Quote:Original post by roos
does anyone know if there's any good way to deal with Z-fighting? I have heard one method is to modify the near clipping plane when rendering the track, so that its Z-values are slightly offset from the terrain. This does help somewhat, but not completely...


Tom Forsyth's DirectX FAQ has a little nugget of information on this, search for "ZBias" and read the entry.

-Mezz
if you enable w-buffer you could stick to 16bits (floating point) depth buffer, check the caps of the current hardware
Ethereal
yes.
As a matter of fact, our next game does and is targetted at GF3+ hw.
16 bit frame buffers werre necessary when people only had 4-16 megs of video memory. There still could be a bandwidth bottleneck, but if write buffer bw is your problem, then you definitely are doing something strange...
Act of War - EugenSystems/Atari
Quote:So, my question is, does anyone know if this is a reasonable thing to do, considering the game is targeting cards along the lines of Geforce2 and higher? Or, could this seriously mess up compatability?
Most graphics engines/games scale according to the hardware. My personal choice would be to enumerate for the best format I can get (might be lucky with D3DFMT_D32 if you're not after stencil bits) and for most cases that'll be acceptable.

In the few chipsets where _D16 is the best you can use, emit a warning of some kind saying that technically it'll work but it might look crap. Therefore you don't cut out any of your "market".

Alternatively, invest some time into ZBiasing - as that should be a much more scalable/robust solution. But for a simple hack, I doubt you can go to far wrong by upping the requirements (or using my idea above).

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

It's safe to require a 24 bit z-buffer but on most GeForce cards you have to use a 32 bit back buffer if you want 24 bit z, you can't use a 16 bit back buffer with 24 bit z. That's not really a big deal - there's no real reason to use 16 bit colour depth these days anyway.

If you still have problems with z-fighting even with 24 bit z or if you want to get it working with 16 bit you can try moving your near clip plane out. Moving the near clip plane further away from the camera greatly increases z precision in the distance. Other options are to play with the DEPTHBIAS / SLOPESCALEDEPTHBIAS render states or use the clip plane trick described in the link to Tom Forsyth's blog.

Game Programming Blog: www.mattnewport.com/blog

Cool, thanks for all your replies! :) I will go ahead and stick with a 24-bit depth buffer, then. That'll also help with other things, i.e. no jagged interface between water surface and land.

This topic is closed to new replies.

Advertisement