

The second blending component are parameters. This equation defines the basic math operation that relates the source color and the dest color. The first defines the basic equation used for blending. If it is an unnormalized integer, blending for that buffer behaves as if it is disabled.īlending state for a buffer has two components. Either regular floats or Normalized Integers. Note that blending only works for a particular buffer if the Image Format is some form of floating point. When blending is enabled, one of the following blend equations will be used to determine the color written to that buffer. When blending is disabled to a buffer, the color from the fragment shader will be written directly to that buffer. glDisablei can be used to disable blending.īlending on all buffers can be enabled or disabled with glEnable and glDisable. Each buffer being written to by a fragment shader can have blending separately enabled and disabled. S will be written directly to O.īlending must be enabled with a call to glEnablei(GL_BLEND, i), where i is an integer representing the buffer to enable blending on. If the buffer that D comes from contains an integral format (actual, non-normalized integers), then blending for that buffer is skipped entirely. If the buffer in question uses an sRGB image format, and GL_FRAMEBUFFER_SRGB is currently enabled, then the value being read will be linearized, converting from the sRGB colorspace to a linear one. The destination color D read from the buffer can undergo changes as well. The source color S output from the fragment shader will be clamped to if the image format of the destination buffer that it is destined for is a normalized integer format. Scalar multiplies against colors are also component-wise multiplies. Da represents the alpha component of the destination color.Īll addition and multiplication is component-wise. Srgb represents only the RGB components of the source color. The S, D, and so forth represent all of the components of that color. The color S is the source color the color D is the destination color the color O is the output color that is written to the buffer. When discussing the source and dest colors, boldface type will be used to represent colors. The destination color is the color from the image in the framebuffer. The source color is the value written by the fragment shader. Blending happens independently on each fragment shader output value.īlending operations take place between a source color and a destination color. These colors are mapped to particular images in the Framebuffer via glDrawBuffers. The Fragment Shader can write a number of colors. Whereas draw buffers blend is about the ability to specify different blend parameters for different buffers. The ability to enable/disable blending to specific buffers is core 3.0 functionality. Note that the glEnablei/glDisablei functions are not part of this functionality.

So, given the function glBlendFuncSeparate, there is a glBlendFuncSeparatei whose first parameter is a draw buffer index.

This function takes one additional parameter at the beginning, an unsigned integer representing the draw buffer index whose blending data this function call is intended to change. If this functionality is available, for every function described below, there is an equivalent function that has an "i" at the end of the name ("iARB" for the extension version). No pre-4.0 hardware from NVIDIA implements this. Note: All AMD/ATI 3.x-class hardware, the HD2000, 3000, and 4000 series, implement ARB_draw_buffers_blend. Given the availability of this feature, the user can specify different blending parameters or equations for each buffer. When blending is active, the input colors from the fragment processor does not merely overwrite the corresponding value currently in the output buffer, but instead the two colors are combined together based on a function.

Once the matching is arranged, the color can be written to that buffer. Each fragment output color is matched up with a particular buffer (or discarded) via a call to glDrawBuffers or glDrawBuffer. These colors must be written to zero or more of the color buffers in the current framebuffer. There are other outputs from fragment processing, but blending only deals with colors. The result of the fragment processing stage of the OpenGL Pipeline, whether using Fragment Shaders or not, are zero or more color values. Doing this requires that you take certain steps, some of them quite difficult to deal with. This is not its only use, but it is one of its main uses. Blending can be used to make objects appear transparent.
