A stage can specify a texture map, a color function, an alpha function, a texture coordinate function, a blend function, and a few other rasterization options.
<Frequency>: the number of times that the animation cycle will repeat within a one second time period. The
larger the value, the more repeats within a second. Animations that should last for more than a second need to be expressed as decimal values.
<texture1> …<texture8>: the texture path/texture name for each animation frame must be
explicitly listed. Up to eight frames (eight separate .tga files) can be used to make an animated sequence. Each frame is
displayed for an equal subdivision of the frequency value.
// Vera Visions Material { qer_editorimage textures/sfx/b_flame7.tga vmap_lightimage textures/sfx/b_flame7.tga surfaceparm trans surfaceparm nomarks surfaceparm nolightmap vmap_surfacelight 1800 cull none { animMap 10 textures/sfx/b_flame1.tga textures/sfx/b_flame2.tga textures/sfx/b_flame3.tga textures/sfx/b_flame4.tga textures/sfx/b_flame5.tga textures/sfx/b_flame6.tga textures/sfx/b_flame7.tga textures/sfx/b_flame8.tga blendFunc GL_ONE GL_ONE } { animMap 10 textures/sfx/b_flame2.tga textures/sfx/b_flame3.tga textures/sfx/b_flame4.tga textures/sfx/b_flame5.tgatextures/sfx/b_flame6.tga textures/sfx/b_flame7.tga textures/sfx/b_flame8.tga textures/sfx/b_flame1.tga blendFunc GL_ONE GL_ONE } { program unlit map textures/sfx/b_flameball.tga blendFunc GL_ONE GL_ONE } }
6.3.1.1 blendFunc add
This is a shorthand command for blendFunc GL_ONE GL_ONE. Effects like fire and energy are additive.
6.3.1.2 blendFunc filter
This is a shorthand command that can be substituted for either blendFunc GL_DST_COLOR GL_ZERO or blendFunc GL_ZERO GL_SRC_COLOR. A filter will always result in darker pixels than what is behind it, but it can also remove color selectively. Lightmaps are filters.
6.3.1.3 blendFunc blend
Shorthand for blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA. This is conventional transparency, where part of the background is mixed with part of the texture.
BlendFunc or "Blend Function" is the equation at the core of processing shader graphics. The formula reads as follows:
[Source *<srcBlend>] + [Destination * <dstBlend>]
Source is usually the RGB color data in a texture TGA file (remember it's all numbers) modified by any rgbgen and alphagen. In the shader, the source is generally identified by command MAP, followed by the name of the image.
Destination is the color data currently existing in the frame buffer.
Rather than think of the entire texture as a whole, it maybe easier to think of the number values that correspond to a single pixel, because that is essentially what the computer is processing … one pixel of the bit map at a time.
The process for calculating the final look of a texture in place in the game world begins with the precalculated lightmap for the area where the texture will be located. This data is in the frame buffer. That is to say, it is the initial data in the Destination. In an unmanipulated texture (i.e. one without a special shader script), color information from the texture is combined with the lightmap. In a shader-modified texture, the $lightmap stage must be present for the lightmap to be included in the calculation of the final texture appearance.
Each pass or "stage" of blending is combined (in a cumulative manner) with the color data passed onto it by the previous stage. How that data combines together depends on the values chosen for the Source Blends and Destination Blends at each stage. Remember it's numbers that are being mathematically combined together that are ultimately interpreted as colors.
A general rule is that any Source Blend other than GL_ONE (or GL_SRC_ALPHA where the alpha channel is entirely white) will cause the Source to become darker.
GL_ONE This is the value 1. When multiplied by the Source, the value stays the same the value of the color information does not change.
GL_ZERO This is the value 0. When multiplied by the Source, all RGB data in the Source becomes Zero (essentially black).
GL_DST_COLOR This is the value of color data currently in the Destination (frame buffer). The value of that information depends on the information supplied by previous stages.
GL_ONE_MINUS_DST_COLOR This is nearly the same as GL_DST_COLOR except that the value for each component color
is inverted by subtracting it from one. (,i.e. R = 1.0 - DST.R, G = 1.0 - DST.G, B = 1.0 - DST.B, etc.)
GL_SRC_ALPHA The TGA file being used for the Source data must have an alpha channel in addition to its RGB channels (for a total of four channels). The alpha channel is an 8-bit black and white only channel. An entirely white alpha channel will not darken the Source.
GL_ONE_MINUS_SRC_ALPHA This is the same as GL_SRC_ALPHA except that the value in the alpha channel is inverted by subtracting it from one.(i.e. A=1.0 - SRC.A)
GL_ONE This is the value 1. When multiplied by the Destination, the value stays the same the value of the color information does not change.
GL_ZERO This is the value 0. When multiplied by the Destination, all RGB data in the Destination becomes Zero (essentially black).
GL_SRC_COLOR This is the value of color data currently in the Source (which is the texture being manipulated here).
GL_ONE_MINUS_SRC_COLOR This is the value of color data currently in Source, but subtracted from one(i.e.
inverted).
GL_SRC_ALPHA The TGA file being used for the Source data must have an alpha channel in addition to its RGB channels (four a total of four channels). The alpha channel is an 8-bit black and white only channel. An entirely white alpha channel will not darken the Source.
GL_ONE_MINUS_SRC_ALPHA This is the same as GL_SRC_ALPHA except that the value in the alpha channel is inverted by subtracting it from one. (i.e. A=1.0 - SRC.A).
Doing the Math: The Final Result
The product of the Source side of the equation is added to the product of the Destination side of the equation. The sum is then placed into the frame buffer to become the Destination information for the next stage. Ultimately, the equation creates a modified color value that is used by other functions to define what happens in the texture when it is displayed in the game world.