如果我这样做,我会收到一个正常绘制的模型:
GraphicsDevice.Clear(Color.Black);
GraphicsDevice.BlendState = BlendState.Opaque;
GraphicsDevice.DepthStencilState = DepthStencilState.Default;
DrawModel(model, modelMatrix, transforms);
但是,如果我尝试使用渲染目标,即使没有应用效果,结果也会非常模糊:
GraphicsDevice.SetRenderTarget(scene);
GraphicsDevice.Clear(Color.Black);
GraphicsDevice.BlendState = BlendState.Opaque;
GraphicsDevice.DepthStencilState = DepthStencilState.Default;
DrawModel(model, modelMatrix, transforms);
GraphicsDevice.SetRenderTarget(null);
spriteBatch.Begin();
spriteBatch.Draw(scene, new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height), Color.White);
spriteBatch.End();
唯一的区别是使用渲染目标。 Here is a picture左侧是普通图形,右侧是渲染目标图形。这是渲染目标的定义方式:
scene = new RenderTarget2D(GraphicsDevice, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, false, SurfaceFormat.Color, DepthFormat.None);
我也尝试过这样定义:
scene = new RenderTarget2D(device, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, false, device.DisplayMode.Format, DepthFormat.Depth24, 0, RenderTargetUsage.PlatformContents);
我在这里做错了什么?
答案 0 :(得分:1)
确保使用与BackBuffer相同的设置。
您需要注意许多选项 - 但我记得在使用RenderTarget2D时遇到问题。
尝试使用它(我使用它,它对我来说很好):
new RenderTarget2D(GraphicsDevice, pixelWidth, pixelHeight, false, SurfaceFormat.Bgr565, DepthFormat.Depth24Stencil8);