[英]MonoGame: problem with rendering 3d model and spritebatch
我想在屏幕上繪制一些調試信息,但這會導致渲染模型出現問題。 我在互聯網上找到了一些解決方案,但是沒有用。 也許我太傻了,但是我不知道怎么了。 這是Draw方法:
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.DarkCyan);
spriteBatch.Begin();
player.Draw(dt);
spriteBatch.DrawString(gamefont, "render Time :" + gameTime.ElapsedGameTime.TotalSeconds, new Vector2(0, 85), Color.White);
spriteBatch.End();
effect.View = player.view;
effect.Projection = player.projection;
effect.Texture = dirtTexture;
GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp;
GraphicsDevice.BlendState = BlendState.Opaque;
GraphicsDevice.DepthStencilState = DepthStencilState.Default;
foreach (EffectPass p in effect.CurrentTechnique.Passes)
{
p.Apply();
effect.World = player.world;
GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, buffer.VertexCount / 3);
}
base.Draw(gameTime);
}
三角形法線(正面)向后繪制。 這由頂點緩沖區中頂點的順序定義。
幸運的是,我們可以在GraphicsDevice
指定順序。 只需添加以下行:
GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
如果給出相同的結果,請使用:
GraphicsDevice.RasterizerState = RasterizerState.CullClockwise;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.