Question

So this is a continuation of a question I asked earlier today. I've built myself some nice looking ribbon trails using XNA 3.1's DrawUserPrimitives method, essentially by expanding a polygon as motion occurs. It all looks super sleek and nice, except for one thing - anti-aliasing. I cannot for the life of me work out how to apply it.

I've set this in the game constructor:

graphics.PreferMultiSampling = true;

And I've also added this to test for the hardware:

        graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>((sender, e) =>
        {
            PresentationParameters parameters = e.GraphicsDeviceInformation.PresentationParameters;
            parameters.MultiSampleQuality = 0;

        #if XBOX
                pp.MultiSampleType = MultiSampleType.FourSamples;
                return;
        #else

            int quality;
            GraphicsAdapter adapter = e.GraphicsDeviceInformation.Adapter;
            SurfaceFormat format = adapter.CurrentDisplayMode.Format;

            if (adapter.CheckDeviceMultiSampleType(DeviceType.Hardware, format, false, MultiSampleType.FourSamples, out quality))
            {
                parameters.MultiSampleType = MultiSampleType.FourSamples;
            }
            else if (adapter.CheckDeviceMultiSampleType(DeviceType.Hardware, format, false, MultiSampleType.TwoSamples, out quality))
            {
                parameters.MultiSampleType = MultiSampleType.TwoSamples;
            }
        #endif
        });

By adding some print lines, I know my hardware can support 4 sample AA, but this all seems to make no difference. I just can't seem to get this to work.

Here's a screenshot of one of my trails with all of that code applied:

See? No AA!

I'd really appreciate some help. I looked at this a while ago for a solution to a different problem, and couldn't get it to work then, either.

Well, cheers.

Was it helpful?

Solution

Fixed this one, too!

The issue was that, while the back buffer was getting the right anti-alias settings, the render target wasn't. This meant that drawing to the render target was done without AA, but the texture that was then drawn to the back buffer was done with it. I've fixed it now.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top