MBlendState Class Reference


Detailed Description

Container class for an acquired GPU blend state.

MBlendState wraps an acquired composite GPU blend state. This blend state can be used to set the current GPU blend state using MStateManager::setBlendState(myBlendState).

Instances of MBlendState cannot be created or modified by users. You can read the descriptor for an MBlendState using MBlendState::desc(), but you cannot set or alter the descriptor directly.

MBlendState can only be obtained via MStateManager::acquireBlendState(). To use MStateManager::acquireBlendState(), create and fill an MBlendStateDesc instance with the requested state and pass it to MStateManager::acquireBlendState() which will return the cached unique blend state of that description. If the unique blend state did not previously exist in the cache, it is created.

The information included in the blend state includes alpha to coverage enable, independent blend enable, a global float4 blend factor, and an array of blending descriptors, one for each target.

The advantages of using this class rather than setting blend states explicitly are:

1. Since the states are cached internally, state setting is much faster than setting individual states. 2. Since state is set through the Maya viewport API, Maya can maintain accurate knowledge of the current GPU state, even in the presence of arbitrary plug-ins. This also speeds state setup by reducing redundant state setting and OGL queries. 3. The information is device aware, meaning that it will return the correct results based on the current active device. For example it will return the appropriate values for DirectX versus an OpenGL device.

Examples:

cgfxShaderNode.h, hwColorPerVertexShader.cpp, and hwPhongShader.cpp.

#include <MStateManager.h>

List of all members.

Public Types

enum   BlendOperation {
  kAdd = 0x1, kSubtract = 0x2, kReverseSubtract = 0x3, kMin = 0x4,
  kMax = 0x5
}
 

Blend operations for hardware target blending.

More...
enum   BlendOption {
  kZero = 1, kOne = 2, kSourceColor = 3, kInvSourceColor = 4,
  kSourceAlpha = 5, kInvSourceAlpha = 6, kSourceAlphaSat = 11, kDestinationColor = 9,
  kInvDestinationColor = 10, kDestinationAlpha = 7, kInvDestinationAlpha = 8, kBothSourceAlpha = 12,
  kBothInvSourceAlpha = 13, kBlendFactor = 14, kInvBlendFactor = 15
}
 

Specifies what value to use as blend factor with an optional pre-operation.

More...
enum   ChannelMask {
  kNoChannels = 0, kRedChannel = 0x1, kGreenChannel = 0x2, kBlueChannel = 0x4,
  kAlphaChannel = 0x8, kRGBChannels = 0x7, kRGBAChannels = 0xf
}
 

A bitfield that indicates which color components(red, green, blue, alpha) are writable.

More...

Public Member Functions

  ~MBlendState ()
  Destructor.
const MBlendStateDesc desc (MStatus *ReturnStatus=NULL) const
  Get the blend state descriptor that was used to create the state object.

Static Public Member Functions

static const char *  className ()
  Returns the name of this class.

Static Public Attributes

static const int  kMaxTargets = 8
  Maximum number of simulatanious render targets.

Member Enumeration Documentation

Blend operations for hardware target blending.

Enumerator:
kAdd 

Add the source and destination together.

kSubtract 

Destination minus source.

kReverseSubtract 

Source minus destination.

kMin 

The minimum of the source and destination.

kMax 

The maximum of the source and destination.

Specifies what value to use as blend factor with an optional pre-operation.

Enumerator:
kZero 

Blend factor is 0.

kOne 

Blend factor is 1.

kSourceColor 

Blend factor is source color, src.rgb.

kInvSourceColor 

Blend factor is the complement of the source color, (1 - src.rgb).

kSourceAlpha 

Blend factor is source alpha, src.a.

kInvSourceAlpha 

Blend factor is the complement of the source alpha, (1 - src.a).

kSourceAlphaSat 

Blend factor is (f, f, f, 1); where f = saturate(src.a) between 0 and 1.

kDestinationColor 

Blend factor is destination color, dst.rgb.

kInvDestinationColor 

Blend factor is the complement of the destination color, (1 - dst.rgb).

kDestinationAlpha 

Blend factor is destination alpha, dst.a.

kInvDestinationAlpha 

Blend factor is the complement of the destination alpha, (1 - dst.a).

kBothSourceAlpha 

Source blend factor is src.a, destination blend factor is (1- src.a).

kBothInvSourceAlpha 

Source blend factor is (1- src.a), destination blend factor is src.a.

kBlendFactor 

Blend factor is the global blend factor specified by users.

kInvBlendFactor 

Blend factor is the complement of the global blend factor, (1 - blendFactor.rgba).

A bitfield that indicates which color components(red, green, blue, alpha) are writable.

Enumerator:
kNoChannels 

 

kRedChannel 

 

kGreenChannel 

 

kBlueChannel 

 

kAlphaChannel 

 

kRGBChannels 

 

kRGBAChannels 

 


Member Function Documentation

const MBlendStateDesc & desc ( MStatus ReturnStatus = NULL ) const

Get the blend state descriptor that was used to create the state object.

Parameters:
[out] ReturnStatus return status
Returns:
A reference to the blend state descriptor
Status Codes:
const char * className ( ) [static]

Returns the name of this class.

Returns:
Name of this class.

MBlendState MBlendState MBlendState MBlendState MBlendState MBlendState MBlendState MBlendState MBlendState MBlendState
MBlendState MBlendState MBlendState MBlendState MBlendState MBlendState MBlendState MBlendState MBlendState MBlendState