PDA

View Full Version : Problem with blending



Roest
05-02-2008, 12:13 PM
I have a dataset which i put into a 3d texture using GL_LUMINANCE_ALPHA, where the luminance is the value of the data and the alpha value is just 0 for 0 and 255 for everything else. I map this to 3 quads as seen in this screenshot http://b.imagehost.org/view/0649/screen1.png

However the blending is only correct for the last drawn quad. I use
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

Is there anything simple i have overlooked?

ZbuffeR
05-03-2008, 01:50 AM
Yes, a couple of things :-)

- depth testing
- your blendfunc is order dependant. So you have to carefully order the drawing of your quad, ie. for back to front.

If you only have binary alpha, you can get away with alpha blending and use only alpha testing, and no need to sort your quads in that case.

glAlphaFunc(GL_GREATER,0.5f); // adjust your prefered threshold here
glEnable(GL_ALPHA_TEST);

Some litterature on the subject, I recommend you read at least "Introduction to GPU Volume Rendering" (1) and (2) :
http://www.vis.uni-stuttgart.de/vis03_tutorial/

This is somewhat older :
http://www.cs.utah.edu/~jmk/sigg_crs_02/courses_0067.html

The keywords for your searches : hardware accelerated volume rendering.

There has already been quite a lot of discussions about it on these forums as well.

Roest
05-04-2008, 03:22 AM
If you only have binary alpha, you can get away with alpha blending and use only alpha testing, and no need to sort your quads in that case.

glAlphaFunc(GL_GREATER,0.5f); // adjust your prefered threshold here
glEnable(GL_ALPHA_TEST);



That did the trick, thanks alot. Also thanks for the reading suggestions.