Archived

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

try_catch_this

Transparency in textures.

Recommended Posts

How do I: A) Make a single color in a texture transparent. Like say I make pink the transparent color for that texture. Without using masks. B) How do you make an RGBA image.

Share this post


Link to post
Share on other sites
A. Use an alpha channel. While loading the texture, set the alpha for all pixels of that color to transparent; set all others to an opaque alpha.

B. Define what you mean here. How you load it into memory? How you create it in an art program? How you represent it on disk? What information have you already looked up about this?


How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites
quote:
Original post by try_catch_this
B) How do you make an RGBA image.


Assuming you''re talking about creating the image, not loading/using it, you could use Photoshop. It supports alpha channels and can save as TGA and perhaps some other rgba supporting formats.

Share this post


Link to post
Share on other sites
quote:

use Photoshop



cant afford it.
Clicky

quote:

A. Use an alpha channel. While loading the texture, set the alpha for all pixels of that color to transparent; set all others to an opaque alpha.



Loading textures in opengl to me is a "black box". I call a function it loads a file. Dont know the specifics.


I was thinking about something likeglColor4f( r, g, b, a ); for each vertex? Setting the appha accordingly.



[edited by - try_catch_this on October 15, 2003 4:46:03 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by try_catch_this
Loading textures in opengl to me is a "black box". I call a function it loads a file. Dont know the specifics.


There''s no function in OpenGL that loads a file, so you must mean some auxiliary library.

Anyway, it''s time for you to open up the black box and see how it works. It''s not that hard. And it''s more or less necessary if you''re ever going to get anywhere with OpenGL.

quote:
I was thinking about something likeglColor4f( r, g, b, a ); for each vertex? Setting the appha accordingly.

That only allows you to set alpha per vertex. Definitely not enough precision for textures.


How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites
You can use Pixia with the .png plug in to create textures in alpha. You can also use Gimp, both are free.

If you want to ''black box'' textures, I suggest you use DevIL.
Clicky. That library does everything you need to create a texture.

You just bind a texture, you don''t need glColor4f(), that is only for setting polygon''s colors, not the texture''s colors.

~~~~~
"the best thing about betting on apathy is that even when you lose, you dont care." - nethead.
Download and play Slime King I.

Share this post


Link to post
Share on other sites
I think I had Gimp before but uninstalled it because I didnt like it. Well I guess $0 beats 650 usd any day

About how I load textures, I improvised on some nehe code and other around and I got a class that loads RAW, Resource bitmaps, TGA, FIle Bitmap. When I need other image formats I will ask.

When I call TextureManager.LoadGLTextureRAW( "Data/1.raw", 1, 64, 64 ) I really dont need to know how it does it. Just bind it.

Share this post


Link to post
Share on other sites
you don''t really have a choice in this; you have to learn something :

you can either learn how to manipulate textures (to put the alpha values into the texture), or learn how to create a graphic file in a format that uses alpha (gimp, for example).

Share this post


Link to post
Share on other sites
to be honest, i don''t like the gimp either. too much stuff, and those linux-people don''t like to document things in a way that non-linux people can read and understand easily (it is like hanging out with a bunch of people who constantly reference inside jokes).

so, i learned how to load a bitmap, and created my own utilities to take the bitmaps and apply and alpha channel (either based on a color value, or a separate greyscale bitmap holding alpha values), and save them to another, homemade graphics format. now my opengl apps just include the class for loading my own format into a texture. this all took about a day and a half, including the annyoing distractions like dinner and sleep and my family.

Share this post


Link to post
Share on other sites
::gluBuild2DMipmaps( GL_TEXTURE_2D, 3, BMP.bmWidth, BMP.bmHeight, GL_BGR_EXT, GL_UNSIGNED_BYTE, BMP.bmBits );

Is setting an alpha as easy as changing GL_BGR_EXT to GL_BGRA_EXT?

Share this post


Link to post
Share on other sites
To create 32bit textures, try Paint Shop Pro. The latest version (8) isn''t that good and not very cheap, but version 7 is pretty powerfull and you can buy it new for as low as $50,- most likely, maybe even cheaper.

If you do not want to know how the ''black box'' works, get an image loading library like DevIL. I wrote my own TGA loader based on the tutorials on NeHe''s and GameTutorials. It''s pretty easy. Don''t worry.

Sander Maréchal
[Lone Wolves Game Development][RoboBlast][Articles][GD Emporium][Webdesign][E-mail]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by krez
those linux-people don''t like to document things in a way that non-linux people can read and understand easily (it is like hanging out with a bunch of people who constantly reference inside jokes).


I have never heard a more applicable description of Linux documentation ... LOL

Share this post


Link to post
Share on other sites