Texture alpha is most commonly used to "cut out" a texture image, like a stencil. This allows you to create more complex shapes while rendering simple polygons.
RGB | Alpha | |
---|---|---|
Example code: crayoland.c
Creating an alpha channel and adding it to an image is sometimes difficult, depending on the software you have.
I have made two simple tools that can be used to create an alpha channel via a blue-screen-like technique. To use them, edit your texture image in any paint program, and fill in all the areas that should be transparent with a fixed color (one that doesn't occur anywhere else in the image). The programs (makeAlpha and addAlpha) then take your image, in SGI format, along with the transparency-color, find all pixels of that color, and create an alpha channel with the value 0 for transparent pixels and 255 for all others. makeAlpha writes the alpha alone as a black & white image, so that you can check it; addAlpha writes out the color and alpha as a single, 4-channel RGBA image. These programs can be found in ~dave/bin/ on the DMS Linux machines.
For example, if your image is tree.sgi, with the background pixels filled in blue (0,0,255), then run
~dave/bin/addAlpha tree.sgi tree-with-alpha.sgi 0 0 255
to create a new image tree-with-alpha.sgi that can be used as a texture map.
Alternatively, you can create the alpha channel by hand (in a paint program) as a greyscale image, and then combine it with the RGB image using the command caglue (also in ~dave/bin):
~dave/bin/caglue tree.sgi tree-alpha.sgi tree-with-alpha.sgi