PDA

View Full Version : Which BlendFunc(...) to use ?



OGL_PGR
09-29-2005, 03:59 AM
Please help me choose the proper blending function:

I have an RGB image with some BLACK spots...

How do I make those BLACK areas transparent ?

Thanks.

diwic
09-29-2005, 04:40 AM
If I were you, I would try to make your RGB image an RGBA image and set the alpha value whenever there's a black spot to zero (and to one otherwise).

Then I would:
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glColor4d(1,1,1,1);

...before I started putting the vertexes out.

// David

Michoo
09-29-2005, 11:26 AM
I'm using glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ;
textures: I bind 24 and 8 bit bitmaps or make alpha from choosen color and create file that can be directly load to memory.

If you want I can send source or .exe of my binder - it's made in bc++b.

dorbie
09-29-2005, 02:05 PM
To make the black spots transparent you'd have to use something like:

glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);

That will probably not look very satisfying though. The better way is to add an alpha channel because that gives you independent control of color and alpha, and then use the other suggestions already posted.

OGL_PGR
09-29-2005, 07:43 PM
Thanks a lot.

I'm getting Ok results with this:

glEnable(GL_BLEND);

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0);
// select the cactus texture
glBindTexture(GL_TEXTURE_2D, tex_id);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
...
glBegin(GL_TRIANGLE_STRIP);
...
...
glEnd();
...
glDisable(GL_ALPHA);
glDisable(GL_BLEND);
---------------------------
Image is basically a tree with BLACK background.
Sometimes, I can still see "black" dots here and there near the corners...( during rendering )

Whats the reason for that ?
Could someone tell me how to create an ALPHA map in photoshop ?

Thanks.