Graphics Reference
In-Depth Information
Typical supported blending functions include:
Addition
D = DA d + SA s
Subtract
D = SA s DA d
Reverse subtract
D = DA d SA s
Min
D = min ( SA s , DA d )
Max
D = max ( SA s , DA d )
Because the
channel often controls the blending factors, this blending of source
primitive color with destination pixel color is often referred to as alpha blending.
To work with alpha blending, our program must:
α
1. enable alpha blending functionality;
2. define A s , the source blending factor;
3. define A d , the destination blending factor;
(
DA d ,
)
4. define the blending function ( f
SA s
of Equation (12.3)).
For example, the blending operation from Equation (12.4) is defined as:
A s :
Source alpha
A d :
Inverse source alpha
Blend function:
Addition
UWBGL_D3D_Lib13
Change summary. See p. 525
for a summary of changes to
the library.
This library supports per-primitive alpha blending and texture mapping. The ma-
jor changes to this library are the inclusion of texture file resource management,
primitive attribute support, and DrawHelper extension for blending and textur-
ing. The details of texture support will be discussed in the next section. List-
ing 12.6 shows the modification to the Primitive class to support the blending
and texture mapping attributes. At labels A and B are the public interface meth-
ods for setting and querying the protected instance variables representing the new
attributes. Recall that in the UWBGL design, the Primitive class stores the at-
tributes for the DrawHelper class during graphics API-dependent rendering of
the primitives. Label C shows the modification to the SetupDrawAttributes()
method that passes the new attributes to the DrawHelper class. Listing 12.7 shows
the D3D support for enabling alpha blending. At label A, with the alpha blend-
ing enabled, we enable and program the D3D alpha blending functionality ac-
cording to the list in the previous section.
At label B, when alpha blending is
Search WWH ::




Custom Search