Graphics Reference
In-Depth Information
Figure 3.74. The difference between using MRTs and standard single render targets for filling several ren-
der targets with scene-based data.
different render targets for receiving output from the pipeline, as long as they meet certain
size and format restrictions. A single pixel shader invocation calculates and outputs a color
to write to each of these render targets. This ability to use more than one render target si-
multaneously is referred to as multiple render targets (MRTs) and provides the potential for
improving the efficiency of a rendering algorithm.
If an algorithm requires multiple render targets to be filled with data produced from
the scene's geometry, then it is possible to fill each render target one at a time using a tradi-
tional single render target configuration. This means that all of the calculations performed
in the vertex shader, the tessellation stages, the geometry shader, and the rasterizer are
repeated for each pass. The only calculations that are different between passes are those
performed by the pixel shader. The use of MRTs allows all of the passes to be combined
into a single one, after which the pixel shader writes to all outputs individually. This saves
the cost of processing the geometric data multiple times, but still enables the same number
of render targets to be filled with the desired information. Figure 3.74 visualizes the differ-
ence between using MRTs in this scenario and making multiple rendering passes instead. A
very good example of the use of MRTs is provided in Chapter 11, "Deferred Rendering."
Modifying depth values. In addition to being responsible for writing the color values for a
given fragment, the pixel shader also can output a new depth value to the SV_Depth system
value semantic. If the pixel shader does not write the depth value, the depth generated in
the rasterizer stage is passed to the output merger stage. However, in some cases it is more
appropriate for the pixel shader to specify a depth value instead. A scenario where this
would be useful is when using billboards. A billboard is commonly used to simulate more
complex geometry with two triangles arranged to form a quad, which is then aligned to be
perpendicular to the current view direction. A texture is applied to the quad, and the results
Search WWH ::




Custom Search