Shader semantics bind shader input and output registers with pipeline data or other shader parameters. For more about using shader semantics, see Varying Shader Inputs and Semantics.
Semantics are attached to function parameters like this:
[Parameter Modifiers] ParameterType ParameterName [: Semantic] [= Initializers]
Each of these is covered in detail on the function declaration syntax page.
The vertex shader input semantics are:
Vertex Shader Input Semantic | Description |
---|---|
BINORMAL[n] | Binormal |
BLENDINDICES[n] | Blend indices |
BLENDWEIGHT[n] | Blend weights |
COLOR[n] | Diffuse and specular color |
NORMAL[n] | Normal vector |
POSITION[n] | Vertex position in object space |
POSITIONT | Transformed vertex position. POSITIONT tells the runtime that the vertex is transformed and that the vertex shader should not be executed. |
PSIZE[n] | Point size |
TANGENT[n] | Tangent |
TESSFACTOR[n] | Tessellation factor |
TEXCOORD[n] | Texture coordinates |
n is an optional integer between 0 and the number of resources supported. For example, PSIZE0, COLOR1, etc.
The vertex shader output semantics are:
Vertex Shader Output Semantic | Description |
---|---|
COLOR[n] | Diffuse or specular color. Any vertex shader prior to vs_3_0 should clamp a parameter that uses this semantic between 0 and 1, inclusive. A vs_3_0 vertex shader has no restriction on the data range. |
FOG | Vertex fog. |
POSITION[n] | Position of a vertex in homogenous space. Compute position in screen-space by dividing (x,y,z) by w. Every vertex shader must write out a parameter with this semantic. |
PSIZE | Point size. |
TEXCOORD[n] | Texture coordinates. |
The pixel shader input semantics are:
Pixel Shader Input Semantic | Description |
---|---|
COLOR[n] | Diffuse or specular color. For shaders prior to vs_3_0 and ps_3_0, this data ranges between 0 and 1, inclusive. Starting with ps_3_0, there is no restriction on the data range. |
TEXCOORD[n] | Texture coordinates. |
VFACE | Floating-point scalar that indicates a back-facing primitive. A negative value faces backwards, while a positive value faces the camera. See Face Register. |
VPOS | Contains the current pixel (x,y) location. See Position Register. |
The pixel shader output semantics are:
Pixel Shader Output Semantic | Description |
---|---|
COLOR[n] | Ouput color. Any pixel shader prior to ps_3_0 should clamp a parameter that uses this semantic between 0 and 1, inclusive. For ps_3_0 shaders, the data range is dependent on the render target format. |
DEPTH[n] | Output depth. |
You can also double-bind semantics. That is, apply the same semantic to more than one parameter. For instance:
float4x4 WorldView[60] : WORLDVIEW : register(c16); float4 main( float3 Pos : POSITION, int4 IPos : POSITION ) : POSITION { float3 P = mul(float4(Pos, 1), (float4x3)WorldView[IPos.w]); return float4(P,1); }
This function takes two arguments: a three-component, floating-point position and a four-component, integer position. The integer position is used as an index into the array of world-view matrices.