Shadows when using alpha blending

Hi, I’m new to openGl, but I’ve managed to make an app to load and display medical MRI data. I make a cube for each voxel in the data set and colorize them. I’ve been experimenting with changing the opacity for each cube. I call

glEnable (GL_BLEND);

and then set the opacity for each cube to 0.5. This produces some strange results. On all the cubes in the left half of the screen, there is a dark shadow outlining the cubes from the left. The right half of the screen does not have this shadow and appears “normal”. I have disabled all lights and lightning so I don’t think that’s the problem. However, when I rotate the data set, the shadows appear and disappear depending on the orientation… I think the alpha blending visually looks much better, so it would be very nice to be able to render the data sets with opacity, but without those shadows. Does anyone have an idea of whats going on here?


Transparency does not work with depth testing.
This is obvious when thinking about it, as depth testing only stores the nearest depth.

Simplest fix is to use additive transparency and no depth testing.
You will also need a very low alpha.

Search volume rendering, there are loads of documentation, papers, techniques on the web.

A simple system is to render a bunch of quads (with back to front oredering) using a 3D texture.
Better systems use ray “tracing” within a fragment shader through the 3D texture.

I think generating a voxel out of the MRI dataset is not a good approach. As pointed out by ZBuffer, you may use volume rendering. The simplest approach of loading a 3d texture and slicing it is given here Check the books code samples. The book is a must have for any practioner/researcher for realtime volume rendering. For GPU raycasting, check this tutorial

If u need any further help, just report here. We will guide u as and when needed.