Jump to content
  • Advertisement
Sign in to follow this  
roos

Is it ok to require 24 bit Depth buffer?

This topic is 5129 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

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

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
if you enable w-buffer you could stick to 16bits (floating point) depth buffer, check the caps of the current hardware

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!