Graphics Reference
In-Depth Information
pixel shader that use this depth information, and can also be used to modify the rasterizer-
generated depth value with a customized depth value. We will see later in this section how
the pixel shader can modify its depth value using the SV_Depth system value semantic.
Fragment destination. In addition to being able to receive the location that the fragment
was generated from, the fragment's ultimate destination can also be declared as an input.
If there is a standard, non-array render target bound for receiving output from the pipeline,
the output position of the fragment is more or less described by the SV_Position semantic
discussed above. However, if an array-based render target is used to generate multiple
simultaneous renderings of a scene, the render target array index must also be used to de-
termine where the fragment will finally be written to. This is commonly used to generate
various forms of environment maps, as demonstrated in Chapter 13.
The pipeline determines which render target slice to apply a primitive to by interpret-
ing the SV_RenderTargetArrayIndex system value semantic. This parameter can also be
used as an input attribute to the pixel shader. This lets the pixel shader program perform se-
lective processing of a fragment that depends on the render target slice that will ultimately
receive the fragment.
Geometric Orientation
The final specialized input attribute that we can declare for input to the pixel shader is the
SV_IsFrontFace system value semantic. This parameter provides an indication of the ori-
entation of the primitive that generated the fragment. This is a Boolean attribute that is true
when the fragment is generated by a front-facing primitive and false when it is generated
by a back-facing primitive. You may recall that the rasterizer state can be used to determine
which vertex winding defines the front-facing direction for a primitive, as well as which
of these orientations are to be culled. If both orientations are allowed to be rasterized, this
system value will specify which orientation was detected by the rasterizer stage.
Since point and line primitives have no notion of orientation, fragments generated
from either of these primitive types will always produce a value of true for this input at-
tribute. However, if a triangle primitive is rasterized in wireframe mode (which essentially
generates lines from the edges of the triangles) the triangle orientation information is still
used.
3.11.2 Pixel Shader State Configuration
With a clear understanding of what data the pixel shader program can receive, we will now
consider what types of state configurations are available to the application. The pixel shader
stage is a programmable stage, meaning that it has access to the standard common shader
core functionality that we have seen throughout the various pipeline stages. Once again, we
Search WWH ::




Custom Search