Problem with blending

Started by
2 comments, last by Enigma 18 years, 5 months ago
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.
Advertisement
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
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.
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

This topic is closed to new replies.

Advertisement