I am trying to have one texture sit on top of another and be transparent. I am using the code listed below. When this renders it makes both textures have the same transparency. Anyone know how to fix this?
glActiveTextureARB( GL_TEXTURE0_ARB );
glActiveTextureARB( GL_TEXTURE1_ARB );
thanks in advance!
Not sure about this however, I heard of the tex env color.
A texture environment (texture unit) has more than just texture and texcoord. It also has this. Don’t know however what it is, never checked it out, however, I hope this may help you.
Blending is not a per texture unit state and neither are color arrays. If you want your code snippet to work, you are going to need to either draw your geometry twice (first time with blending and color arrays disabled, second time with blending and color arrays enabled) or you are going to store the alpha value for each texture in the textures alpha channel instead of using the per vertex alpha value.
The spec is very clear:
Lighting, Materials and/or vertex colors generate an incoming fragment color (and possibly a separate specular, “second color”).
Fragment color goes through some number of texture environments. Each texture environment may apply the interpolated color value fetched from a texture to the incoming fragment value, resulting in an output fragment value. The possible modes include MODULATE, DECAL, ADD, REPLACE and COMBINE. Each texture environment is specified using ActiveTexture() and TexEnv(). The filtering parameters are specified with TexParameter(). TexParameter() sticks with the texture object, TexEnv() does not.
At the end, the last outgoing fragment color is summed with the second color, possibly has fog applied to it, and is then either written to the framebuffer, or if blending is turned on, is blended with the framebuffer using the src and dst weight factors specified by BlendFunc().
There are a number of improvements and extensions which add to this model, but understanding the above will give you a very solid ground on which to base your decisions about how to apply different texture layers; assuming you know mathematically what it is you want to accomplish (i e, when to use MODULATE, ADD or DECAL for example).
Is it possible then to modify the textures alpha texture at run time or does this have to be predefined?
Look at GL_COMBINE and the texture_env_crossbar extension (or the register_combiners extension, for nVIDIA).
Also, look at ARB_fragment_program, which lets you do almost anything.