The "frame buffer" refers to the resulting visual color of all objects sorted from back to front in the camera's view. In the scene below, objects are drawn in the following order: mountain, tree, house, man. Once the man is reached, the current frame buffer consists of the resulting visual color of the house drawn on top of the tree, which is drawn on top of the mountain. How these colors are mixed is referred to as the "frame buffer operation." You are probably most familiar with the colors not being mixed at all, but simply painted on top of each other.
However, you may want to change the frame buffer operation for geometry in your scene for special effects such as coronas or night vision. Use the radio buttons to experiment with different frame buffer operations in the above scene.
The scene contains a purple box (R = 99, G = 48, B = 156) with a yellow box (R = 255, G = 207, B = 0) in front. In this simple scene, the the purple box is considered the frame buffer because it is the resulting color of all objects sorted behind the yellow box. The yellow box has an alpha mask applied, which makes it appear transparent in some areas. In these areas, the alpha mask has a color of (R = 64, G = 64, B = 64), or about 25% opacity. Here are some examples of how the resulting color is calculated for each operation, without taking lighting into account.
Blend
This is the default frame buffer operation when geometry contains alpha,
which you are most familiar with
when viewing 3D graphics. The alpha mask is accounted for in this operation.
Since the
alpha value of the tranparent area is 25%, we use 25% of the geometry color
and 75% of the frame buffer color
to get the final color in the areas of alpha.
| Final colors: |
Red = ( .75 * 99 ) + ( .25 * 255 ) = 138
|
Replace
This is the default frame buffer operation when geometry contains no alpha.
In this operation, the alpha mask gets disregarded. The color of the buffer gets
replaced by the color of the geometry.
| Final colors: |
Red = 255
|
Multipy
The alpha mask is also disregarded here, so we use the frame buffer color times the
geometry color, treated as a percent of the maximum color.
| Final colors: |
Red = 99 * ( 255 / 255 ) = 99
|
Add
Again, the alpha mask is disregarded, so we use the frame buffer color plus the
geometry color, capping each component at 255.
| Final colors: |
Red = 99 + 255 = 255 [capped]
|
Weighted Add
Similar to Add, but this accounts for the alpha mask. We use the frame buffer color
plus the geometry color weighted by the alpha value and cap each component at 255.
| Final colors: |
Red = 99 + .25 * 255 = 163
|
WTSurfaceShader::setFrameBufferOperation