View Full Version : Linear Mipmapping with transparency bitmap color

Joe Montana
07-14-2005, 09:37 AM
Im trying to render a mipmapped texture in a quad . The bitmap has a transparency color. Therefore with linear mipmapping(or nonmipmapping) the transparency color is getting blended with adjacent colors and is not transparent anymore. How can you have transparency in a bitmap with linear texture mapping?


07-14-2005, 04:35 PM
You can calculate the smaller mipmap levels yourself instead of using gluBuild2DMipmaps, and do the color->transparency mapping on those explicitly. You just have to make sure you can identify the texels that you want to be transparent.

That doesn't totally solve the problem, but it should help you get closer.

07-14-2005, 10:40 PM
When you allocate the bitmap in main memory, allocate it with an alpha channel and loop through the pixels to fill the alpha channel.
Then upload with gluBuild2DMipmaps.

That should make the mixed pixels somewhat transparent instead of just a different color.
There is one downside: the color is also interpolated by mipmapping. So if you use e.g. black as the transparent color, in the mipmap will pixels that are next to the transparent color will be darker.
If you want to prevent that, you'll have to calculate your own mipmaps like dirk suggested, but do interpolate the alpha channel.

Joe Montana
07-15-2005, 07:09 AM
Thanks. I changed the bitmap transparency color to black after loading it and its much better with the linear texture mapping now.
I always have a problem with blend modes. I want to just now take the black(transparent) color of the bitmap and blend it with the color in the current What is the blendfunc to do this without using alpha blending, just a 3 component bitmap color?.