MRT in monogame, and depth buffer questions.

I think you’re on a good path, this looks correct. Note that your second RenderTarget doesn’t have to have a depthbuffer, for MRTs only the depthbuffer of target1 is used.

I am personally using SetRenderTargets like this

´ _renderTargetAlbedo = new RenderTarget2D(_graphicsDevice, targetWidth,
targetHeight, false, SurfaceFormat.Color, DepthFormat.Depth24, 0, RenderTargetUsage.DiscardContents);

        _renderTargetNormal = new RenderTarget2D(_graphicsDevice, targetWidth,
            targetHeight, false, SurfaceFormat.HalfVector4, DepthFormat.None, 0, RenderTargetUsage.DiscardContents);

        _renderTargetDepth = new RenderTarget2D(_graphicsDevice, targetWidth,
            targetHeight, false, SurfaceFormat.Single, DepthFormat.None, 0, RenderTargetUsage.DiscardContents);

        _renderTargetBinding[0] = new RenderTargetBinding(_renderTargetAlbedo);
        _renderTargetBinding[1] = new RenderTargetBinding(_renderTargetNormal);
        _renderTargetBinding[2] = new RenderTargetBinding(_renderTargetDepth);

SetRenderTargets(RTBinding);

I can’t tell if this helps, but it’s working well for me. If you want to see the actual implementation you can check out my Deferred Engine Playground - download deferred engine which uses MRTs.

I am pretty sure that this works the same in OpenGL.

2 Likes