Jump to content
  • Advertisement
Sign in to follow this  

[SOLVED]Problem to blend two rendered images together.[Fixed Function Pipe]

This topic is 4139 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Good evening. Currently I try to fade two rendered images together, with a smooth transition, but it doesnt work propperly. I do it like this. It is possible to choose among some cameras. When the camera is switched, the scene gets blended from the first camera image, to the currently choosen camera picture. So, if the camera is switched, alpha blending is enabled. Then, I put a staring fading factor into the constant color slot, which gets decreased every frame. Here is the code.
	Do the camera blending.
	If one camera is switched to another, apply 
	alpha blending between to camera pictures.
void CApplication::DoCameraBlending( DWORD dwFlag  )
	// now, set the initial values for blending in 
	// the constant color/alpha register.
	float f = GetCurScene()->GetFadeFactor() ;
        glBlendColor( f,f,f,f ) ;
	switch( dwFlag )
		// first render screen
		glBlendEquation( GL_ADD) ;
		// blend the screens

		// second render screen
		//glBlendEquation( GL_LOGIC_OP );
		//glLogicOp(GL_OR) ;
		//glBlendEquation( GL_FUNC_SUBTRACT );
		// blend the screens
		glBlendEquation( GL_LOGIC_OP );
		glLogicOp(GL_INVERT) ;
		//glBlendEquation( GL_FUNC_SUBTRACT ) ;

		break ;


CAPP_BLEND_ONE means, that the first camera picture is rendered. CAPP_BLEND_TWO means, that the second, the recently choosen or the newest cameras picture is rendered. You can ignore these lines
glBlendEquation( GL_LOGIC_OP );
glLogicOp(GL_INVERT) ;

These lines have absolutly no effect!!! I have no idea why?!?! (Depth buffer problem???) The effect works just nice, but the problem is, that the older camera picture leaves its volume on the newly rendered image. This means, the effect of fading works just fine, but there is a volume, which just disappears when the fading is finished. Examples:

The next one looks extream bad! It looks like a depth buffer problem.

Maybe someone could give me some hint, how I can solve this ugly problem!?!? Grateful Alex [Edited by - directNoob on May 23, 2007 6:46:24 PM]

Share this post

Link to post
Share on other sites
You might be right with the depth buffer idea. You could always test that by enabling the depth test and setting the depth test function to allow everything.


Hope that helps.

Share this post

Link to post
Share on other sites
I don't fully understand what you're trying to accomplish...are you trying to do a dissolve between two camera views, a la filmography?

If so, why not simply overlay the old view atop the new one, then drop the alpha only on the old view until it fades to nothing, fully revealing the new view. Since as it's blending out it will be occluding the lower image, it may appear as if they're trading places? Or is this not the effect you desire?

Share this post

Link to post
Share on other sites
Hi and thanks.

I found a solution.

It is to use glDepthMask()...

First of all.
First i thought to render to a separate texture. This means, rendering onto a texture for every camera. And than, just alpha blend them!
Very simple...

But, I dont have alpha values at hand right now, and I'm also not allowed to
program shaders, so the only availible solution to me is, using color blending with the fixed function pipe.

This is what I initially thought, but with the glDepthMask, you have to do it
vice versa. This means, first draw the camera view from the newest camera choosen with glDepthMask( GL_TRUE) and than, draw the old camera view, with glDepthMask(GL_FALSE). This worked perfectly and still works. But you still have to set the propper blending factors with glBlendFunc and, but not necessarily, glBlendEquation() with GL_FUNC_ADD.

When I'm allowed to use shaders, I will try render every camera view onto a separate texture and blend them together.

The effect looks great! This looks much better as just simply flip through the cameras and render sudden pictures.

You know what I mean?!

Thanks again

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!