首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用RenderTarget2D会导致模糊

使用RenderTarget2D会导致模糊
EN

Stack Overflow用户
提问于 2013-09-05 13:01:32
回答 1查看 295关注 0票数 0

如果我这样做,我会收到一个正常绘制的模型:

代码语言:javascript
复制
GraphicsDevice.Clear(Color.Black);
GraphicsDevice.BlendState = BlendState.Opaque;
GraphicsDevice.DepthStencilState = DepthStencilState.Default;
DrawModel(model, modelMatrix, transforms);

但是,如果我尝试使用一个呈现目标,即使没有对其施加任何影响,结果也是非常模糊的:

代码语言:javascript
复制
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();

唯一的区别是渲染目标的使用。这是一张照片,左侧为普通绘图,右侧为呈现目标。以下是如何定义呈现目标:

代码语言:javascript
复制
scene = new RenderTarget2D(GraphicsDevice, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, false, SurfaceFormat.Color, DepthFormat.None);

我还试着用这种方式来定义它:

代码语言:javascript
复制
scene = new RenderTarget2D(device, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, false, device.DisplayMode.Format, DepthFormat.Depth24, 0, RenderTargetUsage.PlatformContents);

我在这里做错了什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-05 18:01:16

确保您使用的设置与BackBuffer相同。

您需要注意许多选项--但我不记得我在使用RenderTarget2D时遇到过问题。

试着使用这个(这是我所用的,对我来说很好):

代码语言:javascript
复制
new RenderTarget2D(GraphicsDevice, pixelWidth, pixelHeight, false, SurfaceFormat.Bgr565, DepthFormat.Depth24Stencil8); 
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18637092

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档