Sign in to follow this  
~Helgon

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

Recommended Posts

~Helgon    361
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

Share this post


Link to post
Share on other sites
Ashaman73    13715
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 [i]block [/i]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.

Share this post


Link to post
Share on other sites
C0lumbo    4411
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this