BlendState
BlendState is a descriptor that defines how output of fragment shader is written and blended into render target. A blend state can be set on a material using Material#blendState, or in some cases on the graphics device using GraphicsDevice#setBlendState.
For the best performance, do not modify blend state after it has been created, but create multiple blend states and assign them to the material or graphics device as needed.
Summary
Static Properties
ALPHABLEND | A blend state that does simple translucency using alpha channel.[read only] |
NOBLEND | A blend state that has blending disabled and writes to all color channels.[read only] |
NOWRITE | A blend state that does not write to color channels.[read only] |
Properties
blend | Enables or disables blending. |
Methods
clone | Returns an identical copy of the specified blend state. |
copy | Copies the contents of a source blend state to this blend state. |
equals | Reports whether two BlendStates are equal. |
Details
Static Properties
ALPHABLEND | A blend state that does simple translucency using alpha channel. [read only] |
NOBLEND | A blend state that has blending disabled and writes to all color channels. [read only] |
NOWRITE | A blend state that does not write to color channels. [read only] |
Constructor
BlendState([blend], [colorOp], [colorSrcFactor], [colorDstFactor], [alphaOp], [alphaSrcFactor], [alphaDstFactor], [redWrite], [greenWrite], [blueWrite], [alphaWrite])
Create a new BlendState instance.
All factor parameters can take the following values:
- BLENDMODE_ZERO
- BLENDMODE_ONE
- BLENDMODE_SRC_COLOR
- BLENDMODE_ONE_MINUS_SRC_COLOR
- BLENDMODE_DST_COLOR
- BLENDMODE_ONE_MINUS_DST_COLOR
- BLENDMODE_SRC_ALPHA
- BLENDMODE_SRC_ALPHA_SATURATE
- BLENDMODE_ONE_MINUS_SRC_ALPHA
- BLENDMODE_DST_ALPHA
- BLENDMODE_ONE_MINUS_DST_ALPHA
- BLENDMODE_CONSTANT
- BLENDMODE_ONE_MINUS_CONSTANT
All op parameters can take the following values:
- BLENDEQUATION_ADD
- BLENDEQUATION_SUBTRACT
- BLENDEQUATION_REVERSE_SUBTRACT
- BLENDEQUATION_MIN
- BLENDEQUATION_MAX
Note that MIN and MAX operations on WebGL platform require either EXT_blend_minmax or WebGL2 to work (check device.extBlendMinmax).
Parameters
blend | boolean | Enables or disables blending. Defaults to false. |
colorOp | number | Configures color blending operation. Defaults to BLENDEQUATION_ADD. |
colorSrcFactor | number | Configures source color blending factor. Defaults to BLENDMODE_ONE. |
colorDstFactor | number | Configures destination color blending factor. Defaults to BLENDMODE_ZERO. |
alphaOp | number | Configures alpha blending operation. Defaults to BLENDEQUATION_ADD. |
alphaSrcFactor | number | Configures source alpha blending factor. Defaults to BLENDMODE_ONE. |
alphaDstFactor | number | Configures destination alpha blending factor. Defaults to BLENDMODE_ZERO. |
redWrite | boolean | True to enable writing of the red channel and false otherwise. Defaults to true. |
greenWrite | boolean | True to enable writing of the green channel and false otherwise. Defaults to true. |
blueWrite | boolean | True to enable writing of the blue channel and false otherwise. Defaults to true. |
alphaWrite | boolean | True to enable writing of the alpha channel and false otherwise. Defaults to true. |
Properties
Methods
clone()
Returns an identical copy of the specified blend state.
Returns
thisThe result of the cloning.
copy(rhs)
Copies the contents of a source blend state to this blend state.
Parameters
rhs | BlendState | A blend state to copy from. |
Returns
BlendStateSelf for chaining.
equals(rhs)
Reports whether two BlendStates are equal.
Parameters
rhs | BlendState | The blend state to compare to. |
Returns
booleanTrue if the blend states are equal and false otherwise.