Does anyone have any tips when it comes to drawing translucent objects other than drawing the farthest objects first. Is there any tricks I can use to avoid determining the order of objects each time I need to draw to screen?
well maybe, but it depends on what your rendering, there are many cases where sorting is not needed or can be simplified.
- If you know that no transparent objects will be rendered behind that surface you can just go ahead and render it after opaque objects but before other transparent objects.
- If you know the transparent objects do not intersect and they are mostly convex you sort on a per object basis then draw each object with back facing polygons first then front facing polygons.
- if your rendering fog or dust with a uniform color you can just go ahead and render them without sorting or depthwriting.
- If your transparent objects are structured in separate groups but are concave in nature you can sort every polygon in each group first then sort the groups back to front.
- for some objects (such as various forms of vegetation or smaller details) it’s better to not render transparency but rather discard fragments instead based on the alpha.
with proper post processing you will never notice the difference
There are also more advanced techniques like depth pealing and gpu sorting, but i think it’s better to stick to the basics in the begining.
Either way the more transparent objects there are on the screen the higher the need for sorting is
If you can accept its limitations, “weighted average transparency” is fast and simple.