Multi-render target (MRT) can be usedProgramWrite Data to multiple render targets simultaneously in one rendering. This feature is useful in post effect. For example, if you need to write depth, normal, and Geometry Data to RT, you can use MRT to reduce the pass for generating the data. The main steps for using MRT are as follows:
- The use of MRT requires hardware support. You can query the hardware support capability before using it.
- After the hardware supports MRT, the use of MRT is similar to the use of a single common render target, except that the corresponding RT index can be specified when the RT is bound, setrendertarget (rtindex ,...). Note: During the RT binding process, you also need to create some temporary surfaces to store the default RT information on the corresponding layer for subsequent restoration.
- After the MRT is successfully bound, you can identify color0, color1,… in pixel shader ,... To write the content to the corresponding RT. After the pass is generated, rT is used.
Of course, there are still some restrictions in the use of MRT, mainly including
- The configured RT must have the same width and height.
- The Set RT usually requires the same bit width, for example, 16bits or 32 bits.
More details are provided in the d3d SDK.