×
Menu

NiAlphaProperty from NDL help (EN)

 
NiAlphaProperty (страница из оригинальной справки. NDL Gamebryo 1.1)

Description
NiAlphaProperty is a rendering property that controls the various parameters associated with alpha blending, including enabling and disabling it, and setting the source and destination blending functions. The property also affects alpha testing, which can increase performance and alleviate the need for the sorting of alpha blended objects.
 
Constructors
NiAlphaProperty()
This default constructor constructs a property with alpha blending and alpha testing turned off, the source blending function set to NiAlphaProperty::ALPHA_SRCALPHA, the destination blending function set to NiAlphaProperty::ALPHA_INVSRCALPHA, the alpha testing function set to TEST_ALWAYS, and the reference alpha value set to 0.
 
Notes
Alpha Blending Formula
Assuming the pixel passes the alpha testing function, the formula used when determining the color of a framebuffer pixel following the write of an alpha blended pixel is as follows:
 
 
Where CDest is the current pixel color in the framebuffer, and CSource is the incoming color of the pixel. The return values of the source and destination alpha blending functions are multiplied component-wise with the source and destination color values, respectively (as shown in the formula).
 
Alpha Blending Functions
The following blending functions are supported by Gamebryo (although not all renderers will be able to support all functions, or all combinations of source and destination functions--see the renderer documentation for details); all of the following constants are in the scope of NiAlphaProperty, and must be scoped accordingly. In the following table, RS, GS, BS and AS are the source red, green, blue and alpha values respectively; RD, GD, BD and AD are the destination red, green, blue and alpha values, respectively. Note that not all renderers can support destination alpha (AD) on all hardware. For the purposes of this table, colors and alpha values are assumed to be between 0.0 and 1.0.
Blending Function
Value
ALPHA_ONE
(1, 1, 1)
ALPHA_ZERO
(0, 0, 0)
ALPHA_SRCCOLOR
(RS, GS, BS)
ALPHA_INV(ers)SRCCOLOR
(1 - RS, 1 - GS, 1 - BS)
ALPHA_DESTCOLOR
(RD, GD, BD)
ALPHA_INVDESTCOLOR
(1 - RD, 1 - GD, 1 - BD)
ALPHA_SRCALPHA
(AS, AS, AS)
ALPHA_INVSRCALPHA
(1 - AS, 1 - AS, 1 - AS)
ALPHA_DESTALPHA
(AD, AD, AD)
ALPHA_INVDESTALPHA
(1 - AD, 1 - AD, 1 - AD)
ALPHA_SRCALPHASAT
(f, f, f, 1)àf = min (AS, 1 - AD)
 
Alpha Testing Functions
The following testing functions are supported by Gamebryo (although not all renderers will be able to support all functions); all of the following constants are in the scope of NiAlphaProperty, and must be scoped accordingly. In the following table, AS is the source alpha value, and AR is the reference alpha value. If the respective test returns true, then the pixel is rasterized.
Testing Function
Value
TEST_ALWAYS
Always true
TEST_LESS
AS < AR
TEST_EQUAL
AS = AR
TEST_LESSEQUAL
AS £ AR
TEST_GREATER
AS > AR
TEST_NOTEQUAL
AS ¹ AR
TEST_GREATEREQUAL
AS ³ AR
TEST_NEVER
Never true