drawing RGBA textures in 3D space (MRI Imaging)

Hi all,

I’m working on visualizing MRI Images in 3D. The problem I have is that when I enable GL_DEPTH_TEST to order my slices, I lose the alpha blending…

without GL_DEPTH_TEST:
[attachment=2:1cvmtjrn]Picture 24.png[/attachment:1cvmtjrn]

[attachment=1:1cvmtjrn]Picture 25.png[/attachment:1cvmtjrn]

the reason I need to have some sort of depth sorting is that right now the textures are always drawn in the same order, so the other side of the face is never visible, and at certain angles, the face goes concave.

the concave face:

Its difficult to see in images… but when you see it in motion, it looks really weird when it rotates.

Source code link (using 0.06): http://5cameron.com/2009/09/mriVis-4sep2009.zip

Does anyone have any thoughts on this that they could contribute?



![](http://forum.openframeworks.cc/uploads/default/400/Picture 24.png)

![](http://forum.openframeworks.cc/uploads/default/401/Picture 25.png)

have you tried a GL_TEXTURE_3D? Perhaps osgVolume (part of OpenSceneGraph) is another option.

Otherwise you’ll have to sort your planes according to the distance to the eye-point. Or use a shader which does raycasting into the volume.

the problem with blending and depth test is things that are not visible are not drawn when GL_DEPTH_TEST is enabled, so the blending cannot be calculated. you need to order your planes according to the distance to the camera. you can have a Plane class that contains the texture, it’s position, rotation, anchor of rotation and some kind of getCurrentZ() method that returns the current distance calculated aplying the rotation using forr example ofxVectorMath. Then you can store all your planes in a list and order them like:

bool compare_z(Plane * first, Plane * second){  
	return first->getCurrentZ()<second->getCurrentZ();