Sign in to follow this  
Alessandro

Problem with blending

Recommended Posts

Hi, i have a problem with blending that i'm unable to solve. I feel very stupid to ask about this, but here it comes: i have this rgb texture, and i apply it to a simple quad. However, as you can see from this shot, blending is not done properly. It's ok when the cloud is above the teapot, wrong when is over the background. I tried several blendfunc functions but problem remains. Any hint is greatly welcome.

Share this post


Link to post
Share on other sites
make the RGB of the texture white and stick the cloud texture in the alpha of the texture
use blending of SRC_ALPHA , 1-SRC_ALPHA
and play around with glColor4f(...) to change the lightness of the cloud

Share this post


Link to post
Share on other sites
when using blending you have to be careful of the order you draw the object.

Do you draw the teapot and then the quad or the inverse ?

Try to change the order of rendering and it will work proprely.
I think the correct order will be quad and then teapot. Try it.

If you do the inverse (teapot and then quad) the accumulation buffer (the blending) will be filled even if the teapot if in front of the quad.

Share this post


Link to post
Share on other sites
Quote:
Original post by DamienFr
when using blending you have to be careful of the order you draw the object.

Do you draw the teapot and then the quad or the inverse ?

Try to change the order of rendering and it will work proprely.
I think the correct order will be quad and then teapot. Try it.

If you do the inverse (teapot and then quad) the accumulation buffer (the blending) will be filled even if the teapot if in front of the quad.

Not quite. You have the basics right, but the specifics are a little off. The correct order is to render opaque objects first and then translucent ones (in back to front order if you have multiple translucent polygons). If you do the reverse then it is the depth buffer that gets filled and the opaque object does not get drawn where it is behind the transluncent object. However, that's not actually the problem here. The problem here is that Alessandro is using additive blending instead of alpha blending. zedzeek posted the correct solution.

Enigma

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