Jump to content
  • Advertisement
Sign in to follow this  
haphazardlynamed

cant get an alpha channel on textures

This topic is 5019 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

currently using BMPs but they supposedly dont have alpha channels forum searches reveal that PNG and TGA are good alternatives, both have nice loaders available already unfortuantly I cant seem to make PNG or TGA with alpha channels Using photoshop with an alpha channel, and it just wont let me save alpha into either of those formats, in fact Photoshop seems to claim that i can make BMPs with alpha so wtf? whys photoshop seem to have all the file formats/alpha abilites backwards? and what can i do about it? need to have an alpha channel in my texture so i can use it for multitexture combining....

Share this post


Link to post
Share on other sites
Advertisement
Photoshop has some kind of special BMP format I believe which will let you save alpha. It does save alpha for TGA at least, but depending on which version of Photoshop you have you have to create the alpha layer differently.

Which version are you using?

Share this post


Link to post
Share on other sites
I don't really know about those formats you describe,so every time I need an alpha channel I follow this approach:

(1)Create the RGB texture in photoshop and save it as a bmp:"texture_RGB.bmp"
(2)Now,create a grayscale image(with the same dimensions) that represents the alphachannel and again save it as a .bmp:"texture_alpha.bmp"
(3)Write a little utility and combine these two together into an RGBA format of your own.For R,G,B channels read from "texture.bmp" and for the A channel read from "texture_alpha.bmp".Save that:"texture.raw"

You will of course have to write a loader since it's your own file format,but it should be easy enough.

Share this post


Link to post
Share on other sites
version 7.0
i really dont know how to use it very well, had to ask a friend how to set different channels and add an alpha
seems that this is not the way for it to make TGAs tho
preliminary google search reveals it might involve some wierd Photoshop specific stuff about masks, not sure i want to get into all that


mikeman, your approach sounds ok, tho i dont know too much about the guts of these formats themselves...
can I have a copy of your utility?


Share this post


Link to post
Share on other sites
I've got some C++ code that'll take an rgb bmp and create an alpha mask if you want it.

Share this post


Link to post
Share on other sites
haphazardlynamed: I suspected as much. This is the reason I stuck at 5.5 or 6.0 ;)

Although there is a plug-in which should restore this to the way it was.

The way to make alpha channels for TGA files is the following (if I remember correctly):
put the picture on the bottom layer of a .PSD (the layer should not be a background layer). Then using the erase tool with different opacities 'erase' the parts you want transparent. The background of checkers will shine through. If you save this as a .TGA file, I think Photoshop will convert this 'deletion'mask as the alph channel.

Not sure it this works, but it's worth a quick try.

edit: found the site on this: clicky

Share this post


Link to post
Share on other sites
@haphazardlynamed:I can't find the utility right now,but since it's converting to my own format,you woudn't have much use for it.However,take a look at this simple piece of code:


AUX_RGBImageRec *Image_RGB,*Image_A;
Image_RGB=auxDIBImageLoad("c:\\texture_RGB.bmp");//Load RGB data
Image_A=auxDIBImageLoad("c:\\texture_A.bmp");//Load alpha data

unsigned char *Image_RGBA=new unsigned char[Image_RGB->sizeX*Image_RGB->sizeY*4];//Alloc mem for RGBA image
unsigned char *pix1=Image_RGB->data;
unsigned char *pix2=Image_A->data;
unsigned char *pix3=Image_RGBA;
int i,j;

for (i=0;i<Image_RGB->sizeX*Image_RGB->sizeY;++i)
{

for (j=0;j<3;++j)//Copy RGB data(first 3 bytes)
{
*pix3=*pix1;
++pix3;++pix1;
}

*pix3=*pix2;++pix3;pix2=pix2+3;//Copy the alpha channel
}




I load two textures using glaux.I assume both of them are 24-bit,but "texture_A.bmp" is the alpha texture,that means it's only made of tones of gray,so R,G,B channels are the same.In the end,you can use Image_RGBA and load it using glTexImage2D and GL_RGBA.I haven't test it,so it may be not completely bug-free,but it seems right.

Share this post


Link to post
Share on other sites
Oops - please note that the code I mailed you has a memory leak.
You need to 'delete [] data' before returning.

:o

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!