View Full Version : Backbuffer alpha test

03-30-2004, 02:06 AM

I have a scene consisting of several polygons with a color and alpha texture. I want to render the polygons front to back with blending enabled (using glBlendFunc(GL_SRC_ALPHA, GL_ONE)). When the alpha of a fragment in the backbuffer reaches 1.0, successive blends should no longer affect that fragment. A fragment shader would probably do the job, but my card (Geforce4MX) does not support it. Any ideas?

I am trying to use multiple (partly) overlapping polygons that, blended, form an opaque surface. However, a surface in the back should not be visible through a surface in the front.

03-30-2004, 10:31 AM
You can't actually do exactly what you're suggesting, even with a fragment program, because fragment programs don't change frame buffer blending.

There are extensions that allow you to specify separate frame buffer blending for alpha and color, but even that is not sufficient, because you want a sharp non-linearity in behavior when the destination buffer alpha value hits one. Thinking about that requirement, what should happen if the destination alpha is 0.9, and your fragment wants to add 0.2 ? Should only half of the affected screen change take effect, or what?

Anyway, if you have a higher-level description of what you want to accomplish, then perhaps someone might be able to help you if you posted THAT -- what you posted and asked for, cannot be done.

03-30-2004, 07:30 PM

Have you tried GL_SRC_ALPHA_SATURATE, GL_ONE? It'll blend colors based on their alpha value until the destination alpha reaches 1. Also make sure you request an alpha buffer when creating the window, otherwise the destination alpha based blending functions won't work.