Hi guys,

just a short blog post with a super short content. I’ve seen a question on the monogame forums of how to render to multiple render targets at once in monogame (identical in XNA, too).

I am writing this again on my blog so it is preserved for future searchers :)

Here is the solution (160kb). You will have to build the content anew and build the solution itself to make it run. (Open the content pipeline -> rebuild)

The idea is very very simple: I draw red to one texture and blue to the other (but I do that at the same time with MRT rendering).
To showcase our results I render these two textures seperately.

and here is version which just uses spritebatch, in case you need that


I’ve also noticed that I didn’t even post about the bloom solution / integration I’ve made for fellow indie devs.

Here you go. The sample should be pretty easy to understand and integrate into your game if you want. For more info follow the link.

An example application is in my deferred engine, which you can download on github, too.
(Discussion here:

Overview MRT

Basically it is just these two functions

protected override void Initialize()
//Create a mesh to render, in our case a simple rectangle / quad
quadRenderer = new QuadRenderer();

//Create our rendertargets!
renderTarget1 = new RenderTarget2D(GraphicsDevice, width, height);
renderTarget2 = new RenderTarget2D(GraphicsDevice, width, height);

//Create our Rendertargetbinding
renderTargetBinding[0] = renderTarget1;
renderTargetBinding[1] = renderTarget2;



protected override void Draw(GameTime gameTime)
//Set our renderTargetBinding as the target!


//Apply our shader. It should make the first rendertarget red, and the second one blue. You find the shader in content/BasicShader.fx

//Draw our mesh! It's just a fullscreen quad / rectangle (We can use spritebatch, see second link)
 quadRenderer.RenderQuad(GraphicsDevice, -Vector2.One, Vector2.One);

//Set our backbuffer as RenderTarget

//Draw our rts

//Our first rt should be red! It's in the top left corner!
 spriteBatch.Draw(renderTarget1, new Rectangle(0,0,width/2, height/2), Color.White);
//Our second one should be blue in the bottom right corner
 spriteBatch.Draw(renderTarget2, new Rectangle(width / 2, height / 2, width / 2, height / 2), Color.White);


As you can see it’s very basic.

  • Draw a fullscreen quad with MRT, draw red to the first one and blue to the other one
  • Draw the RTs seperately to the backbuffer to see how they look like now


struct VertexShaderInput
{  float3 Position : POSITION0;

struct VertexShaderOutput
{  float4 Position : POSITION0;

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{  VertexShaderOutput output;  output.Position = float4(input.Position, 1);  return output;

struct PixelShaderOutput
{  float4 Color0 : COLOR0;  float4 Color1 : COLOR1;

PixelShaderOutput PixelShaderFunction(VertexShaderOutput input)
{  PixelShaderOutput output;    //The first rendertarget is red!  output.Color0 = float4(1, 0, 0, 0);  //The second rendertarget is blue!  output.Color1 = float4(0, 0, 1, 0);  return output;

technique Technique1
{  pass Pass1  {   VertexShader = compile vs_4_0 VertexShaderFunction();   PixelShader = compile ps_4_0 PixelShaderFunction();  }

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s