# drawing order of translucent objects

If the object made up of a lot facets is translucent and it is always rotating, is there an easy way to determine the correct order of drawing the facets? Thanks.

If it is convex, using back-face culling will do the trick. In all other cases you are mostly screwed (ie. no, there is no “easy” way, all methods i know are more in the range of “extremely complicated and/or slow”).

Jan.

Jan, can you elaborate on some of the “extremely complicated” methods? Are you talking about techniques like depth peeling? Recently, I’ve been brainstorming ideas to optimize the simple solution of using std::sort for far to near sorting. At the least a sort that exploits frame-to-frame coherence can be used. Or perhaps a bucket sort if your willing to lose some precision.

Thanks,
Patrick

method 1) depth-peeling. Is reported to be very slow, understandably
method 2) manually sort (precisely) by transformed z.
method 3) rough bucket-sort. AKA “Ordering Table”. Used in PSX (as there is no z-buffer). Specify i.e 200 z-ranges:

``````
Triangle* OTable[200];
// z in OTable[23] = [0.1213;0.1433)
// z in OTable[24] = [0.1433;0.1653)
struct Triangle{
Triangle* pNext; // it's a linked-list
vec3 p0,p1,p2; // transformed position
vec2 st0,st1,st2; // texture-coordinate
};

Triangle HeapSoup[100000]; // place to quickly allocate triangles from.
This can/does handle a full-scene, instead of just a single object.

``````

method 4) pre-sort triangles of an object from 4 view-positions. Instead of having “int indices[1000]”, you have “int indices[4][1000]”, while the vertex-data stays the same. This is useful if you’ll be mostly seeing the object rotated only along Y-axis.

method 5) available only if objects are alpha-tested and have smooth edges (grass, tree-leaves): first render with alphatest, then with blending. Without sorting, good results (although rarely correct) can be achieved.

My favorite is the ordering-table, it can handle whole scene, can be tuned for precision or speed, can be made to interleave shaders/blending-modes, can add several interleaved stages of rough refraction.

I agree that the ordering-table provides a lot of flexibility. I suppose the buckets themselves can even have non-uniform depth.

Pre-sorting isn’t going to work for a lot of use cases I am interested in where the vertex data changes every frame (e.g. smoke and fire).

Thanks,
Patrick