Skip to main content
GameDev.net gamedev.net
🔒 Locked

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

Started by ~Helgon Nov 23, 2012 at 7:36 AM 2 replies 1.9k views
Original Post
~Helgon
~Helgon
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
Ashaman73
Ashaman73
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.
C0lumbo
C0lumbo
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.
~Helgon
~Helgon
Thanks for the awnsers
from time to time i find time

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.