PDA

View Full Version : advanced alpha blending



XFire
09-18-2002, 12:05 PM
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,
Mike

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

OneSadCookie
09-18-2002, 12:26 PM
Fade the vertex color?

XFire
09-18-2002, 01:24 PM
Hi again,

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

Korval
09-18-2002, 03:11 PM
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.

vshader
09-18-2002, 10:55 PM
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).]