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.

Lets say I set 2 render targets:

device.SetRenderTargets(color, depth);

And then half my draw code only outputs color and not depth. This works fine on the PC and produces the expected results however I feel like this might be an issue on the Xbox.

Are there any issues I should be aware of when using MRT while only outputing to one render target?

share|improve this question

2 Answers 2

First of all, using a color buffer and a depth buffer isn't really MRT. That term is used when you have multiple color buffers and are sending different outputs to each.

But to answer your question, no, there should be no issue. Any render targets that are disabled by the current states will not be written to. You can turn color writes or depth writes on and off whenever you like.

The X360 GPU is really just a slightly-modified version of a certain PC GPU chipset. It's not like it's different in a fundamental enough way that enabling/disabling depth writes behaves differently.

share|improve this answer
    
Color and depth are used as MRT when the depth buffer really is a separate render target used to encode depth in a color buffer (although most of the time typically written as a single vector or red-green encoding). –  ChrisC Nov 8 '11 at 20:44

I don't think it'll be an issue on the Xbox as long as you don't accidentally clear the rendertarget before you are done with it. To be on the sure side when only writing to your color rendertarget, make sure to choose a BlendState which disables color writes to your depth rendertarget. You'll even save some bandwith/performance this way.

E.g. create a new BlendState disabling color writes to second rendertarget:

protected override void LoadContent()
{
    this._blendState = new Blendstate()
    {
        ColorWriteChannels1 = ColorWriteChannels.None,
    }
}

Then set this state before you do your draw calls only outputting to the color rendertarget (and reset afterwards):

protected override void Draw(GameTime gameTime)
{
    GraphicsDevice.SetRendertargets(color, depth);
    GraphicsDevice.BlendState = BlendState.Opaque; // .. or any other BlendState

    {.. draws to both rendertargets ..}

    GraphicsDevice.BlendState = this._blendState;

    {.. draws only to color rendertarget ..}
}
share|improve this answer

Your Answer

 
discard

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