Aracılığıyla paylaş


Effect States

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.

Warning

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

Thre are two types of render states.

Pixel Pipe Render States

State Type Values
AlphaBlendEnable bool true or false. Equivalent to setting AlphaBlendEnable.
AlphaFunc dword Any value of CompareFunction. Equivalent to setting AlphaFunction.
AlphaRef dword Same values as ReferenceAlpha. Values can range from 0x00000000 through 0x000000FF.
AlphaTestEnable dword true or false. Equivalent to setting AlphaTestEnable.
BlendOp dword Same values as BlendFunction. Equivalent to setting BlendFunction.
ColorWriteEnable dword Bitwise combination of RED|GREEN|BLUE|ALPHA. Equivalent to setting ColorWriteChannels.
DepthBias int Same values as DepthBias.
DestBlend dword Same values as Blend, excluding BothSourceAlpha and BothInverseSourceAlpha, which are not supported.
FillMode dword Same values as FillMode.
SrcBlend dword Same values as Blend, excluding BothSourceAlpha and BothInverseSourceAlpha, which are not supported.
StencilEnable bool true or false. Equivalent to setting StencilEnable.
StencilFail dword Keep, Zero, Replace, IncrSat, DecrSat, Invert, Incr, Dec, or TwoSided. Equivalent to setting StencilFail.
StencilFunc dword Same values as CompareFunction. Equivalent to setting StencilFunction.
StencilMask dword Same values as StencilMask.
StencilPass dword Keep, Zero, Replace, IncrSat, DecrSat, Invert, Incr, Dec, or TwoSided. Equivalent to setting StencilPass.
StencilRef int Same values as ReferenceStencil.
StencilWriteMask dword Same values as StencilWriteMask.
StencilZFail dword Keep, Zero, Replace, IncrSat, DecrSat, Invert, Incr, Dec, or TwoSided. Equivalent to setting StencilDepthBufferFail.
Wrap0–Wrap15 dword

Valid values are:

ZEnable dword true or false.
ZFunc dword Same values as CompareFunction. Equivalent to setting DepthBufferFunction.
ZWriteEnable bool true or false. Equivalent to setting DepthBufferWriteEnable.

Vertex Pipe Render States

State Type Values
ClipPlaneEnable dword

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.

CullMode dword Same values as CullMode.
MultiSampleAntialias bool true or false. Equivalent to setting MultiSampleAntiAlias.
MultiSampleMask dword Same values as MultiSampleMask.
PointSize float
PointSize_Min float
PointSize_Max float
PointSpriteEnable bool True or False.

Sampler States

State Type Values
Sampler sampler null, 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 state Type Values
AddressU[16] dword Same values as TextureAddressMode. Equivalent to setting AddressU.
AddressV[16] dword Same values as TextureAddressMode. Equivalent to setting AddressV.
AddressW[16] dword Same values as TextureAddressMode. Equivalent to setting AddressW.
BorderColor[16] DWORD Either 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] dword Point, Linear, or Anisotropic. Equivalent to setting MagFilter.
MaxAnisotropy[16] dword Values must be in the range [1, 16]. The default value is 1.
MaxMipLevel[16] int Values range from 0 to (n − 1) where 0 is the largest. The default value is zero.
MinFilter[16] dword Point, Linear, or Anisotropic. Equivalent to setting MinFilter.
MipFilter[16] dword None, Point, or Linear. Equivalent to setting MipFilter.
MipMapLodBias[16] float Values 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

State Type Values
PixelShader pixelshader NULL, an assembly block, a compile target, or a pixel shader parameter.

Vertex Shader States

State Type Values
VertexShader vertexshader NULL, 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

State Type Values
PixelShaderConstant float[m[n]] m × n array of floats; m and n are optional.
PixelShaderConstant1 float4 One 4D float.
PixelShaderConstant2 float4x2 Two 4D floats.
PixelShaderConstant3 float4x3 Three 4D floats.
PixelShaderConstant4 float4x4 Four 4D floats.
PixelShaderConstantB bool[m[n]] m × n array of bools; m and n are optional.
PixelShaderConstantI int[m[n]] m × n array of ints; m and n are optional.
PixelShaderConstantF float[m[n]] m × n array of floats; m and n are optional.

Vertex Shader Constant States

These shader states set vertex shader constants.

State Type Values
VertexShaderConstant float[m[n]] m × n array of floats; m and n are optional.
VertexShaderConstant1 float4 One 4D float.
VertexShaderConstant2 float4x2 Two 4D floats.
VertexShaderConstant3 float4x3 Three 4D floats.
VertexShaderConstant4 float4x4 Four 4D floats.
VertexShaderConstantB bool[m[n]] m × n array of bools; m and n are optional.
VertexShaderConstantI int[m[n]] m × n array of ints; m and n are optional.
VertexShaderConstantF float[m[n]] m × n array of floats; m and n are optional.

Texture States

State Type Values
Texture[8] texture NULL, or a texture parameter.