blendf(3G)blendf(3G)NAMEblendf - computes a blended color value for a pixel
FORTRAN 77 SPECIFICATION
subroutine blendf(sfactr, dfactr)
integer*4 sfactr, dfactr
PARAMETERS
sfactr is a symbolic constant taken from the list below. It identifies
the blending factor by which to scale contribution from source
pixel RGBA (red, green, blue, alpha) values.
BFZERO 0
BFONE 1
BFDC (destination RGBA)/255
BFMDC 1 - (destination RGBA)/255
BFSA (source alpha)/255
BFMSA 1 - (source alpha)/255
BFDA (destination alpha)/255
BFMDA 1 - (destination alpha)/255
BFMINS min(BF_SA, BF_MDA)
BFCC (constant RGBA)/255
BFMCC 1 - (constant RGBA)/255
BFCC (constant alpha)/255
BFMCA 1 - (constant alpha)/255
BFMIN min(1, destination RGBA/source RGBA)
BFMAX max(1, destination RGBA/source RGBA)
dfactr is a symbolic constant taken from the list below. It identifies
the blending factor by which to scale contribution from
destination pixel RGBA values.
BFZERO 0
BFONE 1
BFSC (source RGBA)/255
BFMSC 1 - (source RGBA)/255
BFSA (source alpha)/255
BFMSA 1 - (source alpha)/255
BFDA (destination alpha)/255
BFMDA 1 - (destination alpha)/255
BFCC (constant RGBA)/255
BFMCC 1 - (constant RGBA)/255
BFCC (constant alpha)/255
BFMCA 1 - (constant alpha)/255
A blending factor is obtained by evaluating a mathematical expression
over a source RGBA value, a destination RGBA value and a constant RGBA
value. The latter is provided with blendc.
Blending factors, except for BFMIN and BFMAX, use RGBA values converted
to fractions of the maximum value 255. To improve performance, these
conversion calculations are approximate. However, 0 converts exactly to
Page 1
blendf(3G)blendf(3G)
0.0, and 255 converts exactly to 1.0.
DESCRIPTION
In RGB mode, the system draws pixels using a function that blends the
incoming (source) RGBA values with the RGBA values that are already in
the framebuffer (the destination values). Most often, blending is
simple: the source RGBA values replace the destination RGBA values of the
pixel.
In some cases, however, simple replacement of framebuffer values is not
appropriate. Two such cases are transparency and antialiasing. To be
blended properly, transparent objects must be rendered back-to-front
(i.e. drawn in order from the farthest object to the nearest object) with
a blend function of (BFSA, BFMSA). As can be seen from the equations
below, this function scales the incoming color components by the incoming
alpha value, and scales the framebuffer contents by one minus the
incoming alpha value. Thus incoming (source) alpha is correctly thought
of as a material opacity, ranging from 1.0 (completely opaque) to 0.0
(completely transparent). Note that this transparency calculation does
not require the presence of alpha bitplanes in the framebuffer.
Suggestions for appropriate blend functions for antialiasing are given on
the pntsmo and linesm manual pages. Other less obvious applications are
also possible. For example, if the red component in the framebuffer is
first cleared to all zeros, and then each primitive is drawn with red set
to 1 and a blend function of (BFONE, BFONE), the red component of each
pixel in the framebuffer will contain the count of the number of times
that pixel was drawn.
To determine the blended RGBA values of a pixel when drawing in RGB mode,
the system uses the following functions:
Rdestination = min (255, ((Rsource * sfactr) + (Rdestination * dfactr)))
Gdestination = min (255, ((Gsource * sfactr) + (Gdestination * dfactr)))
Bdestination = min (255, ((Bsource * sfactr) + (Bdestination * dfactr)))
Adestination = min (255, ((Asource * sfactr) + (Adestination * dfactr)))
When the blend function is set to (BFONE, BFZERO), the default values,
the equations reduce to simple replacement:
Rdestination = Rsource
Gdestination = Gsource
Page 2
blendf(3G)blendf(3G)
Bdestination = Bsource
Adestination = Asource
Fill rate may be increased substantially when blending is disabled in
this manner.
Polygon antialiasing (see polysm) is sometimes optimized when the
blendfunction (BFMINS, BFONE) is used. Source factor BFMINS, which
should be used only with destination factor BFONE, has the side effect of
slightly modifying the blending arithmetic:
Rdestination = min (255, ((Rsource * sfactr) + Rdestination))
Gdestination = min (255, ((Gsource * sfactr) + Gdestination))
Bdestination = min (255, ((Bsource * sfactr) + Bdestination))
Adestination = sfactr + Adestination
This special blend function accumulates pixel contributions until the
pixel is fully specified, then allows no further changes. Destination
alpha bitplanes, which must be present for this blend function to operate
correctly, store the accumulated coverage.
In order to store the smallest or the largest RGBA value among the source
RGBA and destination RGBA, simply use
blendf(BFMIN, BFZERO);
or
blendf(BFMAX, BFZERO);
respectively.
Blending is available with or without z-buffer mode. When blendfunction
is set to any value other than (BFONE, BFZERO), logico is forced to
LOSRC.
SEE ALSO
cpack, linesm, logico, pntsmo, polysm, blendc
Page 3
blendf(3G)blendf(3G)NOTES
Blending factors BFDA, BFMDA, BFMINS are not supported on machines
without alpha bitplanes.
IRIS-4D G, GT, and GTX models, the Personal Iris, Indigo Entry, XS, XS24,
XZ, Elan and Extreme systems do not support blend factor BFMINS.
IRIS-4D G, GT, GTX, VGX, and VGXT models, the Personal Iris, Indigo
Entry, Indy, XL, XS, XS24, and Elan systems do not support blend factors
BFCC, BFMCC, BFCA, BFMCA, BFMIN and BFMAX.
IRIS-4D B and G models and the Personal Iris do not support this function
at all. Use getgde(GDBLEN) to determine whether blending hardware is
available.
BUGS
Blending works properly only in RGB mode. In color map mode, the results
are unpredictable.
On IRIS-4D G, GT, GTX, VGX, and VGXT models, the Personal Iris, Indigo
Entry, Indy, XL, XS, XS24, and Elan systems when multiple destination
buffers are specified (using frontb, backbu, and zdraw ) only a single
location can be read and used as the destination value on the right side
of the above equations. As a result, the destination values on the left
and the right of the equations may not be taken from the same framebuffer
locations. By default, the destination RGBA values are read from the
front buffer in single buffer mode and from the back buffer in double
buffer mode. If the front buffer is not enabled in single buffer mode,
the RGBA values are taken from the z-buffer. If the back buffer is not
enabled in double buffer mode, the RGBA values are taken from the front
buffer (if possible) or from the z-buffer.
On some IRIS-4D GT and GTX models, while copying rectangles with blending
active, readso also specifies the bank from which destination color and
alpha are read (overriding the blendf setting).
IRIS-4D VGX models do not clamp color values generated by the special
blending function BFMINS,BFONE to 255. Instead, color values are allowed
to wrap.
Page 4