View Full Version : a simple question about shading and hidden surface removal
06-15-2004, 10:13 PM
Hi, is shading performed before or after for instance a hidden surface removal algorithm such as z-buffering?
06-15-2004, 11:51 PM
Both, and it depends. :)
I should probably elaborate.
AFAIK, In older (fixed function) hardware the shading was done before the z-test, no exceptions. On newer hardware (ones that have fragment shaders) it depends on what the fragment shader program does. Provided the fragment shader program doesn't alter the z value of the fragment the driver/graphics card can optimize this by doing the z test first. If the fragment is obscured it is simply discarded and the resources that would have been required to shade that fragment aren't required. If the fragment program alters the z value then the z-test has to be done after the fragment program is finished.
06-16-2004, 01:56 PM
Hehe, it reminds me about an argument with a teacher who thought that the z test was done before shading/texturing.
In fact having a pre-lighting z-test on the hardware with fixed function is indeed not useful, it would only create bubbles in the pipeline, and have almost no performance gain. It can be useful howerer, with heavy multitexture or anisotropic+trilinear filtering.
With complex fragment shaders of course it can be much more useful.
06-17-2004, 04:18 AM
How does a spearate z-pass create a pipeline bubble?
06-17-2004, 12:56 PM
@harsman: apparently I did not myself very clear. I was talking about the order of the operations in the pipeline. Not about separate rendering passes (I edited my post to improve it a bit).
To the original poster, here are some diagrams explaining fairly well the situation :
http://www.gris.uni-tuebingen.de/~meissner/publications/presentations/eghww98occ/im g024.gif (http://www.gris.uni-tuebingen.de/~meissner/publications/presentations/eghww98occ/img024.gif)
You can see the visibility test is almost the last operation in the general case. The hyper-Z (hz) ati optimisation was recently added to enhance perfs for the cases mentionned above (big FP with no z modification and fixed-path with heavy texture access).
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.