Direct3D 纹理后处理/复制

发布于 2024-08-07 17:38:46 字数 959 浏览 9 评论 0原文

因此,我尝试实现一些 Direct3D 后处理,但在渲染纹理时遇到问题。基本上,我的程序看起来像这样:

// Render scene to "scene_texture" (an HDR texture)...

...

device->SetRenderTarget(0, brightpass_surface);
device->SetTexture(0, scene_texture);
// Render "scene_texture" to "brightpass_texture" using full-screen quad.
// This involves passing the quad geometry through a brightpass shader.

...

device->SetRenderTarget(0, ldr_surface);
device->SetTexture(0, brightpass_texture);
// Render "brightpass_texture" to "ldr_surface" using full-screen quad...

我遗漏了一些部分,因为有相当数量的代码(我只是想了解总体思路)。不幸的是,上述结果会导致空白屏幕。这是我想要发生的事情:

  1. 将场景渲染到纹理(HDR)
  2. 通过 Brightpass 着色器将该纹理渲染到第二个纹理
  3. 将第二个纹理渲染到可见的 LDR 表面

请注意,如果我将上面的最后一行从 更改

device->SetTexture(0, brightpass_texture);

device->SetTexture(0, scene_texture);

那么一切正常。请注意,我尝试跳过 Brightpass 着色器并简单地传递像素,但这也不起作用。

So I'm trying to implement some Direct3D post-processing, and I'm having issues rendering to textures. Basically, my program looks like this:

// Render scene to "scene_texture" (an HDR texture)...

...

device->SetRenderTarget(0, brightpass_surface);
device->SetTexture(0, scene_texture);
// Render "scene_texture" to "brightpass_texture" using full-screen quad.
// This involves passing the quad geometry through a brightpass shader.

...

device->SetRenderTarget(0, ldr_surface);
device->SetTexture(0, brightpass_texture);
// Render "brightpass_texture" to "ldr_surface" using full-screen quad...

I've left out some parts b/c there is a fair amount of code (I'm just trying to get across the general idea). Unfortunately, the above results in a blank screen. Here is what I want to happen:

  1. Render scene to a texture (HDR)
  2. Render that texture to a second texture THROUGH a brightpass shader
  3. Render the second texture to the visible LDR surface

Note that if I change the last line above from

device->SetTexture(0, brightpass_texture);

to

device->SetTexture(0, scene_texture);

Then everything works. Note that I've tried skipping the brightpass shader and simply passing the pixels through, but that doesn't work either.

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

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

发布评论

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

评论(3

我不咬妳我踢妳 2024-08-14 17:38:46

问题是多重采样。在 D3DPRESENT_PARAMS 结构中,我启用了多重采样。在启用多重采样时,您无法使用“全屏四边形”技术从一个浮点纹理渲染到另一个浮点纹理。

相反,我在 HDR 场景渲染目标 (scene_texture) 中启用多重采样,并在 PRESENT_PARAMS 结构中禁用它。这很好,因为我只需要多重采样来进行场景渲染。

The problem was multisampling. In the D3DPRESENT_PARAMS structure, I had enabled multisampling. You can't render from one floating point texture into another floating point texture using the "full-screen quad" technique while multisampling is enabled.

Instead, I enabled multisampling in the HDR scene render target (scene_texture) and disabled it in the PRESENT_PARAMS structure. This is good because I only needed multisampling for the scene rendering.

漆黑的白昼 2024-08-14 17:38:46

您是否确定使用渲染到纹理标志创建了 Brightpass_texture?

Did you make sure you created the brightpass_texture with a render-to-texture flag?

最单纯的乌龟 2024-08-14 17:38:46

调试运行时是否会出现任何错误?你如何获得ldr_surface?

如果将场景直接渲染到 ldr_surface 并绕过所有 HDR 内容,会发生什么?事情可能看起来有点饱和,但它应该给你一个想法......

Does the debug runtime spew any errors out? How do you get ldr_surface?

What happens if you render your scene straight to ldr_surface and bypass all the HDR stuff? Thing will probably look a bit saturated but it should give you an idea ...

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