by the Codermind team. |
Question
«I've heard people talk of order-independent transparency when talking of rendering alpha blended objects. What does that mean and why is it important in computer graphics ?»
Answer
Order independent transparency or OIT in computer graphics denotes any technique that allows to render overlapping semi-transparent objects without having to sort them before they are being rendered.
In a rasterizer, objects that are drawn in such a way that they let some of the background appear through them typically need sorting at the pixel level from back object to front object. This is called the painter algorithm as each new paint layer obscures a little bit of the combination of all previous paint layers.
Though this is typically achieved by a coarse or fine grained sorting of elements by depth value, some algorithms allow those objects to be rendered without any pre-sorting on the CPU. Sorting could be achieved at a later time, or not at all if the correctness of the display is ensured by another mean.
Sorting objects before they are rendered can lead to many issues. One of the issue is that sometimes a correct order doesn't exist, which would be the case if object overlap each other in a worst case scenario (A over B, B over C, C over A). Another problem is that sorting costs CPU time, which can be a problem for a large number of objects. Another related issue is that the front to back order might be suboptimal in term of render state change (a large CPU cost in a modern renderer). It also prevents generation of objects position at a later stage in the pipeline (through procedural generation, displacement), etc.
Candidates for order independent transparency solutions include :
* storage of samples in an accumulation buffer to be sorted at a later time. Stencil routed A Buffer is a modern example of such use of the accumulation buffer.
* depth peeling, where the scene has to be rerendered n times with n being the overdraw. Some acceleration techniques exist.
* screen door transparency, If you've heard of alpha to coverage that's a common use of screen door transparency (where alpha is used as a coverage information of individual samples instead of being used to compute alpha blending).
Note : OIT typically is not an issue with ray tracing, as a ray would typically have its first intersection and then a decision would have to be made on where to send the ray for intersection next. Sorting will naturally occur at the ray level (but some optimization could resort to coarse pre-sorting which would help opaque and transparent geometry alike).
You should also note that all form of alpha blending do not require sorting of fragments. Any form that is purely commutative such as additive (src + dest) or multiplicative (src * dst) do not require sorting as any order will trigger the same result. But one of the typical form of alpha blending (srcalpha * srccolor + (1-srcalpha) * dstcolor) is not a commutative operation and so requires sorting.
Also sometimes a rough order can be sufficient if the commutation of two terms of the equation is not likely to result in a big change in visual appearance. You should disable depth-writing though, because depth-writing/testing is relying on the fact that you have the exact pixel order right : if A is behind B and A is drawn after B and if the ZBuffer contains the depth of B then A will not be drawn. You probably still need Z-testing so that the transparent triangles correctly intersect with the totally opaque objects.




