Rendering a transparent MRI

Hi,

I need to render MRI data with transparency. I can do it efficiently by instancing cubes. Opaque rendering works great so far.

My question is: for transparency to work, will it indeed work if I just enable GL blending (GL_BLEND)?

eg.

glBlend(GL_BLEND)
glBlendFunc(GL_SRC_ALPHA, GL_ONE)

I know the GPU will process triangles in random/arbitrary order - I know I can’t control the order.

I saw there are techniques around using order-independent transparency (OIT), using sophisticated shaders, but I would like to know if GL blending is supposed to work in the first place.

I mean, why would it not work? Every time a cube is rendered, some color intensity (say 0.01f) will be added to the color buffer. And voilà. Why would rendering order be important? I guess order is only important when dealing with objects using different colors? (as per example shown on Wikipedia page for OIT)

I would greatly appreciate your insight,
F

Order doesn’t matter for that particular combination of source and destination factors (i.e. additive blending). You’re just adding all the fragment colours together (each scaled by its own alpha), and addition is associative.

It matters in the (more common) case of translucent surfaces, where the surface colour is supposed to modulate everything behind the surface without affecting anything in front of it. The destination factor affects anything written before the current fragment and nothing after it, so the colour of each fragment gets multiplied by the destination factor of every subsequent fragment written to the same pixel. If the destination factor is one, this is a no-op; if it’s anything else, earlier fragments get scaled down more than later fragments.