3
\$\begingroup\$

This question already has an answer here:

Let's assume we have some arbitrary triangle manifold meshes which are transparent.

How real guys effectively render it?

Is it possible todo it without sorting faces back to front (e.g. via bsp) and then render it with blending?

\$\endgroup\$

marked as duplicate by msell, Lars Viklund, DMGregory, Community Nov 16 '15 at 17:05

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

6
\$\begingroup\$

Yes, it's possible. The general idea is called order independent transparency (OIT).

OIT often relies on some form of sorting still (you in fact must having some form of sorting for certain types of blending!) but pushes the work out into the GPU, perhaps sorting per-pixel rather than per-face.

The more advanced and actually feasible forms of OIT require relatively modern hardware to pull off, though. Features like GPU atomics are required.

There's also techniques like weighted, blended order independent transparency and a few others.

\$\endgroup\$
  • \$\begingroup\$ The article mentions them, but keywords to look up are "a-buffer" and "k-buffer". Old slides, but these can help to visualize the algorithm for a-bufers: slideshare.net/hgruen/… (I can't remember if there was a faster implementation, but that's the basic algorithm). \$\endgroup\$ – Sirisian Nov 14 '15 at 3:09
  • \$\begingroup\$ thanks for link (I'm more intersting in GL, but thanks) and for "a-buffer" hint word \$\endgroup\$ – bruziuz Nov 14 '15 at 10:27
  • \$\begingroup\$ I realized that this concept is a bit trickier, I heard about deep peeling couple years ago but didn't implement it never in terms in GL api....A long times ago approx. in 2000 I heard about theoretical z-buffer modification to store this tuples per pixel (color, alpha, z, ptrToNextTuple). Nowadays it seems that this OIT technics are workaround to implemented such thing "artificially" via limited graphics api. \$\endgroup\$ – bruziuz Nov 14 '15 at 10:28
  • \$\begingroup\$ Yes, these methods are tricky. Also, since this isn't clear usually, really modern hardware (maxwell GPUs) can use rasterizer order views. msdn.microsoft.com/en-us/library/windows/desktop/… Not sure what the OpenGL technique is or if it exists yet. Also OpenGL a-buffer can be found here: blog.icare3d.org/2010/07/… you probably already found it through google. Should run rather fast on modern hardware. I should also point out that you can use a-buffers/k-buffers to render volumetric objects. \$\endgroup\$ – Sirisian Nov 16 '15 at 17:26
  • \$\begingroup\$ You can essentially store the depth values and whether a face is a front or backface then use a lambert opacity algorithm to blend the volumes. There are tons of tricks along similar concepts as you research. Just need to be careful with fillrate obviously. \$\endgroup\$ – Sirisian Nov 16 '15 at 17:31
1
\$\begingroup\$

There are also some kinds of transparency which can be done without any sorting at all (even at the per-pixel level)!

In these two cases you still need to draw the transparent items last, but any order will product the same result:

  1. Using blend-mode "multiply" -- this would simulate materials that are perfectly transparent but reduce the amount of light which passes through them, like colored glass with no refraction.
  2. Using blend-mode "add" -- this doesn't correspond to any actual physical materials, but makes a sort of layered, glowing effect.
\$\endgroup\$
  • 1
    \$\begingroup\$ Ok. So if we "model transparency" via blending. if blending operation is commutative and associative then there is no reason to sort anything. \$\endgroup\$ – bruziuz Nov 14 '15 at 10:47
  • 1
    \$\begingroup\$ For me "add", "multiply", "alpha"-based blending of src and dst fragment -- they all are for illustration purposes. In our world (at least at level of electromagnetism) when wave hit the obstacle it's behavior depend on "angle of attack" the surface and "refracted angle" and this dependence is not linear (I believe it was derived in any Physics course of electromagnetism) \$\endgroup\$ – bruziuz Nov 14 '15 at 11:14
  • \$\begingroup\$ Exactly, add and mul are commutative, so order won't affect them. I like what you say about "illustration", everything we do on the computer is less real -- or rather, different -- than real. The art is in choosing an approximation suitable for our needs... \$\endgroup\$ – david van brink Nov 14 '15 at 18:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.