View Full Version : glBlendFunc & glReadPixel

06-20-2003, 06:21 AM
I've set up a pbuffer with 24 color bits and 8 alpha bits. I'm successfully able to share bound textures between my screen context & pbuffer. I'm using RGBA textures where I both frequently modify the alpha channel in the texture itself & modify the opacity for the entire texture with the material. I use:


And all of this works as expected on the screen and it also works as expected when I do a glReadPixels on the pbuffer (including getting the expected alpha out of the pbuffer) except....

There is one major glitch, the alpha values I get from the pbuffer are not correct when I have an object with transparency in front of another object. In that case the alpha values of the front object end up being the alpha values in the buffer... The fact that the object behind it that was rendered first and was completely opaque has no bearing...

I've been messing with the glBlendFunc to no avail.

As a further clue (this may be what's killing me) I also frequently clear out my depth buffer.

Can anyone set me straight?

06-20-2003, 11:48 AM
So your read work with your normal buffer (not the pbuffer).

I really dont think it should work for either, the problem is the color buffer is not setup like the depth buffer, basically the last primitive drawn is the one written to all channels, versus what you want, a comparison operator like the depth buffer for your alpha channel, where only higher values are written.

06-21-2003, 10:39 AM
Your right the pbuffer is immaterial. It works in neither case. I really don't understand there *ever* being any value in blending the alpha in the frame buffer in that manner.... surely it should be possible to specify that the alpha gets treated differently during blending so the value in the framebuffer isn't completely useless?

06-23-2003, 12:36 PM
There isnt much programmability to frame buffer blending on <= GF3 cards(that I know of). Im not sure if that situation is better on the GfFX class cards. You can disable alpha writes(on the second object) if you want the video card to use the alpha from the more solid object, but there would probably be artifacts in any software solution like that.