Rendering to Multiple Render Targets


Sometimes it can be useful to render to multiple color buffers in a single pass (I.E. a single draw call). For example, if you are writing a deferred renderer, you may want to write to an albedo, normal, depth, specular, and ambient occlusion map all at the same time. In Unity, you can bind multiple color buffers via the Graphics.SetRenderTarget method.

The following image shows the two color buffers being bound as the active render targets to be written to.
I chose to clear both render targets to the color blue.

The image below shows a frame buffer capture where two color buffers have been written to simultaneously as output.

The example below simply writes the colors red and blue to two separate color buffers. One of the colors is rendered via a full-screen quad. You can change which color buffer is displayed by commenting/uncommenting lines 42 and 43.

Download the Sample Project

Share It!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.