Monogame无色纹理

3

我找不到解决这个问题的方法:

我正在使用VertexPositionTexture创建带有纹理的矩形,并使用DrawUserPrimitives来绘制一些原始图形。

矩形是:

tmpPoint.VerticesList[0] = new VertexPositionTexture(new Vector3(-size, size, 0), new Vector2(0, 0));
tmpPoint.VerticesList[1] = new VertexPositionTexture(new Vector3(size, size, 0), new Vector2(1f, 0));
tmpPoint.VerticesList[2] = new VertexPositionTexture(new Vector3(-size, -size, 0), new Vector2(0, 1f));
tmpPoint.VerticesList[3] = new VertexPositionTexture(new Vector3(size, -size, 0), new Vector2(1f, 1f));

效果已设置:

Effect = new BasicEffect(game.GraphicsDevice) {
    VertexColorEnabled = true,
    TextureEnabled = true };
Effect.EnableDefaultLighting();

绘制方法:

public void DrawRectangle()
{
    originalBlend = game.GraphicsDevice.BlendState;
    game.GraphicsDevice.BlendState = BlendState.AlphaBlend;
    Effect.World = PointScale * PointRotation * PointTranslation;
    Effect.CurrentTechnique.Passes[0].Apply();
    game.GraphicsDevice.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleStrip, VerticesList, 0, vertexBuffer.VertexCount / 2); 0, 0, 4, 0, 2);
    game.GraphicsDevice.BlendState = originalBlend;
}

所有都很好,但是带有纹理的矩形没有颜色,只有alpha通道和黑色的渐变。它看起来像这样:enter image description here 但是纹理图片如下所示:enter image description here 当我试图移除时:
Effect.EnableDefaultLighting();
Effect.LightingEnabled = true;
VertexColorEnabled = true;

颜色已经可以使用了...

你可能会感到困惑,但在Windows 7机器上,颜色已经可以正常工作。当我在TFS中提交所有更改,并在Windows 10机器上获取最新版本时,就出现了这个问题。我还没有Windows 7机器。但是我在另一台装有Windows 7可执行文件的机器上进行了检查,没有成功...

没有问题的主机:

  • C:\Program Files (x86)\MonoGame\v3.0\Assemblies\DesktopGL路径下的DLL为3.5.1.1679

  • C:\Program Files (x86)\MSBuild\MonoGame\v3.0\Tools路径下的DLL为3.5.1.1679

  • Debug\路径下的DLL为3.5.1.1679

加载的程序集(仅列出差异):

  • mscorlib.dll 4.6.1076

  • System.Core.dll 4.6.1055.0

  • System.dll 4.6.1075.0

  • System.Drawing.dll 4.6.1068.2

  • System.Windows.Forms.dll 4.6.1055.0

在出现问题的另一台Windows 10(任何版本的Windows 7+)机器上(没有差异):

  • C:\Program Files (x86)\MonoGame\v3.0\Assemblies\DesktopGL路径下的DLL为3.5.1.1679

  • C:\Program Files (x86)\MSBuild\MonoGame\v3.0\Tools路径下的DLL为3.5.1.1679

  • Debug\路径下的DLL为3.5.1.1679

加载的程序集(仅列出差异):

  • mscorlib.dll 4.6.1080

  • System.Core.dll 4.6.1038.0

  • System.dll 4.6.1081.0

  • System.Drawing.dll 4.6.1078.0

  • System.Windows.Forms.dll 4.6.1038.0

已打开问题: https://github.com/mono/MonoGame/issues/5029

更新: 看来这只是在英特尔HD图形上无法正常工作,但在Radeon和NVidia上却可以正常工作...


发布你的代码。[mcve] - user585968
1
MickyD,谢谢。完成。 - sahap
我调查了新的行为。 - sahap
你能在绘制之前清除屏幕吗,像这样:game.GraphicsDevice.Clear(Color.Transparent); - Nejc Galof
还在NVIDIA 540M上进行了测试,结果成功,并且在Intel HD Graphics 4400上进行了测试,但没有照明效果。 - sahap
显示剩余4条评论
1个回答

0

不是说不说话才是最终答案,但要检查的一件非常重要的事情是您是否拥有英特尔图形系统的最新驱动程序版本。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接