Quake III Arena Shader Manual Revision #12
By Paul Jaquays and Brian Hook
(with additional material by John Carmack, Christian Antkow, Kevin Cloud, & Adrian Carmack)


Previous      Index       Next


7. Notes on Alpha Channels
To use some blend modes of alphaFunc, you must add an alpha channel to your texture files. Photoshop can do this. Paintshop Pro has the ability to make an alpha channel cannot work directly in to it. In Photoshop you want to set the type to Mask. Black has a value of 255. White has a value of 0. The darkness of a pixel's alpha value determines the transparency of the corresponding RGB value in the game world. Darker = more transparent.

Care must be taken when reworking textures with alpha channels. Textures without alpha channels are saved as 24 bit images while textures with alpha channels are saved as 32 bit. If you save them out as 24 bit, the alpha channel is erased. Note: Adobe Photoshop will prompt you to save as 32, 24 or 16 bit. Choose wisely. If you save a texture as 32 bit and you don't actually have anything in the alpha channel, Quake III Arena may still be forced to use a lower quality texture format (when in 16 bit rendering) than if you had saved it as 24 bit.

To create a texture that has "open" areas, make those areas black in the alpha channel and make white the areas that are to be opaque. Using gray shades can create varying degrees of opacity/transparency.

Example: An opaque texture with see-through holes knocked in it.textures/base_floor/pjgrate1

textures/base_floor/pjgrate1
{
    surfaceparmmetalsteps
    cull none

    // A GRATE OR GRILL THAT CAN BE SEEN FROM BOTH SIDES
    {

      map textures/base_floor/pjgrate1.tga
      blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
      alphaFunc GT0
      depthWrite
      rgbGen identity

    }
    {

      map $lightmap
      rgbGen identity
      blendFunc GL_DST_COLOR GL_ZERO
      depthFunc equal

    }

}

1A
1B
1C
1D
1E
pentagram.tga
Alpha channel of pentagram.tga used as GL_SRC_ALPHA
greenfloor.tga
Alpha channel of pentagram.tga inverted by using it as GL_ONE_MINUS_SRC_ALPHA
Greenfloor with pentagram merged into it.

Start with a TGA file image. In this case, a pentagram on a plain white field (figure 1A). The color of the field surrrounding the image to be merged is not relevant to this process (although having a hard-edged break between the image to be isolated and the field makes the mask making process easier). Make an alpha channel. The area of the image to be merged with another image is masked off in white. The area to be masked out (not used) is pure black (figure 1B). The image to be merged into is greenfloor.tga (figure 1C).

Make a qer_editorimage of greenfloor.tga. This is placed in the frame buffer as the map image for the texture. By using GL_SRC_ALPHA as the source part of the blend equation, the shader adds in only the non-black parts of the pentagram. Using GL_MINUS_ONE_SRC_ALPHA, the shader inverts the pentagram's alpha channel and adds in only the non-black parts of the green floor.

In a like manner, the alpha channel can be used to blend the textures more evenly. A simple experiment involves using a linear gradiant in the alpha channel (white to black) and merging two textures so they appear to cross fade into each other.

A more complicated experiment would be to take the pentagram in the first example and give it an aliased edge so that the pentagram appeared to fade or blend into the floor.


Previous     Index       Next


Quake 3: Arena Shader Manual Copyright 1999 id Software, Inc.
Revision 12 December 23, 1999

HTML by Jason Heppler
HTML Linking by Matthew "Bushboy" Trow
http://www.heppler.com/shader/