Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to write to two render targets: one for colour and another for depth+normal (for post-processing). I have a problem, though. Both targets seem to be getting the value output by COLOR0, while the second should logically be getting the value from COLOR1. What did I do wrong?

RT Initialization:

renderTarget = new RenderTarget2D(device, gameResolution.Width, gameResolution.Height, false, graphics.PreferredBackBufferFormat, DepthFormat.Depth24);
extraTarget = new RenderTarget2D(device, gameResolution.Width, gameResolution.Height, false, SurfaceFormat.Color, DepthFormat.None);

Using RTs:

Device.SetRenderTargets(new RenderTargetBinding(renderTarget), new RenderTargetBinding(extraTarget));

Relevant HLSL:

struct Pixel
    float4 Color : COLOR0;
    float4 Extra : COLOR1;

Pixel PS(Middle input)
    Pixel output;

    // perform other shader code

    output.Color = float4(totalDiffuse * matDiffuseColor * color.rgb + totalSpecular * matSpecularColor, color.a);
    output.Extra = float4(input.Position.z / input.Position.w, clippedNormal);

    return output;
share|improve this question
up vote 0 down vote accepted

Try to set your render targets directly:

Device.SetRenderTargets(renderTarget, extraTarget);
share|improve this answer
I tried this first, but to no avail. – jmegaffin Apr 20 '12 at 18:46
Are you sure that your graphics card supports more than one render target? I think that your code is correct. – Vodáček Apr 20 '12 at 19:07
How do I check for this? – jmegaffin Apr 20 '12 at 19:14
Try to use this tool:… – Vodáček Apr 20 '12 at 19:19
@Boreal Do you think you could spare the time to say which? If you propose an edit to Vodacek's post which details the combination, you'll be able to help other people who had your same problem in the future who find this answer. – doppelgreener Apr 21 '12 at 0:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.