Transparency in textures.

Started by
10 comments, last by try_catch_this 20 years, 6 months ago
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.
Advertisement
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.
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.
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]
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.
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.
~~~~~Screaming Statue Software. | OpenGL FontLibWhy does Data talk to the computer? Surely he's Wi-Fi enabled... - phaseburn
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.

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).
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
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.
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
::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?

This topic is closed to new replies.

Advertisement