View Full Version : Alpha blending + pbuffer = doesn't work !!

07-22-2004, 05:23 PM
Hi all:
I'm using pbuffer as my rendertarget, and Cg for both vertex and fragment program. I found that alpha blending doesn't work properly in this situation. For example:

1. glBlendFunc(GL_ONE, GL_ZERO) gives correct result.
2. glBlendFunc(GL_ZERO, GL_ONE) gives black screen.
3. glBlendFunc(GL_ONE, GL_ONE) gives same result as 1.
4. glglBlendFunc(GL_DST_COLOR, GL_ZERO) gives black screen.
5. glBlendFunc(GL_ZERO, GL_SRC_COLOR) gives black screen.

It seems the content of the pbuffer is lost before alpha blending takes place, any idea why? Forgot to mention, I cleared the z-buffer after drawing the first pass, will this be a problem?

07-22-2004, 07:21 PM
blending is working just fine. You must not understand the blending function. Did you read chapter 6?

07-23-2004, 05:41 PM
Errr, is it correct?

Why does 2 and 4 give black screen?

07-25-2004, 11:55 PM
Originally posted by 991060:

2. glBlendFunc(GL_ZERO, GL_ONE) gives black screen.
At first, you have a black screen after
glClearColor( 0.0, 0.0, 0.0, 1.0 );
If you're drawing something with
glBlendFunc(GL_ZERO, GL_ONE)
you takking no color component from something_you_are_drawing (GL_ZERO) and full color component from black background (GL_ONE) = you'll have black colored something_you_are_drawing:
0 * ( R, G, B ) + 1 * ( 0, 0, 0 ) = ( 0, 0, 0 )

Originally posted by 991060:

4. glglBlendFunc(GL_DST_COLOR, GL_ZERO) gives black screen.
something_you_are_drawing colored with black background color (GL_DST_COLOR) + no color component from background (GL_ZERO) = black something_you_are_drawing on black background = black screen


Another question:
Why I'm getting black screen with 3-d antialiasing using blend function like in The Redbook's example:
What another blend func I have to use?