Transparent Objects

Started by
22 comments, last by GameDev.net 18 years, 6 months ago
Quote:you can sort the opaque objects along with the transparent ones; if not, you have to render them all before the transparent ones.


Sneftel means: Option 1: Sort all objects (opaque + transparent) and render them back-to-front (Technically correct, but sorting opaque objects is not necessary, see Option 2). Option 2: First, Render all opaque objects, Second, sort all transparent objects, Third, render all (sorted) transparent object back-to-front. Option 3: Use depth peeling (doesn't require sorting, but requires multiple-pass).

Thanks Sneftel. One more question about sorting faces: Assuming no two faces intersect, sort all the faces based on the average positions of each face's vertices. Is this algorithm correct?
Advertisement
Yep, that'll work.
Great, thank you Sneftel. Time to start working now! I also took the time to search the literature (again) and was astonished to find that I didn't know about this wonderful Radix Sort (http://codercorner.com/RadixSortRevisited.htm). I probably won't try depth peeling (don't know vertex/fragment program yet) for now.
Save some fill rate by rendering opaque stuff front-to-back with z-test enabled.
Quote:Original post by mossmoss
Save some fill rate by rendering opaque stuff front-to-back with z-test enabled.


Thanks mossmoss. I know I would need to render opaque stuff with z-test enabled, but would front-to-back be better than simply putting everything into the pipeline? I would need to sort them then.
Quote:Original post by xinvar
Quote:Original post by mossmoss
Save some fill rate by rendering opaque stuff front-to-back with z-test enabled.


Thanks mossmoss. I know I would need to render opaque stuff with z-test enabled, but would front-to-back be better than simply putting everything into the pipeline? I would need to sort them then.


No, you don't need to sort them, z-buffer would take care of it.
The idea -- in my slightly obtuse way of explaining -- was that if you're going to sort translucents back-to-front for rendering purposes, make sure to sort ONLY translucent objects. Back-to-front is worst case for overdraw if using the z-buffer, so don't sort opaque back-to-front. Either sort them front-to-back or not at all (so they're in a "random" order).
I see. Thank you!
Quote:No, you don't need to sort them, z-buffer would take care of it.
u contradict what u said earlier, what u mentioned first is correct
sort the opaque meshes in front to back order (from my testing in my game this gives about 1% increase in FPS (millage will vary of course) so its up to u if its worth it)
Thank you, zedzeek. I would sort the transparent objects only.
Quote:
sort the opaque meshes in front to back order (from my testing in my game this gives about 1% increase in FPS (millage will vary of course) so its up to u if its worth it)


xinvar, just to elaborate with regards to performance with sorting opaque meshes front-to-back.

There are several situations here:
1.) you are CPU bound. Sorting anything will aggravate the situation.
2.) you are vertex/memory bandwidth-bound: sorting will have no effect.
3.) you are fill-rate bound (in the case of complex shaders). Sorting front-to-back of your opaque objects will allow early-out in the z test per-pixel which improves performance. If you have a complex scene it may be worth doing a quick z only pass of your opaque objects before rendering your opaque objects.

So, the sorting front-to-back is only good advice if you're fill rate bound on the GPUs that you're targetting.
do unto others... and then run like hell.

This topic is closed to new replies.

Advertisement