Graphics Reference
In-Depth Information
Let both source and destination values be functions of frequency, represented
by the color channel c . For each color channel c , let the new destination value
d c be
d c =
σ c ( s , d )
·
s c +
δ c ( s , d )
·
d c ,
(14.15)
where
are functions that compute the contributions of the old destination
value d and the source value s .Let BlendFunc(senum, denum) select the imple-
mentation of the
δ
and
σ
δ
σ
functions. To enable optimization of common cases in
the underlying renderer, APIs generally limit the choice of
and
to a small set of
simple functions. Hence the arguments to BlendFunc are enumerated types rather
than the functions themselves. For generality, let senum and denum have the same
type.
A partial list of the blending function enumerants and the functions to which
they correspond (which we'll extend a bit later) is:
σ
and
δ
ONE :
b c ( s , d )= 1
ZERO :
b c ( s , d )= 0
SRC_COLOR :
b c ( s , d )= s c
b c ( s , d )= d c
DST_COLOR :
s c
ONE_MINUS_DST_COLOR : b c ( s , d )= d c
To make the application of BlendFunc clear, we now examine two trivial cases
in a common scene. There exist alternative and more efficient methods for achiev-
ing these specific cases in OpenGL than what we describe here, specifically the
blending enable bit and write mask bits, but we describe the general solution to
motivate blending functionality.
Consider a static scene containing a wall covered in red latex paint, a pinhole
camera, and a thin, flat blue plastic star that is suspended between the wall and
the camera, occupying about half of the image in projection. Let these objects be
in a vacuum so that we need not consider the impact of a potentially participating
medium such as air. Now consider a sample location near the center of the star's
projection.
Blue plastic is reflective, so light incident on the star at the corresponding point
within the scene is either absorbed or reflected. Assume that we have somehow
computed the incident light and the reflective scattering. Let s describe the radi-
ance reflected toward the screen-space sample location. If we are in the midst of
rendering, then the image that we are computing may already have some existing
value d at this location, either the value with which it was initialized (say, d c = 0
W
ONE_MINUS_SRC_COLOR :
b c ( s , d )= 1
(sr m 2 )) or perhaps some “red” value if the wall was rendered into the image
first.
Any light transported from the background wall along the ray through our
sample and the camera's pinhole must necessarily be blocked by the blue star. So
we don't care what the preexisting value in d is. We simply want to overwrite it.
For this case, we select BlendFunc(ONE, ZERO) , yielding the net result
/
d c = 1.0
·
s c + 0.0
·
d c
(14.16)
= s c .
(14.17)
This is not very exciting, and it seems like a silly way of specifying that the new
value overwrites the existing one. It makes a little more sense in the context of
Search WWH ::




Custom Search