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