advanced alpha blending

Hi folks,

i have some RGBA textures containing fonts and sprites, which i like to fade in/out.
I know, i could compute new alpha values for the texture and load it again using glTexSubimage2d(), or i could create a texture for each level of transparency.

I am not verry happy with both solutions, because updating too much textures (at runtime) leads to a noticeable performance hit, and creating each texture up to 16 times is rather texture-memory expensive…

Is there an other way to draw a RGBA texture with dynamic alpha values for the solid texels only? (The opaque texels should remain opaqu)
Please let me know and thank’s in advance,

By the way, i am using OpenGL 1.2 on a geforce 2 powered pc - not an infinite reality4 powered onyx - unfortunatly…

Fade the vertex color?

Hi again,

OneSadCookie, fading the vertex color doesn’t work. The transparent texels become visible if i use glColor4().

Then you’re doing something wrong.

Are you using the TexEnv mode GL_MODULATE? If so, then that should work. You should be using the glBlendFunc(GL_SRCALPHA, GL_INVSRCALPHA) mode when drawing the text. That ought to allow you to use the vertex colors to control the overall transparency of the text.

if your fonts are single color, a good way to do them is with the BLEND texenv mode. you only need greyscale font images (set internal format as GL_INTENSITY so greyscale modulates alpha too).
you can control the color of the letters with the texture env constant color (you must set alpha of this to 1, and use blend(SRCALPHA, INVSRCALPHA)), and you control the transparency with the vertex colors of your quads.

but if your images must be RGBA, then Korval’s solution should work perfectly.

[This message has been edited by vshader (edited 09-19-2002).]