View Full Version : How to program fade-in / fade-out effect like movie in OpenGL
08-11-2003, 11:44 AM
I want to program the fade-in and fade-out effect like movie. I image that a scene begin black, and gradually appeared(fede-in). And gradually fade-out to white.
How can I program this effect?
At present, I guess that follow method:
1) rendering graphics
2) call glCopyTexImage2D and get entire screen image to a texture.
3) processing the texture image to reduce brightness of colors.(but,how?
4) scale the texture's size to screen size and use the texture as frame image.
(And If this method isn't nonsence, can I program dissolve effect?)
If you have any advice, I want to hear your advice very much.
08-11-2003, 11:56 AM
I gues you could simply render the scene, copy to texture (not too small, 512x512 or 1024x1024 should be appropriate), change perspective mode to glOrtho, and then rendern an exactly screen-sized quad with the texture on it, with colors fading from 0.0 to 1.0 (for all RGB), and with the color modifying the texture (I think it's glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE) ), this should give you the desired effect.
08-11-2003, 11:57 AM
Read about "blending" and "alpha values". To fade in from black, plot a solid black rectangle in front of your scene. Then gradually change its alpha value with blending enabled to make it more and more transparent as time passes.
08-12-2003, 04:26 AM
Isn't there a way to only play with the light source and get the same effect of fading?
08-12-2003, 10:52 PM
hi, the black quad with a varying alpha value works very well to solve this problem.
another problem i thought of (but never looked into much) is fading out of one scene and into another at the same time, so when half way between the two scenes u can see both with 1/2 transparency on each.
only solution i found was to render both scenes to a texture, and then use multitexturing to blend the two together. but the result is not very nice. it's too blocky if a low sized texture, or too memory intensive if using a large texture
anyone got a better solution for this?
08-13-2003, 12:06 AM
Look into using the accumulation buffer. I don't know how fast the accumulation buffer will compare to using textures but your problem can be solved using it. Simply render scene one then accumluate it at some intensity value, then render scene two and accumulate it at some intensity value.
Unfortunatley this still seems to be very memory intensive, and seeing as how the acc buffer may have more color-bit precision, it could result in degraded performance.
[This message has been edited by hkyProgrammer88 (edited 08-13-2003).]
A friend of mine got some fade-out effect using a black fog and changing the fog intensity so that 0.0 means no fade and 1.0 means black. I know it can sound sorta corny, but it works fine :P.
Could u put a rectangle over the top. Blend it with the scean? A black rectangle.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.