Early-Z

Started by
2 comments, last by coderchris 16 years, 5 months ago
Hello, I'm wondering what exactly are the conditions on modern GPUs (e.g. GeForce 8800) for early-Z to be enabled. All I found on the web are some hints that something has been improved... It seems to me early-Z gets disabled when you're discarding fragments or modifying depth on pixel shader, but, are there some other conditions as well? What I'd need to do is to "carve out" parts of triangles, i.e., make certain fragments invisible/transparent (in order to render nice silhouettes), but still retain early-Z, as my pixel shader will be rather heavy. Deferred shading is of no help as the actual shading is trivial (the problem is in the carving -- it's something like relief mapping, but that's not important here I guess). Any suggestions?
Advertisement
Quote:Original post by ladzin
It seems to me early-Z gets disabled when you're discarding fragments or modifying depth on pixel shader

More the latter than the former. Good info here. BTW, alpha testing certainly won't disable early Z culling, and it sounds like that's what you're trying to do.
Be sure to distinguish early-z from z-cull. Z-cull on Geforce 6, 7 and 8 is done on blocks of fragments after the coarse raster, and has the biggest performance impact. The only way to disable it is to write to depth in your pixel shader. Alpha tested (or texkill) fragments are culled no problem, the problem with them is that they stretch out the zcull near and far boundaries for each block (if z-writes are on), making subsequent zcull less efficient. On Geforce 8's there is also what Nvidia calls early-z, which is a per-pixel depth test BEFORE the pixel shader. Depth writes, alpha test and texkill all disable early-z and it happens after the pixel shader.
regarding both early-z and z-cull; what happens if you do a depth pre-pass (as in something like crysis does; render only the depth to a depth buffer and also write the depth to a render target)?

Would doing a depth pre-pass allow you to safely use texkill, alpha testing, ect, in the color pass (with depth writing disabled) without disabling early z and z cull?

This topic is closed to new replies.

Advertisement