4

How to enable the Anti-Aliasing using MonoGame to DrawUserPrimitives?

I've saw this other question: Drawing Bezier curves in MonoGame (XNA) produces scratchy lines

But the code isn't enabling the Anti-Alias.

I've setup a sample application here: https://github.com/viniciusjarina/PrimitiveDraw/blob/master/Game1.cs#L95

Even using graphics.PreferMultiSampling = true;

This is the output:

enter image description here

Vinicius Jarina
  • 797
  • 5
  • 16
  • Just a note. Your exact code changing the OpenGL MG DLL for the DirectX MG DLL makes the antialiasing work. Whatever the problem is it's affecting MG OpenGL version only. – KakCAT Jul 19 '19 at 11:07
  • @KakCATI need to use DesktopGL since the idea is to do a Windows/Mac version even on Mac + OpenGL is still not smooth. I will try the DX MG later. Thank you. – Vinicius Jarina Jul 19 '19 at 15:01
  • I supposed you were using GL for that reason :) I just wanted to make that note because for developers it's important to specify the version the problem appears on. Both GL and DX should give the same results, but they're not there yet. My bet is it's a bug on GL's side or just unimplemented. – KakCAT Jul 19 '19 at 16:28
  • 1
    I found this issue: https://github.com/MonoGame/MonoGame/issues/6199 , however there's no "official answer" about that being a bug or unimplemented. – KakCAT Jul 19 '19 at 16:29

1 Answers1

-2

Edited: This answer only covers how to make the code in the linked question actually work. I couldn't enable AA.

You'll need to set the culling to clockwise.

        GraphicsDevice.RasterizerState = new RasterizerState
        {
            CullMode = CullMode.CullClockwiseFace
        };

If that messes up your other primitives, you can simply reverse the order of the paths from

            path.Add(new VertexPositionColor(new Vector3(curvePoints[x] + normal * curveWidth, 0), Color.Firebrick));
            path.Add(new VertexPositionColor(new Vector3(curvePoints[x] + normal * -curveWidth, 0), Color.Firebrick));

to

            path.Add(new VertexPositionColor(new Vector3(curvePoints[x] + normal * -curveWidth, 0), Color.Firebrick));
            path.Add(new VertexPositionColor(new Vector3(curvePoints[x] + normal * curveWidth, 0), Color.Firebrick));

I'm using VertexPositionColor because I want a different color.

live627
  • 397
  • 4
  • 18