Reputation: 39881
Say I have such blending equation and coefficients that colors go out of the range for example
Source color: (0.8f, 0.8f, 0.8f, 1.0)
Destination color: (0.8f, 0.8f, 0.8f, 1.0)
glBlendFunc(GL_ONE, GL_ONE);
glBlendEquation(GL_FUNC_ADD);
Should colors be normalized after calculation or they are being clamped? What is defined by the GL standard, I can't find it.
Upvotes: 0
Views: 184
Reputation: 45352
In general, color vectors are never "normalized" automatically in the GL. They are clamped at the various fragment processing stages if that operation makes sense for the current format of the color buffer, and they are never clamped when using a floating-point format.
OpenGL 4.6 Core Profile specification:
Section 17.3.6 Blending:
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 if blending is enabled, the input values are clamped unless you use an unnormalized floating point color buffer. THe result of the blending is not clamped.
The next operation is Section 17.3.7 sRGB Conversion:
[Note:
cl
is the input value of the operation (which is the resulting value of the blending stage), andcs
is the resulting value of the sRGB conversion, withcs = cl
if sRGB conversion is disabled]The resulting
cs
values for R, G, and B, and the unmodified A form a new RGBA color value. If the color buffer is fixed-point, each component is clamped to the range [0, 1] and then converted to a fixed-point value using equation 2.3. The resulting four values are sent to the subsequent dithering operation.
Upvotes: 1