Graphics Reference
In-Depth Information
A.2.2 Compositing with pixel depth information
In compositing, independently generated images may sometimes not be disjoint in depth. In such cases,
it is necessary to interleave the images in the compositing process. Duff [ 5 ] presents a method for
compositing three-dimensional rendered images in which depth separation between images is not
assumed. An rgb a z (premultiplied) representation is used for each pixel that is simply a combination
of an rgb value, the alpha channel, and the z -, or depth, value. The z -value associated with a pixel is the
depth of the surface visible at that pixel; this value is produced by most rendering algorithms.
Binary operators are defined to operate on a pair of images f and b on a pixel-by-pixel basis to
generate a resultant image ( Equation A.5 ) . Applying the operators to a sequence of images in an appro-
priate order will produce a final image.
c ¼ f op b
(A.5)
The first operator to define is the over operator. Here, it is defined using colors that have been pre-
multiplied by their corresponding alpha values. The over operator blends together the color and alpha
values of an ordered pair of images on a pixel-by-pixel basis. The first image is assumed to be “over” or
“in front of” the second image. The color of the resultant image is the color of the first image plus the
product of the color of the second image and the transparency (one minus opacity) of the first image.
The alpha value of the resultant image is computed as the alpha value of the first image plus the product
of the transparency of the first and the opacity of the second. Values stored at each pixel of the image,
resulting from c ¼ f over b , are defined as shown in Equation A.6 .
rgb c ¼ rgb f þð 1 a f Þrgb b
a c ¼ a f þð
(A.6)
1
a f Þ a b
For a given foreground image with corresponding alpha values, the foreground rgb s will be unat-
tenuated during compositing with the over operator and the background will show through more as
a f decreases. Notice that when a f ¼
1, then rgb c ¼ rgb f and a c ¼ a f ¼
1; when a f ¼
0 (and therefore
rgb f ¼
0, 0, 0), then rgb c ¼ rgb b and a c ¼ a b . Using over with more than two layers requires that their
ordering in z be taken into account when compositing. The over operator can be successfully used when
compositing planes adjacent in z. If non-adjacent planes are composited, a plane lying between these
two cannot be accurately composited; the opacity of the closest surface is not separately represented
in the composited image. Over is not commutative, although it is associative.
The second operator to define is the z -depth operator, zmin, which operates on the rgb, alpha, and
z -values stored at each pixel. The zmin operator simply selects the
values of the closer pixel (the
one with the minimum z ). Values stored at each pixel of the image resulting from c ¼ f zmin b are
defined by Equation A.7 .
rgb a z
rgb a c ¼
if
ðz f < z b Þ
then
ðrgb a f Þ
else
ðrgb a b Þ
(A.7)
z c ¼
min
ðz f ; z b Þ
The order in which the surfaces are processed by zmin is irrelevant; it is commutative and asso-
ciative and can be successfully used on non-adjacent layers.
Comp is an operator that combines the action of zmin and over. As before, each pixel contains an
rgb value and an a value. However, for an estimate of relative coverage, each pixel has z -values at each
of its four corners. Because each z -value is shared by four pixels, the upper left z -value can be stored at
 
Search WWH ::




Custom Search