PDA

View Full Version : Render to texture alpha blending quality?



Gut Flora
02-28-2010, 06:54 PM
Hello to the OpenGL community!

When I render a texture with alpha components to a render target (FBO with texture attached), the result looks dark and incorrectly blended. Here's a screen shot of what's happening:

http://lh3.ggpht.com/_vrrgDZzNAew/S4sbCzSwwSI/AAAAAAAAACU/vWR_wW5d3A4/s800/Alpha.png

Both left and right textures are blended with the same blend equation and parameters, using fixed function blending (no shaders).

The texture to the left is blended to the frame buffer. The texture to the right is blended to the FBO.

As you can see, the texture (left) blended to the frame buffer looks as it should. However, the texture blended to the FBO (right) is dark and incorrectly blended.

When rendering non-alpha component textures, the effect is as desired, with no texture darkening, as is shown from this screen shot:
http://lh3.ggpht.com/_vrrgDZzNAew/S4sbDRfOcWI/AAAAAAAAACY/Ah6EpJiKZoQ/s800/Normal.png

The texture color format attached to FBO is GL_RGBA8, and GL_BGRA.

Any ideas?

*Edit:

It seems the texture blends correctly when I switch blending modes to GL_ONE, GL_ONE.


glBlendFunc( GL_ONE, GL_ONE );

Still stumped as to why. Anybody?

Alfonse Reinheart
02-28-2010, 07:11 PM
Both left and right textures are blended with the same blend equation and parameters, using fixed function blending (no shaders).

What are you blend parameters?

Gut Flora
02-28-2010, 07:38 PM
GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA


glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA );

Alfonse Reinheart
02-28-2010, 07:54 PM
OK, so you render to the texture with this blend mode. But that's just rendering to a texture, right? In order to see something, you must render it to the screen, correct?

So what blend mode do you use when rendering the texture you used as a render target to the screen?

Gut Flora
02-28-2010, 11:10 PM
:o Of course. Thank you!