View Full Version : speeding up depth testing
10-03-2003, 07:54 PM
i was wondering would it be fast to sort my polys and draw them furthest to nearest with depth buffer dissabled than to just draw them in any order with depth testing on?
10-03-2003, 10:58 PM
Sure it would be faster. I mean it would be faster if your sorting algoritm is good enough. Quicksort should be just fine. You can always make some experiments, you know. It isn't much of work, really. http://www.opengl.org/discussion_boards/ubb/smile.gif
10-04-2003, 02:33 AM
Good idea, going to implement that in my engine ...
10-04-2003, 08:04 AM
Stop spreading misinformation. Sorting individual polygons and disabling the depth buffer will have artifacts and it will be slower on any hardware that is newer than say 4 years old.
Sort your objects (NOT individual triangles) and render in rough FRONT TO BACK (NOT back to front as suggested) order for some bandwidth saving on newer cards.
In general if your program needs to spend cpu time for figuring out whether to render say 100 triangles or less, it's not worth it. Just rendering them will be faster. There are some exceptions to this, like if all triangles cover the entire screen and you're fill rate bound, but in general it's good advice.
Yeah, drawing things in back-to-front order is one of the worst things you can do - you generate a huge amount of overdraw from all the pixels that later get obscured. Sort your polygons in front-to-back order and render with depth-testing. The sort doesn't need to be exact, but the better sorted your polygons are, the fewer unnecessary pixels get rendered.
The depth buffer is very, very efficient. It would be foolish not to take advantage of it!
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.