Draw Order Question (Z-Test, Depth-Stencil)

Started by
2 comments, last by ~Helgon 11 years, 5 months ago
Hey, i just have a question.


I've read that if i use the depth-stencil for a mirror i should draw the objects from back to front so that the depth can be checked.

Later i've read that if i want my graphic card to uses the build in z-test(Hardware - don't render if the depthComplexity > 1) i have to draw the objects from front to back (and it can have a significantly impact in performance)


So, whats the right way?

Regards Helgon

from time to time i find time

Advertisement
The right way is to utilze the z-test hardware as much as possible, because videochips are highly optimized in this field. Therefore rendering from front to back have the advantage, that front objects will block back objects quite early (early z-rejection) and this can have a significant performance impact.

Though, as always, there are some exceptions. E.g. alpha blending can't utilize the z-test , therefore alpha blended geometry should be rendered from back to front to avoid visual artifacts.
Just talking about rendering opaque geometry on desktop graphics cards. Rendering front-to-back can improve performance because fragments can be skipped more often when drawing triangles that are occluded by other triangles.

However, you can also improve performance by batching triangles into single draw calls and by drawing 'similar' objects together so as to reduce state changes. This can improve both CPU and GPU performance.

These two goals often conflict with one another. I tend to give greater weight to the second goal, only worrying about the first if I can cheaply and easily do some coarse sorting. Unless I'm in full profiling/optimising mode, then I'll let measurements and experiments tell me what to do.
Thanks for the awnsers

from time to time i find time

This topic is closed to new replies.

Advertisement