Graphics Reference
In-Depth Information
8.1.2 Implementation Design
With a clear understanding of what we want to accomplish with our transformation
matrices, we can move on to designing how we will implement this algorithm in the
Direct3D 11 rendering pipeline. The first step is to define what our input model data will
look like. We can assume that the model was generated by some DCC tool in a format
that can be read by our sample program. The model will be a static model, with vertex
positions, normal vectors generated by the tool, and a texture map applied to the model.
This implies that we will have per-vertex texture coordinates as well. The specific vertex
format is shown in Figure 8.6.
Now that we know what information we will be storing, we must make a decision
about how to structure the resources that will hold our model data. These resources will
be bound to the pipeline as inputs to the input assembler stage. It is common to store
our model data in one buffer resource to hold the per-vertex data (referred to as a vertex
buffer), and one buffer resource to hold our primitive specification data (referred to as an
index buffer). Let's consider the vertex buffer first. As shown in Figure 8.6, in this sample
application we will use a per-vertex position, normal vector, and texture coordinate for
our vertex format. The vertex buffer will simply contain an array of these structures to
represent each of the vertices of the input model.
Next, we will look at our index buffer. There are many primitive types available for
use in Direct3D 11, especially when you add in the control patch formats used with the
tessellation system. There are also different index ordering semantics involved with each
of the primitive types. For example, a triangle list uses three indices for each triangle primi-
tive, while a triangle strip only uses two indices plus one additional index per primitive. For
our first implementation, we will start with a basic triangle list primitive type, for ease in
specifying and inspecting data. Thus, the index buffer will provide a list of indices, which
point into the vertex buffer. The total number of indices is indicated by multiplying the
number of triangles by three.
With the input buffers defined, we can consider how the output of the pipeline will
be configured. The normal output configuration is to have both a render target and a depth
stencil buffer bound to the pipeline in the output merger stage.
The render target is typically acquired from the swap buffer
that is being used to present the rendered output to a window.
Unless otherwise noted, this is the configuration that will be
used in the subsequent examples.
If we consider our current pipeline design, we can see
that the input resources and output resources have been identi-
fied. Now we need to make a decision regarding which por-
tions of the pipeline we will use to implement this algorithm.
As noted before, we will be applying our transformation
Figure 8.6. A visualization
of the vertex format that we
will be using.
Search WWH ::




Custom Search