Graphics Reference
In-Depth Information
pixel shader stage. Instead, the pixel shader determines how each of the selected fragments
should appear, based on the fragment's attributes, and the information provided to the stage
in various resources. This gives the pixel shader a relatively important role to play in the
generation of images in real-time rendering.
The pixel shader stage also has some new abilities that were not available prior to
Direct3D 11. It can use the new resource view type, the unordered access view (UAV), to
perform read and write operations to the complete resource attached to the view. 3 5
This
is a big departure from the traditional capabilities of the pixel shader stage, which could
only write color and depth data into the pixel location that was passed to it. This provides
the potential for a large number of algorithms to be implemented directly in the rendering
pipeline, such as histogram generation, while the image is being rendered.
3.11.1 Pixel Shader Pipeline Input
The pixel shader stage receives its input fragment from the rasterizer stage. This means that
the input attributes that the pixel shader program will use are produced by the rasterizer as
well. We have already seen in the rasterizer section that it produces interpolated attribute
data, based on the sampling location of a fragment within the primitive being rasterized,
which is typically the center of the pixel (although sometimes from other sample loca-
tions). We also saw that various interpolation modifier keywords can be specified in the
pixel shader program that will instruct the rasterizer to use a particular interpolation mode
for each input attribute. These interpolation modes are useful in different scenarios, and
must be chosen appropriately to ensure that the input attributes are calculated properly. We
will explore these interpolation modes in more detail here.
Attribute Interpolation
The process of interpolating attributes requires three different pieces of information. The
first is the data that will be interpolated—the attributes of the vertices of the primitive being
rasterized. This includes both their positions and their attribute values. The second piece
of information needed for interpolation is the location of the point that requires the inter-
polated attribute data. This more or less determines how much of each vertex attribute the
interpolated value will receive. The final piece of information required is the interpolation
technique that should be used. This final item performs the actual interpolation on the first
two items described above. The interpolation mode is determined by interpolation modifier
declared with the pixel shader input signature.
3 3
A resource view can be used to expose only a subportion of a resource instead of the complete resource, as
described in Chapter 2.
Search WWH ::




Custom Search