Export (0) Print
Expand All

Effect States

Provide a mechanism for effects to control the graphics device state. Setting a state through an effect file has exactly the same effect as setting the corresponding render state or sampler state from your C# code.

The syntax for setting an effect state from an effect file is:

effect_state [ [index] ] = expression;  

Where:

effect_state
A graphics device render state or sampler state to set. A complete list of states is listed below.
[ [index] ]
Optional integer index. The index identifies a particular state within an array of effect states. The outer brackets indicate that an index is optional. If an index is used, be sure to use inner brackets.
expression
State assignment expression.
Bb313870.caution(en-us,XNAGameStudio.31).gifCaution
Effects that set render states that are not defined in this document may compile, but may fail to load due to run-time validation.

For Boolean render or sampler states, nonzero values are converted to true (1), and zero values are left alone (false).

Effect states can be divided into the following categories.

Render States

There are two types of render states.

Pixel Pipe Render States

StateTypeValues
AlphaBlendEnablebooltrue or false. Equivalent to setting AlphaBlendEnable.
AlphaFuncdwordAny value of CompareFunction. Equivalent to setting AlphaFunction.
AlphaRefdwordSame values as ReferenceAlpha. Values can range from 0x00000000 through 0x000000FF.
AlphaTestEnabledwordtrue or false. Equivalent to setting AlphaTestEnable.
BlendOpdwordSame values as BlendFunction. Equivalent to setting BlendFunction.
ColorWriteEnabledwordBitwise combination of RED|GREEN|BLUE|ALPHA. Equivalent to setting ColorWriteChannels.
DepthBiasintSame values as DepthBias.
DestBlenddwordSame values as Blend, excluding BothSourceAlpha and BothInverseSourceAlpha, which are not supported.
FillModedwordSame values as FillMode.
SrcBlenddwordSame values as Blend, excluding BothSourceAlpha and BothInverseSourceAlpha, which are not supported.
StencilEnablebooltrue or false. Equivalent to setting StencilEnable.
StencilFaildwordKeep, Zero, Replace, IncrSat, DecrSat, Invert, Incr, Dec, or TwoSided. Equivalent to setting StencilFail.
StencilFuncdwordSame values as CompareFunction. Equivalent to setting StencilFunction.
StencilMaskdwordSame values as StencilMask.
StencilPassdwordKeep, Zero, Replace, IncrSat, DecrSat, Invert, Incr, Dec, or TwoSided. Equivalent to setting StencilPass.
StencilRefintSame values as ReferenceStencil.
StencilWriteMaskdwordSame values as StencilWriteMask.
StencilZFaildwordKeep, Zero, Replace, IncrSat, DecrSat, Invert, Incr, Dec, or TwoSided. Equivalent to setting StencilDepthBufferFail.
Wrap0–Wrap15dword

Valid values are:

ZEnabledwordtrue or false.
ZFuncdwordSame values as CompareFunction. Equivalent to setting DepthBufferFunction.
ZWriteEnablebooltrue or false. Equivalent to setting DepthBufferWriteEnable.

Vertex Pipe Render States

StateTypeValues
ClipPlaneEnabledword

Valid values are any DWORD in which the status of each bit (set or not set) toggles the activation state of a corresponding user-defined clipping plane. The least significant bit (bit 0) controls the first clipping plane at index 0, and subsequent bits control the activation of clipping planes at higher indices. If a bit is set, the system applies the appropriate clipping plane during scene rendering. The default value is 0.

User-defined clipping planes are enabled when the value set in this render state contains one or more set bits (that is, is not 0). The value of the render state is not important; the system does not interpret the value as a number. Rather, the value enables the clipping plane, whose corresponding bit is set. Bit 0 controls the state of the first clipping plane (at index 0), bit 1 the second plane, and so on.

The bit patterns that these macros create can be combined by using a logical OR operation to simultaneously enable multiple clipping planes. Omitting one of these from the combination effectively disables the clipping plane at that index.

CullModedwordSame values as CullMode.
MultiSampleAntialiasbooltrue or false. Equivalent to setting MultiSampleAntiAlias.
MultiSampleMaskdwordSame values as MultiSampleMask.
PointSizefloat 
PointSize_Minfloat 
PointSize_Maxfloat 
PointSpriteEnableboolTrue or False.

Sampler States

StateTypeValues
Samplersamplernull, or a sampler state block.

Sampler Stage States

Sampler stages are used to sample textures. Sampler state determines filtering types and texture addressing modes.

Sampler stateTypeValues
AddressU[16]dwordSame values as TextureAddressMode. Equivalent to setting AddressU.
AddressV[16]dwordSame values as TextureAddressMode. Equivalent to setting AddressV.
AddressW[16]dwordSame values as TextureAddressMode. Equivalent to setting AddressW.
BorderColor[16]DWORDEither 0x00000000 (black) or 0xFFFFFFFF (white). Xbox 360 only supports a border color of either black or white. For Xbox 360, nonzero values are changed to 0xFFFFFFFFFF; zero values are left as is.
MagFilter[16]dwordPoint, Linear, or Anisotropic. Equivalent to setting MagFilter.
MaxAnisotropy[16]dwordValues must be in the range [1, 16]. The default value is 1.
MaxMipLevel[16]intValues range from 0 to (n − 1) where 0 is the largest. The default value is zero.
MinFilter[16]dwordPoint, Linear, or Anisotropic. Equivalent to setting MinFilter.
MipFilter[16]dwordNone, Point, or Linear. Equivalent to setting MipFilter.
MipMapLodBias[16]floatValues must be in the range [−16.0f, 15.9375f]. This value is converted into a 5.5 fixed-point format, where 5 bits are used for a signed integer and 5 bits are reserved for the fractional part. The default value is zero.

Shader States

There are only two effect shader states: one associated with a vertex shader object and/or associated with a pixel shader object.

Pixel Shader States

StateTypeValues
PixelShaderpixelshaderNULL, an assembly block, a compile target, or a pixel shader parameter.

Vertex Shader States

StateTypeValues
VertexShadervertexshaderNULL, an assembly block, a compile target, or a pixel shader parameter.

Shader Constant States

Shader constant states are used for setting shader constant registers.

Pixel Shader Constant States

StateTypeValues
PixelShaderConstantfloat[m[n]]m × n array of floats; m and n are optional.
PixelShaderConstant1float4One 4D float.
PixelShaderConstant2float4x2Two 4D floats.
PixelShaderConstant3float4x3Three 4D floats.
PixelShaderConstant4float4x4Four 4D floats.
PixelShaderConstantBbool[m[n]]m × n array of bools; m and n are optional.
PixelShaderConstantIint[m[n]]m × n array of ints; m and n are optional.
PixelShaderConstantFfloat[m[n]]m × n array of floats; m and n are optional.

Vertex Shader Constant States

These shader states set vertex shader constants.

StateTypeValues
VertexShaderConstantfloat[m[n]]m × n array of floats; m and n are optional.
VertexShaderConstant1float4One 4D float.
VertexShaderConstant2float4x2Two 4D floats.
VertexShaderConstant3float4x3Three 4D floats.
VertexShaderConstant4float4x4Four 4D floats.
VertexShaderConstantBbool[m[n]]m × n array of bools; m and n are optional.
VertexShaderConstantIint[m[n]]m × n array of ints; m and n are optional.
VertexShaderConstantFfloat[m[n]]m × n array of floats; m and n are optional.

Texture States

StateTypeValues
Texture[8]textureNULL, or a texture parameter.

Community Additions

ADD
Show:
© 2014 Microsoft