View Full Version : blending question
09-15-2002, 03:25 AM
i have some RGBA textures containing fonts and sprites, which i like to fade in/out.
I know, i could modify the alpha value of the texture and load it again using glTexSubimage2d(), or i could create a new texture for each level of transparency.
I am not verry happy with both solutions, because updating too much textures leads to a noticeable performance hit, and creating each texture up to 16 times is rather memory expensive...
Is there an other way to draw a texture with dynamic alpha values?
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...
[This message has been edited by XFire (edited 09-15-2002).]
use the GL_MODULATE together with a colors alpha value.
the resultig alpha = textureAlpha * ColorAlpha.. then just change the colors alpha per frame
09-15-2002, 04:23 AM
thank's for the quick response!
How do i have to use GL_MODULATE?
Thank's in advance...
Look up the glTexEnv() commands I think - that's where you'll specify GL_MODULATE to work with your texturing and the alpha of the primary colour.
09-16-2002, 09:18 AM
thank's for the info about glTexEnv, i'll try to get it to work...
09-16-2002, 10:12 AM
GL_MODULATE is the default state, so you should just be able to enable blending, then change the alpha of the current color with glColor4*.
Just thought I should note that if lighting is enabled then you'd have to either change the alpha of the material properties, or use glColorMaterial to be able to change it with glColor4*.
[This message has been edited by Deiussum (edited 09-16-2002).]
09-17-2002, 08:03 AM
For use GL_MODULATE :
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
09-17-2002, 01:17 PM
thank's alot for the hints!
I played around with glTexEnv and found some nice results (my favorite is the mushroom like GL_BLEND parameter http://www.opengl.org/discussion_boards/ubb/smile.gif ) but i was not able to change the alpha values/level of transparency for the texture.
Looks like i do something wrong...
Deiussum, i use glColor3f() to set the color of a texturemapped font. As soon as i use glColor4f() the transparent texels (alpha values are already set) become visible. (slightly transparent, depending on the alpha value).
But as soon as i use glColor3f() the characters are displayed propper.
An other strange behaviour...
Leyder Dylan, is it save to use ARB funktions? Are they available on every OpenGL 1.2 implementation? Or only on those from the ARB companys?
Please let me know.
Well, thanks so far for your ideas, but i still need to know how to change the alpha values for solid texels only on a RGBA texture.
Please post a repy if you have any ideas and thank's in advance,
09-17-2002, 04:56 PM
I think that the multitexturing is available on the most of video card. Just can just make a check when running your program.
You can to, use alpha test for displaying a polygon (a tree, ...) in multitexutring. I've not tryed yet but you can try it.
09-17-2002, 04:59 PM
For using alpha test, I've a demo on my site. It loads a tree with alpha test, in fact, it's a sprite.
Or in your InitGL() function :
// Spécifique au test du cannal Alpha
// On active le canal alpha
When you load your sprit, no special things to add.
Your file must have a alpha chanel, for that I add the chanel with Paint Shop Pro.
09-18-2002, 11:57 AM
Leyder Dylan, theres some verry interresting stuff on your site! Thank's for the link.
I've took a look on the alpha demo.
I am already able to display my sprites with transparent texels. But i need to know how to change the alpha values of the solid texels only.
As already sayed, i don't like to compute new alpha values for each frame and update all my textures using glTexSubimage (because the performance decreases noticeable). An other idea would be to create each texture for each level of transparency - but this would waste a lot of texture memory....
Anyway, thanks for the info!
I think i'd better post this question at the advanced forum...
09-18-2002, 12:50 PM
If you want the alpha to be the same over the entire texture, it should work to use GL_MODULATE mode to modulate with the current color, or material color, and then just change the alpha on that.
Example when not using lighting:
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // This is the default mode
glColor4f(1.0, 1.0, 1.0, desiredAlpha);
Modify desiredAlpha, and the entire textured object will be modulated to provide the transparency.
It sounds like maybe that's not what you want, though? If it's not the only other options would be those you listed, or to use multi-texturing techniques to blend with another texture, which still brings you back to needing multiple textures for the varying alphas.
09-19-2002, 02:07 PM
its working fine now http://www.opengl.org/discussion_boards/ubb/smile.gif
Deiussum, the problem was that i used glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA);
Thank you verry much!
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.