My app has z-buffer problem when I’m running in 16bit color depth. But, when I run my app in 32bit color depth, I don’t have any z-buffer problem? It looks like when I run in 16bit color, I get a 16bit Depth buffer and when I run in 32bit color, I get a 32bit Depth buffer. Is it possible? I must run my app in 16bit color because its much faster, but I must have 32bit Depth buffer to stop z-buffer artifacts.
Actually, the GeForce uses a 24 bit Z-Buffer and 8 bit stencil when in 32 bit color mode, and a 16 bit Z-Buffer when in 16 bit color mode.
Try to make your near frustum culling plane farther from the camera, and your far frustum culling plane nearer. This will help with Z-Buffer accuracy.
No currently shipping NVIDIA hardware supports a Z24/S8 mode in 16-bit color. Only the GF2 MX supports 32-bit color w/ 16-bit Z.
I would suggest that you reevaluate your need for a 24-bit depth buffer…
Here is my problem. My app is an out-of-cockpit view for a flight simulator. When your up in the air, you see very far away so I need a hudge far clipping plane and I also need a relatively small near clipping plane because when the aircraft take-off, you must see the runways and the details around the airports. The problem is when your in the air and look at the airport (or any town), the buildings flashes (z-buffer fithing)with each other and them self (the roof with the wall of the building). How can I use a 16bit Depth buffer without having any Z-buffer fighting on my 3D world. Any suggestions.
Maybe adjust your front and rear clip planes depending on how close you are to something.
For example, if you are cruising at 30,000 feet, you won’t need that close of a near clip plane, so put it out at about 10 - 20 units or so, and have the far clip plane at 10000.
When you are close to the ground, you won’t need to see as far, so bring the far clip plane in to about 1000 units and the near clip plane to 1 or 2.
Or you could sort your world into “close” objects and “far” objects. Render the far ones first with the clip planes set so you don’t get z-fighting. Then clear the depth buffer, reset the clip planes, and draw the near objects.
You may even be able to do all your Z sorting yourself.
How can I do all the Z-sorting myself? I have a lot of objects, some are static (airports, buildings, town, …) and some are dynamics (moving targets like truck, train, tank, airplanes, …).
With a fast sorting algorithm such as quicksort it shouldn’t be much of a speed problem, but it could still be quite complex considering that sort for the distance to the center of the object may not always work.
If most objects are static you should consider using a BSPTree.
Or maybe an octree.