Blending function for maximum alpha estimation

Hi,

I want to set the blending function in such a way that only the color values of the fragment with the maximum alpha values are written into the frambuffer - all other fragments should ber not considered at all…

It sounds like a question for the beginners forum, but I really don’t find the correct solution…

With “maximum alpha” you mean a known fixed value, such as 1.0 in float or 255 int ? Or an unknown value determined by scanning the whole scene or object ?

In the first case it is trivially done with alpha testing set to >= 1.0, otherwise you need to calculate or read back the alpha threshold.

I’ll try to explain my problem a little bit more in detal:

I am using a vertex shader to calculate a series of function values (256-therefore I render 256 points) - the result should be transfered to exactly the same fragment position and finally - as a result - I want to get the maximum value for free (that’s why I was thinking about using alpha blending)
However - maybe I could just change the point’s z-value according to its value (normalized) and set the depth test to get the largest one…

In that case you should use
glBlendEquation(GL_MAX)

But if I were you I would probably implement it using a for loop in a fragment shader…

N.

Your better off using the depth value.

If you backbuffer color is 32 bpp, then you can use blending. If it is 128 bit floating point buffer, blending would not work. With 64 bit floating point buffer, the NV 6x000 and up can do blending.

I haven’t tried it myself yet, but I believe the Geforce 8 series support 128 bpp fp blending.

N.

thanks for all information - I will try both solutions (max and depth) and choose the faster/more precise one…