Graphics Reference
In-Depth Information
vertex shader, the array of D3D11_INPUT_ELEMENT_DESC structures used to create the input
layout object must match the declared input signature of the vertex shader. Therefore, the
individual vertex attributes must match what is expected by the vertex shader, including the
data type and semantic name. Listing 3.7 shows a sample vertex shader program in HLSL.
struct VS_INPUT
{
float3 position : POSITION;
float2 tex : TEXCOORDS;
float3 normal : NORMAL;
};
VS_0UTPUT VSMAIN( in VS_INPUT v )
{
}
Listing 3.7. A sample vertex shader input declaration.
For this example, the application would need to provide vertex data that consists of
a POSITION semantic attribute with three floating point elements, a TEXCOORDS semantic
component with two floating point elements, and a NORMAL semantic component with three
floating point elements. Creating an input layout object helps the developer ensure that the
vertex data and the vertex shader signature match one another. Since the vertex data is sup-
plied by the application, it can be created or loaded in the proper format to be used with a
particular vertex shader. These inputs are then used by the vertex shader to perform its own
calculations, and it will then also define a number of output attributes, which it will write
out to be used by the next active pipeline stage. This process is repeated for each subse-
quent pipeline stage, with each stage declaring its output signature and then supplying its
output data in them. Some typical examples of input data produced by the input assembler
include, but are certainly not limited to, the following:
float 3 position—the position of the input vertex
float3 normal—the normal vector of the input vertex
float 3 tangent—the tangent vector of the input vertex
float 3 bitangent — the bitangent vector of the input vertex
uint4 boneIDs—four-bone IDs of the vertex used for skinning
float4 boneWeights—four-bone weights of the vertex used for skinning
Search WWH ::




Custom Search