Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

1 Answer 1

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. –  Boreal 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? –  Boreal Apr 20 '12 at 19:14
    
Try to use this tool: create.msdn.com/en-US/education/catalog/utility/… –  Vodáček Apr 20 '12 at 19:19
1  
@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. –  Jonathan Hobbs Apr 21 '12 at 0:26

Your Answer

 
discard

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.