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:
- Render scene to a texture (HDR)
- Render that texture to a second texture THROUGH a brightpass shader
- 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.