Graphics Reference
In-Depth Information
the fragment should be rejected. If a pixel shader with conservative depth output is used
that specifies SV_DepthGreaterEqual for the depth output attribute, the Hi-Z hardware
will still be able to reject the fragment. This is because the inequality guarantees that the
depth output could only become larger, and consequently, it will always fail the depth test.
Figure 3.77 illustrates this scenario.
Note that if SV_DepthLess or SV_Depthl_essEqual were used instead of SV_
DepthGreaterEqual, the Hi-Z unit would not be able to reject the fragment. This is be-
cause it would be legal for the pixel shader to output values less than the current depth
buffer value of 0.5, causing the fragment to pass the depth test. In fact, if 5V_DepthLess or
SV_DepthLessEqual are used with D3D11_C0MPARIS0N_LESS, there are no cases where the
Hi-Z unit would be able to reject fragments. The same applies to using SV_DepthGreater
or SV_DepthGreaterEqual with D3D11_C0MPARIS0N_GREATER. Consequently, a conserva-
tive depth semantic with inequality direction opposite of the depth test direction should
always be used for best performance.
A Small Example
Now we move on to consider how the pixel shader stage is used to implement a rendering
model. The primary responsibility of this stage is to produce the output color that will be
merged into the render target bound at the end of the pipeline. Thus, the ultimate decisions
the developer must make are what type of calculation to perform, and what data inputs to
use for that calculation. The types of algorithms can range from a single color output for all
pixels that are rendered, all the way to a complete global illumination system that requires
several simulation steps before the final rendering can be performed.
To explore how various algorithms can be implemented, we will first examine one
simple rendering example and see how the pixel shader is used to formulate the rendered
color output. Along the way, we will explain how this example scenario represents the ba-
sic methodology that the pixel shader operates with. By taking a high-level view of these
concepts, we will be able to implement a wide variety of algorithms, including some that
aren't even used to generate color data such as shadow maps. The details of the implemen-
tation aren't as important as the details of how processing is performed within the stage.
As mentioned above, the pixel shader is responsible for producing the final color
values that will be merged into the render targets at the end of the pipeline. In this sample
scenario, the color determination will be a product of the object's material properties, as
well as of some environmental properties that the material interacts with, such as the pres-
ence of lights. An object with the same material properties can appear quite different when
viewed in different lighting conditions, just as models with differing material properties
can appear different even if they are being rendered in the same lighting conditions. Thus,
both sets of properties must be made available to the pixel shader program to properly
determine what color to produce.
Search WWH ::




Custom Search