z-buffering VS no z-buffering - that is the question

Started by
4 comments, last by GekkoCube 22 years, 1 month ago
This question might seem stupid, and it probably is. But I was just wondering.... right now my terrain engine uses z-buffering. is there anything that would require the disabling of z-writing? such as water, skybox,...etc? ~ I am a DirectX to OpenGL convert! ~
Advertisement
Usually you disable z buffering to render the user interface on top of everything else.
you also disable writting to the z-buffer when you''re doing transparent effects... first you draw everything thats solid with z-buffer writing/check enabled..... then you disable z-buffer writing.... but keep z-buffer checking on .... and draw all your transparent effects... water... glass... particles ... etc.... that way... you disable z-buffer writting... so that if multiple transparent effects overlap... one doesn''t obscure the other.... but you keep z-buffer checking enabled ... so that solid objects that were previously drawn still obscure transparent objects that are behind them. Hope that helps
-----BEGIN PGP SIGNATURE-----iQA/AwUBOwgpXBtK1gxlCl8XEQIZDACeOhJi6KLEz+rHAI4PiXt9Nw/qFswAoPigEJoSGWopzBZ6V2H1zLECKT8T=CImp-----END PGP SIGNATURE-----
Does anyone know what parts of z-buffer usage are the slowest. Obviously turning on the z-buffer is going to slow you down, but is this due mostly to z-checking or z-writing? The reason I ask is that for the main part of my scene, a cylindrical tunnel, I know that if I draw the segments in reverse I could turn off z-checking and still get the right image drawn. However, I would still need to write to the z-buffer to stop geometry drawn later from showing up where it shouldn''t. There is also the problem that from what I can see D3D doesn''t let you have z-checking off with z-writing on. I haven''t looked if GL lets you yet.

Thanks for any thoughts.

Cameron
quote:Original post by kamrann
Does anyone know what parts of z-buffer usage are the slowest. Obviously turning on the z-buffer is going to slow you down, but is this due mostly to z-checking or z-writing? The reason I ask is that for the main part of my scene, a cylindrical tunnel, I know that if I draw the segments in reverse I could turn off z-checking and still get the right image drawn. However, I would still need to write to the z-buffer to stop geometry drawn later from showing up where it shouldn't. There is also the problem that from what I can see D3D doesn't let you have z-checking off with z-writing on. I haven't looked if GL lets you yet.


I don't think you can turn off checking but leave writing on - that would almost certainly result in either a completely pointless Z buffer, or very weird results.

Most graphics cards will have some sort of early exit path from their Z buffering algorithms - if you can draw your scene front to back, then you will get better performance than if you draw randomly (or back to front)



Edited by - Sandman on February 27, 2002 7:44:27 AM
Front to back sorting is in general the most effective, because of the early Z test in at least TNT GeForce cards.

Disabeling Z writes could be quite effektive, on sorted geometry. Terrains should be ok for this.

Z-Buffer writes is possible to disable in OpenGL by calling.

glDepthMask( GL_FALSE );

Use Alpha test to render totally transperant pixels (alpha == 0), in a cheap way.

Sort all geoemetry with 0.0 < alpha > 1.0. This is the only way to get things right. Sort all objects back to front.

Per object, you hvae to render two times: Render two passes to get front face and backface polygons in an object correct. This is correct

This fails when objects intersect. Cass Everitt @ NVIDIA did an demo on how this right.

--
VK

This topic is closed to new replies.

Advertisement