PDA

View Full Version : transparent texture mapping



04-26-2001, 12:35 AM
i'm going to texture map a tree (flat tree) standing in my world, but dont want all the black space around the tree to be displayed... is there any better way to do this than the one i read about in Nehe's tuts i mean : first texture map monochromatic mask created of the original texture and then map the desired texture...(with changing params for blending)... it seems to be slow as it takes twice as much time as single texture mapping process....

Bob
04-26-2001, 03:59 AM
Convert your RGB texture to a RGBA texture before uploading it. Go through all pixels in the old texture, if the current pixel is the one you want trnsparent, set the alphavalue in the new texture to 0.0. If it's not the transparent color, set alpha to 1.0 and copy the RGB value aswell.

Then you upload this RGBA-texture, and use alpha test to reject pixels with alpha value of 0.0.



glAlphaFunc(GL_GREATER, 0.5);
glEnable(GL_ALPHA_TEST);

This code works OK for me. One texture and no blending or depthsort needed.