Archived

This topic is now archived and is closed to further replies.

crazedazn203

blending textures...

Recommended Posts

hey i have some trouble getting the right effect. i have a traffic sign that has a white background. i draw this sign as a textured quad and i want to blend the white background away. right now i have set up glBlendFunc(GL_SRC_ALPHA,GL_ONE);, but this makes the whole texture transparent. is there to make it so that only one color is made transparent? oh yea my textures are all bmps, so am i using the right format?

Share this post


Link to post
Share on other sites
I''d read up on how openGL fragment blending works. it may help you out there. and read up on the Alpha Channel. (colours are stored in 32 bits, RGBA, red blue green alpha - alpha is just like any other colour just the monitor doesn''t display it) - bitmaps are RBG so when you load them the alpha (hence the GL_SRC_ALPHA in the blend function) becomes 255. You can, say, go through each pixel and run a check for, say, pink, and set it to black with no alpha.. Or, you can use another format like TGA or PNG or DDS which support RGBA (32 bit per pixel).

| - My (new) little website - | - email me - |

Share this post


Link to post
Share on other sites
ok i tried converting to TGA format, but there must be something im doin wrong when i make my file. i set it to 32bit TGA and use glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); as used in tutorial 32, but i get a white quad. when i replace my texture with on from lesson 32, it works perfect...opening these two files in photoshop i dont see any differences except that my texture is composed of single colors because it is simple and therefore the red green and blue channels are shades of grey.
what am i doing wrong?

Share this post


Link to post
Share on other sites
in photoshop to save a 32bit tga is a bit weird. You can do it two ways. It depends if you are using a locked background layer or just a normal layer. The first doesn't allow transparency, so if you use the eraser, or such, you get white. The later will actually go transparent. If you save the later as is, as a 32bit tga (make sure 'use alpha channel' is ticked in the save box) it will save, but it looses colour information badly in the transparent sections (if part of the image is half transparent, you loose half your colour accuracy there for RGB).
The other way is the better way.
Open up the image, flatten it (Layer->Flatten Image) and then go into the channels, add an alpha channel, then edit that. Flatten the image again before you save it (good idea). Then save as before. That should save correctly.


[edit]
if you don't flatten the image, PS will NOT save any extra channels you add.

| - My (new) little website - | - email me - |

[edited by - RipTorn on January 22, 2004 11:08:36 PM]

Share this post


Link to post
Share on other sites
am i supposed to be able to flatten the image after i add the alpha channel? cause the option is greyed out...
oh yea...for the alpha channel does black mean have that color or does white?

[edited by - crazedazn203 on January 22, 2004 11:39:47 PM]

Share this post


Link to post
Share on other sites
ok..so i open up the psd then flatten the image. then add an alpha channel then opacity to 100? then i color the area that i want to show up black?
flatten image is now greyed out and i Save As a TGA, but the alpha channel option is checked, but greyed out.
when i close the new tga, i get this message from PS about the it not being saved because the current file format does not support all the features of your document. i click yes to save, but now there arent any options for saving. i save as a TGA and it still wont work...

Share this post


Link to post
Share on other sites