View Full Version : transparent texture mapping
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....
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.
This code works OK for me. One texture and no blending or depthsort needed.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.