View Full Version : Architecture questions

07-04-2003, 02:19 AM
In some paper was said, that Doom 3 does at first one pass with color/textures etc. disabled, just to fill the z-buffer for speeding up lighting calculations later.

1. What if i want to do stuff like fences. In this case i have a mask in the alpha-channel, which indicates, whether a texel is visible or not, so that the alpha-test will discard it. But to fill the z-buffer correctly, i will have to have texturing enabled in the first pass, so that alpha-testing works. However nvidia says, that operations like filling the z-buffer are now twice as fast as some time ago. Is this because no colors are written, or is this only true, when texturing is disabled?

2. A lot of diagrams show, that register-combiners and texture-shaders are combuted BEFORE depth and alpha-testing. I know that it is true for the alpha-test (because i can change the alpha-value in a combiner and then the pixel will be discarded). But i wonder why the depth-test should not be BEFORE the register-combiners, because this way a lot of computations could be saved (and in this case doing a z-only pass does make sense).
So is it possible, that the depth-test is done earlier, if reg-comb. are enabled? Or is this not possible on current chips. Or are reg-comb. so fast, that doing those calculations is done in no time, so doing depth-test first wouldnīt save any time?


Eric Lengyel
07-04-2003, 04:23 AM
Even though the OpenGL spec says that the depth test logically follows the computation of the fragment color, an implementation is free to rearrange things if it doesn't affect the output. All modern 3D hardware does indeed perform the depth test before going through register combiners or running a fragment program (unless the texture shaders or a fragment program replaces the depth value).

07-04-2003, 08:38 AM
Yes, if you use alpha cut-out, then you have to enable texturing in your pre-render pass for those objects. You should probably draw them last, so as to get the benefit of fast Z occlusion.

The diagrams say that Z testing happens after fragment colorization. Your fragment program can actually change the depth value of the fragment! However, most modern drivers will detect whether Z is written or not, and if it isn't, run early/fast Z culling and not involve the fragment processing for fragments that will fail the Z test.

07-05-2003, 11:54 PM
Thatīs good news, thanks.