PDA

View Full Version : Shadows when using alpha blending



Naktibalda
12-27-2010, 04:33 PM
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);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

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?

Thanks

ZbuffeR
12-27-2010, 04:59 PM
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.

mobeen
12-27-2010, 11:01 PM
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 http://www.real-time-volume-graphics.org/?page_id=22. (http://www.real-time-volume-graphics.org/?page_id=22) 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 http://www.daimi.au.dk/~trier/?page_id=98

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

Regards,
Mobeen