Sign in to follow this  
STORM76

How to fade a texture upon another?

Recommended Posts

Hi there, I am working on a Q3-like shader engine and have the requirement to let one texture to pulsate upon another using multi-pass multitexturing (later on I will switch to hardware-multitexturing). Now I have the problem that when fading out the top texture, the underlying texture will be faded out, too. In code I do something like this: glPushAttrib(GL_ALL_ATTRIBS); for each shaderstage do { glPushAttrib(GL_ALL_ATTRIBS); glEnable(GL_COLOR_MATERIAL); if (fade shaderstage) { float f = get linear time-interpolated value of [0.0f..1.0f] glColor4f(f, f, f, 1.0f); } else { glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } glBindTexture(...); glPopAttrib(); } glPopAttrib(); My understanding is that I should better change the alpha-values of the texture instead of the vertex colors. But is their an efficient way to do this on a per frame basis for a whole texture? Has anyone an idea? Thanks, Guido

Share this post


Link to post
Share on other sites
A good way to do it would be to do this

For the Fading texture, use alpha blending over the exsisting
For the other texture, just render it, no alpha blending.

make sure the setup for passes is correct.


your just making the fade texture black, which prolly dosn't help much

in multitexture, would be very easy to fade useing combine

Share this post


Link to post
Share on other sites
Thanks, that sounds good. Just one question: what is the best way for manipulating alpha values for a whole texture? Are there any commands available in OpenGL performing this task? Or do I have to iterate over my texture data and set them manually? IMHO that would slow down my engine considerably.

Share this post


Link to post
Share on other sites
It should combine against alpha value in the color that you set with a glMaterial*() call.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this