Graphics Reference
In-Depth Information
method of simultaneously setting an array of sampler states to reduce the number of inter-
actions with the API required to configure the pipeline for rendering.
ID3DllSamplerState*
SamplerStates[D3D11_C0MMONSHADER_SAMPLER_SLOT_C0UNT];
// Fill in the sampler states here...
pContext->VSSetSamplers( start, count., SamplerStates );
Listing 3.11. Binding an array of sampler state objects to the vertex shader stage.
Overall, we can group these four configurations together and consider them to be
the available vertex shader stage states. Configuring the vertex shader requires the proper
shader program, along with all the constant buffers, shader resources, and samplers that are
called for in the shader program. Since each vertex shader program can have significantly
different uses and requirements, it is possible to have many different combinations of these
states.
3.4.3 Vertex Shader Stage Processing
We now know what data the vertex shader can receive as input data from the input assem-
bler, and which resources can be bound by the host application. We also know that the ver-
tex shader program provides custom processing of individual vertices, regardless of which
topology the pipeline has been invoked with. So, what types of operations are performed
in the vertex shader program? Are certain types of operations better suited to this stage's
semantics? We will consider what operations the vertex shader stage is typically used for
and will comment on how best to use this stage of the pipeline.
Geometric Manipulation
The vertex shader is traditionally used to perform geometric manipulations on input data
before it is rasterized later on in the pipeline. This is because the vertices of a model hold
the information that represents the geometric surface of the object being rendered. Since
all vertices are passed through the vertex shader early in the pipeline, this is a logical place
to perform geometric manipulations. A few examples can clarify this topic fairly easily.
The prototypical operation normally performed in the vertex shader is to apply trans-
formation matrices to vertex positions. This operation modifies the input position attribute
of the vertices to reflect the placement of the geometry within the scene by performing a
matrix multiplication of the vertex position with a transformation matrix supplied by the
Search WWH ::




Custom Search