Let's say I set two render targets

GraphicsDevice.SetRenderTargets(rt0, rt1);

If I call


both render targets will be cleared.

Therefore, how can I clear a render target at a specific index? For example just 'rt1' and not 'rt0'.

I would like to avoid texture baking the contents of 'rt0' to another render target and copying them back to 'rt0'. This is because PreserveContents on the XBOX 360 can only hold one render target in memory.


Is there any way just clear the color for a render target? I would like to keep the depth for depth reading.

  • \$\begingroup\$ Sorry i misread your question \$\endgroup\$
    – Kikaimaru
    Jul 22, 2012 at 15:12

1 Answer 1


To clear a specific render target you can either call SetRenderTarget() with only the one you want to clear, or use a pixel shader that outputs an opaque colour to one target and transparent to the other.

To avoid clearing depth use GraphicsDevice.Clear(ClearOptions.Target, Color.Transparent, 0.0f, 0);

  • \$\begingroup\$ I see so colour *= 1 for the target to keep its contents and *= 0 to lose the contents. How does the avoid clearing depth work what does the 0.0f parameter do? \$\endgroup\$ Jul 22, 2012 at 17:43
  • \$\begingroup\$ The MSDN documentation for GraphicsDevice.Clear() explains what the extra parameters do. In this case they do nothing since you're only clearing the colour buffer. msdn.microsoft.com/en-us/library/… \$\endgroup\$
    – Adam
    Jul 22, 2012 at 21:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .