【问题标题】:How to enable Anti-Aliasing using DrawUserPrimitive on MonoGame如何在 MonoGame 上使用 DrawUserPrimitive 启用抗锯齿
【发布时间】:2019-07-11 18:50:08
【问题描述】:

如何使用MonoGame对DrawUserPrimitives启用Anti-Aliasing?

我看到了另一个问题:Drawing Bezier curves in MonoGame (XNA) produces scratchy lines

但是代码没有启用 Anti-Alias。

我在这里设置了一个示例应用程序:https://github.com/viniciusjarina/PrimitiveDraw/blob/master/Game1.cs#L95

即使使用graphics.PreferMultiSampling = true;

这是输出:

【问题讨论】:

  • 只是一个注释。您为 DirectX MG DLL 更改 OpenGL MG DLL 的确切代码使抗锯齿工作。不管问题是什么,它只影响 MG OpenGL 版本。
  • @KakCATI 需要使用 DesktopGL,因为这个想法是在 Mac 上做一个 Windows/Mac 版本 + OpenGL 仍然不流畅。稍后我将尝试 DX MG。谢谢。
  • 我想你是因为这个原因使用 GL :) 我只是想说明一下,因为对于开发人员来说,指定问题出现的版本很重要。 GL 和 DX 都应该给出相同的结果,但它们还没有。我敢打赌,这是 GL 方面的错误,或者只是未实现。
  • 我发现了这个问题:github.com/MonoGame/MonoGame/issues/6199,但是没有关于这是一个错误或未实现的“官方答案”。

标签: xna monogame antialiasing


【解决方案1】:

已编辑:此答案仅涵盖如何使链接问题中的代码实际工作。我无法启用 AA。

您需要将剔除设置为顺时针。

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

如果这弄乱了您的其他原语,您可以简单地将路径的顺序从

            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));

            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));

我使用 VertexPositionColor 是因为我想要不同的颜色。

【讨论】:

  • 还是不行,试试开启这个应用的抗锯齿github.com/viniciusjarina/PrimitiveDraw
  • 代码正在运行 :) 并且正在画一条线,但它看起来像一个 Atari 游戏
  • 是的……真可惜我不能让 AA 工作。我现在必须重新考虑我将如何在 Monogame 中工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-08-17
  • 2014-02-18
相关资源
最近更新 更多