View Full Version : how to fade a textured object in/out ?
03-04-2008, 09:49 AM
How do you fade (alpha fade) an object in/out? (like a klingon ship does).
The only way I could do this, is to take the textures and modify the alpha channel and resend the textures to the video memory each frame. But this would be very slow.
Is there a way to effect the overall alpha attribute of a texture at render time?
03-04-2008, 11:11 AM
Try the last parameter in glColor4f
03-04-2008, 11:19 AM
will produce artifacts imho (hidden polygons popping-up)
How about this: disable color (keep depth-test and depth-write enabled), draw your object. And then enable color and draw the object the way zeoverlord mentioned. Just draw your object last (after background and things that could be behind it) ^^
03-05-2008, 07:45 AM
But i'm using textures, does glColor4f still apply? I thought that was just for solid color materials.
03-05-2008, 07:51 AM
if your texture environment mode is set to GL_MODULATE (which is the default) the color from glColor4f() will modulate the texture value. So for
and a texture value of
0.5f , 0.25f , 0.75f , 1.0f
the output will be
0.5f*1.0f , 0.25f*1.0f , 0.75f*1.0f , 1.0f*0.25f
0.5f , 0.25f , 0.75f , 0.25f
03-06-2008, 08:56 AM
Ok, I got it working. I had to call glEnable(GL_COLOR_MATERIAL) but now my lighting is not working. Everything is bright. I have a maze with lamps in the corners, but once I enable GL_COLOR_MATERIAL everything is just bright (ignores my lights).
Any ideas why?
03-06-2008, 01:58 PM
Check ambient lighting ?
03-11-2008, 07:47 AM
I got it all working now. Seems that when you enable GL_COLOR_MATERIAL that lights are 10x brighter. I've adjusted values and everything works.
Thanks to all for fast help.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.