Microsoft DirectX 8.1 (vertex shader versions 1.0, 1.1)

def

Defines vertex shader constants.

def dest, fVal0, fVal1, fVal2, fVal3

Registers

vDest
Destination register.
fVal0, fVal1, fVal2, fVal3
Four floating point values.

To learn more about registers, see Registers.

Remarks

There are three ways to define constants in a vertex shader.

  1. Define them directly within the declarator. In this case, there is no need to use the def instruction in the vertex shader.
  2. Define them with def in the beginning (after the version instruction - vs.#.# but before all other instructions) in the vertex shader. When using def to define constants in a vertex shader, the compiled shader code returned from D3DXAssembleShader doesn't contain the constant definitions. The constant definitions are returned in the constant declaration (the 4th parameter of D3DXAssembleShader) in form of a declarator segment. This constant declarator segment must then be inserted into the original declarator of the vertex shader to effect the constant definitions. This is done by calling D3DXAssembleShader or D3DXAssembleShaderFromFile or D3DXAssembleShaderFromResource to get a LPD3DXBUFFER pointer to the constant declarator segment and inserting this constant declarator segment into the original declarator for the vertex shader. This is essentially the same as (1).
  3. Use SetVertexShaderConstant to define constants. This is the only way to define new constants or re-define existing constants at runtime without having to re-create the vertex shader.

This also applies to D3DXAssembleShaderFromFile and D3DXAssembleShaderFromResource