(C#) XNA 4.0 StencilBuffer 访问

发布于 2024-12-27 04:41:13 字数 258 浏览 3 评论 0 原文

当我在绘图操作期间使用 StencilBuffer 来渲染目标时,有什么方法可以在调试过程中看到模板缓冲区包含的内容吗?我现在正在搜索几个小时,要么我错过了一些完全明显的东西,要么我找不到查找此表的方法。

XNA 3.1 中的 GraphicsDevice 中有一个属性 DepthStencilBuffer,但它不再存在了。现在我们告诉在创建渲染目标时是否要使用模板缓冲区,是的,但是之后如何访问模板缓冲区,以便我可以查看模板缓冲区中是否有我期望的值?

干杯 卢卡斯

When I'm using StencilBuffer during drawing operations to render targets, is there any way I can see during debugging what the stencil buffer contains? I'm searching for hours now, and either I'm missing something totaly obvious, I can't find a way to look this table up.

There was a property DepthStencilBuffer in the GraphicsDevice in XNA 3.1, but it's not there anymore. Now we tell if we want to use stencil Buffer when we create Render Targets, yes, but how can I access the Stencil Buffer after that, so I can see if I have values in Stencil Buffer that I expect?

cheers
Lucas

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

魂牵梦绕锁你心扉 2025-01-03 04:41:13

我通常会对此发表评论,但我还没有足够的代表...

我建议阅读此页面:http://blogs.msdn.com/b/shawnhar/archive/2010/03/26/rendertarget-changes-in-xna-game-studio-4-0.aspx

肖恩Hargreaves 解释说,模板缓冲区的用途微不足道,可以使用产生类似性能的其他技术来完成。

该页面的引用之一:

问题:

对于深度缓冲区,以下情况如何:

1) 深度预通道 + 颜色通道法线

2)其他东西...(例如AO)

3) 使用之前的深度缓冲区和新的渲染目标渲染实体对象。 (也可以读取诸如 AO 之类的内容)

4)再次使用深度缓冲区进行另一遍(例如体积雾)

答案:

新 API 的最大限制是您无法在多个不同的渲染目标之间共享单个深度缓冲区。然而,通常可以通过安排一些事情来实现这种渲染架构(无论如何在 Windows 上),以便任何时候您想要重用深度缓冲区时,您都可以绘制到相同的渲染目标。

例如,使用深度/模板剔除光体积的经典延迟着色优化是完全可行的:您只需要安排缓冲区操作,以便这些光累积通道完成到绑定在索引 # 上的相同渲染目标中0 在初始场景渲染期间。

I would leave a comment for this normally, but I don't have enough rep for it yet...

I would recommend reading through this page: http://blogs.msdn.com/b/shawnhar/archive/2010/03/26/rendertarget-changes-in-xna-game-studio-4-0.aspx

Shawn Hargreaves explains that the uses for Stencil Buffers are insignificant and can be done using other techniques that yield similar performance.

One of the quotes from that page:

Question:

For depth buffers, what about situation such as:

1) Depth pre pass + normalss to colour channel

2) other stuff... (eg AO)

3) render solid objects using depth buffer from before and a new render target. (also reads things like AO)

4) use depth buffer again for another pass(eg volume fog)

Answer:

The biggest restriction of the new API is that you cannot share a single depth buffer across multiple different rendertargets. However, it is usually possible to achieve this kind of rendering architecture (on Windows, anyway) just by arranging things so that any time you want to reuse the depth buffer, you are drawing to the same rendertarget.

For instance, the classic deferred shading optimization of using depth/stencil to cull light volumes is totally doable: you just need to arrange your buffer operations so that these light accumulation passes are done into the same rendertarget that was bound on index #0 during the initial scene rendering.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文