Graphics Reference
In-Depth Information
The pitfall of this interpretation is that it assumes statistical independence
between the subpixel coverage locations for each s -layer. If the two doors are per-
fectly aligned (assume a parallel projection to make this easy), then this assump-
tion does not hold because the second door provides no new occlusion of the
background. In this case, the second door is precisely behind the first and is invis-
ible to the camera. Therefore, we should have obtained the result d c = d c , and not
the one from Equation 14.23.
Equation 14.23 contains the result we expect on average; that is, if the loca-
tions covered by the doors are statistically independent. This is generally what one
wants, but if there is some underlying reason that the coverage should be corre-
lated between surfaces, then Equation 14.23 will give incorrect results. For exam-
ple, when the s α value results from thin-line rasterization, many thin lines may
naturally align in screen space (say, the support cables on a suspension bridge)
and yield an incorrect result.
The classic paper by Porter and Duff [PD84] that canonicalized blending care-
fully analyzes all coverage cases and is specific about the statistical independence
issue. Yet it is very easy to implement incorrectly. For example, the OpenGL 3.0
and DirectX 10 APIs contain an alpha-to-coverage feature that converts s α back
to a binary visibility mask when placing multiple samples within a pixel. That
feature yields incorrect compositing results, as it is specified, because the mask
contains a fixed pattern based on the s α value. Thus, the subpixel locations cov-
ered by two surfaces with equal, fractional
are always perfectly correlated in
those APIs. This tends to give undesirable results for overlapping translucent sur-
faces. Enderton et al. [ESSL11] describe the problem and one solution: Choose
the coverage based on a hash of the depth value and screen-space position.
We've discussed the coverage of the surface, but what about the coverage of
d α , the result image? Consider a case where we are rendering an image of the
contribution of all surfaces between a depth of 1 m and 2 m from the camera.
We would then like to composite this over another image containing the result for
objects at 2 m and farther. In that case, some pixels in our close image may be
completely transparent, and others may have partial or complete coverage. If we
again assume statistical independence of subpixel locations covered by different
surfaces, we can composite coverage itself by
α
d α = s α + d α ·
( 1
s α ) ,
(14.24)
thus creating a composite value d that itself acts like a surface with partial
coverage.
14.10.2.1 Premultiplied
α
Note that in the preceding section, s c never appeared in isolation. Instead, it was
always modulated by s α . Our interpretation of this was that s is a surface with
α
coverage of a screen-space area, and that the covered parts had color s c ,ormore
formally, emitted and scattered radiance s c toward the viewer. The net contribution
from s is thus s c s α .
It is common practice to store colors with premultiplied alpha, in the form
( s r s α , s g s α , s b s α , s α ) . This has several advantages. For example, it saves a few
multiplication operations during compositing and resolves the ambiguity in the
meaning of s c for a surface with s α = 0. The latter point becomes significant in
 
Search WWH ::




Custom Search