SiliconStudio / xenko

Old repo for Xenko Game Engine. Please use https://github.com/xenko3d/xenko instead.
http://xenko.com
1.54k stars 345 forks source link

It's difficult to enable MSAA. #85

Open Gavin-Williams opened 9 years ago

Gavin-Williams commented 9 years ago

Hi,

I've been trying to get MSAA working. Now I have to apologize here, this is the first engine I've worked with. I have built my own loose engine using SharpDX so I have a reasonable understanding how that works. But using a commercial engine is new to me, so I am still learning about how everything works together. There maybe be things about Services, Renderers, EntitySystem that I'm overlooking.

Here is what I have ...

            // setup custom render target
            GraphicsDeviceManager.PreferMultiSampling = true;
            GraphicsDeviceManager.ApplyChanges();

            RenderTargetSetter rtSetter = new RenderTargetSetter(Services) { ClearColor = Color.Blue};
            TextureDescription desc = rtSetter.RenderTarget.Description;
            desc.Level = MSAALevel.X4;
            var msaaRenderTarget = Texture2D.New(GraphicsDevice, desc).ToRenderTarget();
            rtSetter.RenderTarget = msaaRenderTarget;

            //GraphicsDeviceManager.GraphicsDevice.SetRenderTargets(rtSetter.RenderTarget);

            // setup custom depth buffer
            desc = rtSetter.DepthStencil.Description;
            desc.Level = MSAALevel.X4;
            var msaaDepthBuffer = Texture2D.New(GraphicsDevice, desc).ToDepthStencilBuffer(false);
            rtSetter.DepthStencil = msaaDepthBuffer;

            // Setup the default rendering pipeline
            RenderSystem.Pipeline.Renderers.Add(rtSetter);

So I'm assuming that when a Renderer is added to the pipeline, it knows what to do with it and at some point during rendering, the engine will Set the RenderTarget from the RenderTargetSetter. I might be missing something here though, because the above code actually turns my output black, even if i take out the MSAA stuff.

xoofx commented 9 years ago

We haven't tested MSAA thoroughly, so It might not be correctly handled.