如果我这样做,我会收到一个正常绘制的模型:
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();唯一的区别是渲染目标的使用。这是一张照片,左侧为普通绘图,右侧为呈现目标。以下是如何定义呈现目标:
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);我在这里做错了什么?
发布于 2013-09-05 18:01:16
确保您使用的设置与BackBuffer相同。
您需要注意许多选项--但我不记得我在使用RenderTarget2D时遇到过问题。
试着使用这个(这是我所用的,对我来说很好):
new RenderTarget2D(GraphicsDevice, pixelWidth, pixelHeight, false, SurfaceFormat.Bgr565, DepthFormat.Depth24Stencil8); https://stackoverflow.com/questions/18637092
复制相似问题