View Full Version : blending and masking

02-14-2001, 08:58 AM
i managed to load a blended image...its basically a cactus tree with a black background. The image loads blended but the problem is that black part is completely gone(which is fine)and the green part is partially blended. I want the green part to be solid(not blended at all).
I also tried loading a picture with a masked image on it and loading both these images on separate quads....but the white appears prominent....
i figured what i need to do is....
-load an image of the green cactus with a black background( with SRC_ALPHA,ONE)

-load an image with a white background and the cactus part in black(with what??)

for the second image i need to make the white transparent and black solid...
how do I do that??

if all that is confusing my question would simply be...i want to load the picture of a cactus onto a quad and not make it look square but make it look like the actual shape of the cactus.

02-14-2001, 10:16 AM
Use RGBA (not RGB) texture map. When reading the image of the cactus, check the color of the pixel, and if it is the background color then write 0 to the alpha component, else write 1.


Tim Stirling
02-15-2001, 08:21 AM
Or make a mask of the picture with the stuff you don't want to see white and the stuff you do white. Draw this texture using the blendfunc glBlendFunc(GL_DST_COLOR,GL_ZERO)
Then change the depth testing function to GL_EQUAL and draw you actual picture maing sure the stuff you don't want is black, using the blendfunc glBlendFunc(GL_ONE, GL_ONE). change back the depth function to GL_LESS.

This method works but is far slower requireing 2 textures to be rendered and 4 state changes.

02-15-2001, 10:20 PM
Thanx what's very useful!!!