开发者

Direct3D Texture Post-Processing/Copying

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.


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.


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


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 ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜