WIPIVERSE All articles

Multiple Render Targets

In the field of 3D computer graphics, Multiple Render Targets (MRT) is a feature of modern graphics processing units (GPUs) that allows the programmable rendering pipeline to render images to multiple render target textures simultaneously with a single draw call. These textures can then be used as inputs to other shaders, applied as texture maps to 3D models, or presented to the screen.

History and Background

MRT was introduced with OpenGL 2.0 and Direct3D 9. Before the advent of MRT, a programmer would have to issue a separate draw command to the GPU for each render target texture, resulting in redundant vertex transformations. In a real-time program such as a video game, this redundant processing could be quite time-consuming. With MRT, a programmer creates a pixel (fragment) shader that returns an output value for each render target, and this shader renders to all targets with a single draw call.

Technical Details

To use MRT, a developer configures multiple color attachments on a framebuffer object (or multiple render target surfaces in Direct3D). The fragment shader then writes to multiple output variables simultaneously. Key restrictions and capabilities include:

  • All render target surfaces used together must have the same bit depth, though they may be of different formats depending on hardware support.
  • All surfaces of a multiple render target should have the same width and height.
  • Some implementations cannot perform post-pixel shader operations (e.g., dithering, alpha test, fogging, blending, or masking) on multiple render targets, with the exception of the z-test and stencil test. Devices that do support post-pixel shader operations expose the corresponding capability flag.
  • No antialiasing (multisample anti-aliasing, MSAA) is natively supported on all MRT configurations, though some modern hardware and APIs can manage it with additional setup.

Common Use Cases

Deferred Shading

The most prominent application of MRT is deferred shading, a shading technique that, unlike forward shading, performs lighting calculations on an entire 3D scene at once rather than on each individual object. To achieve real-time performance, MRT stores the required information for lighting calculations in a set of textures collectively called a geometry buffer (G-buffer). Typically:

  • One render target holds the color and surface albedo information of objects.
  • Another contains surface normals and depth information, used to calculate light reflection.
  • Additional render targets can store specularity, ambient occlusion data, material properties, or other surface attributes.

After the entire scene has been drawn to the G-buffer, the lighting pass reads from these textures to compute the final lit image. However, deferred-shading pipelines that rely on MRT can require large G-buffers and significant memory bandwidth, particularly when combined with MSAA.

Other Applications

Beyond deferred shading, MRT is used in:

  • Post-processing effects such as bloom, motion blur, and depth-of-field that require multiple intermediate image buffers.
  • Shadow mapping techniques that need to output depth and color information simultaneously.
  • Particle systems and screen-space effects where multiple channels of data (e.g., color, velocity, depth) are written in a single pass.
  • Virtual reality (VR) rendering, where the left and right eye views can be rendered in a single pass using MRT.

Hardware and API Support

MRT is supported across all major graphics APIs, including:

  • OpenGL (since version 2.0) via glDrawBuffers() and framebuffer objects.
  • OpenGL ES (since version 3.0).
  • Direct3D (since version 9) via IDirect3DDevice9::SetRenderTarget().
  • Vulkan via VkRenderPass and multiple color attachments in subpasses.
  • Metal (Apple) via MTLRenderPassColorAttachments.

The number of simultaneous render targets supported varies by hardware generation. Early MRT-capable GPUs supported 2–4 simultaneous targets, while modern GPUs typically support 4–8, with some supporting up to 16 or more.

References

  • Wikipedia. "Multiple Render Targets." https://en.wikipedia.org/wiki/Multiple_Render_Targets
  • Microsoft Learn. "Multiple Render Targets (Direct3D 9)." https://learn.microsoft.com/en-us/windows/win32/direct3d9/multiple-render-targets
  • PlayCanvas Developer Site. "Multiple Render Targets." https://developer.playcanvas.com/user-manual/graphics/advanced-rendering/multiple-render-targets/
Browse

More topics to explore

    Browse all articles