Graphics Reference
In-Depth Information
in the process of determining the color of a pixel, polygons 1 from both scenes are made available to the
renderer and visibility is resolved at the sub-pixel level. The combined image is anti-aliased, and a color
for each pixel is generated. However, it is often either necessary or more efficient to composite the
images made from different scenes. Each image is anti-aliased independently, and, for each pixel,
the appropriate color and opacity values are generated in rendering the images. These pixels are then
combined using the opacity values (alpha) to form the corresponding pixel in the output image. Note
that all geometric relationships are lost between polygons of the two scenes once the image pixels have
been generated. Figure A.5(a) shows the combination of two scenes to create complex overlapping
geometry that could then be correctly rendered. Figure A.5(b) , on the other hand, shows the two scenes
rendered independently at which point it's impossible to insert the geometric elements of the one
between the geometric elements of the other. The image-based over operator, as described above, must
give visibility priority to one or the other partial scenes.
The pixel-based compositing operator, over, operates on a color value, RGB , and an alpha value
between0and1storedateachpixel.Thealphavaluecanbeconsideredeithertheopacityofthe
surface that covers the pixel or the fraction of the pixel covered by an opaque surface, or a combi-
nation of the two. The alpha channel can be generated by visible surface algorithms that handle trans-
parent surfaces and/or perform some type of anti-aliasing. The alpha value for a given image pixel
represents the amount that the pixel's color contributes to the color of the output image when
composited with an image behind the given image. To characterize this value as the fraction of
the pixel covered by surfaces from the corresponding scene is not entirely accurate. It actually needs
to be the coverage of areas contributing to the pixel color weighted by the anti-aliasing filter kernel. 2
In the case of a box filter over non-overlapping pixel areas, the alpha value equates to the fractional
coverage.
To composite pixel colors based on the over operator, the user computes the new alpha value
for the pixel:
a ¼ a F þ
(1 -
a F )
a B . The composited pixel color is then computed by
Equation A.2 .
ð a F RGB F þð
1
a F Þ a B RGB B Þ= a
(A.2)
where RGB F is the color of the foreground, RGB B is the color of the background, a F is the alpha chan-
nel of the foreground pixel, and a B is the alpha channel of the background pixel. The over operator is
not commutative but is associative (see Equation A.3 ).
n a F over B ¼ a F þð
1
a F Þ a B
over operator
F over B ¼
RGB F over B ¼ð a F RGB F þð
1
a F Þ a B RGB B Þ= a F over B
(A.3)
A over B 6¼ B over A
not commutative
ð
A over B
Þ
over C
¼
A over
ð
B over C
Þ
associative
The compositing operator, over, assumes that the fragments in the two input images are uncorre-
lated. The assumption is that the color in the images comes from randomly distributed fragments. For
example, if the alpha of the foreground image is 0.5, then the color fragments of what is behind the
1 To simplify the discussion and diagrams, one must assume that the scene geometry is defined by a collection of polygons.
However, any geometric element can be accommodated provided that coverage, occlusion, color, and opacity can be deter-
mined on a subpixel basis.
2 The filter kernel
is the weighting function used to blend color fragments that partially cover a pixel's area.
 
Search WWH ::




Custom Search