Section "17.3.8 Blending" of the OpenGL spec states:
If the color buffer is fixed-point, the components of the source and destination values and blend factors are each clamped to [0, 1] or [-1, 1] respectively for an unsigned normalized or signed normalized color buffer prior to evaluating the blend equation. If the color buffer is floating-point, no clamping occurs. The resulting four values are sent to the next operation.
So we know that no clamping occurs there. The next section is "17.3.8.1 Blend Equation" and states:
Signed or unsigned normalized fixed-point destination (framebuffer) components are represented as described in section 2.3.4. Constant color components, floating-point destination components, and source (fragment) components are taken to be floating-point values. If source components are represented internally by the GL as fixed-point values, they are also interpreted according to section 2.3.4.
Finally, section "17.3.8.2 Blend Functions" refers to table 17.2 which explains that for GL_SRC_ALPHA_SATURATE
:
RGB Blend Factors = (f, f, f)
Alpha Blend Factor = 1
where
$$ f = min(A_{s0}, 1 - A_d) $$
So it seems that the reference documentation is misleading for this particular case. However the specification is clear: there is no clamping or conversion for floating-point color buffers.
What if Ad is negative floating value?
My reading of the spec is that nothing special happens if Ad is negative. The min()
operation will still produce results, but I don't see how they would be useful.
I've never used GL_SRC_ALPHA_SATURATE
myself, but the way I understand it, with GL_FUNC_ADD
, it is meant to accumulate color values in the color buffer until the accumulated alpha value equals 1. When the alpha value of the color buffer is 1, no further color contribution from new pixels is allowed. This assumes that you use alpha values between 0 and 1 and use an initial alpha value of 0. Otherwise everything falls apart.
In fact, I think majority of the blending factor mechanisms were designed with alpha values between 0 and 1 in mind and make little sense outside of that range.