2

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.

Matt Fichman
  • 5,458
  • 4
  • 39
  • 59

3 Answers3

2

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.

Matt Fichman
  • 5,458
  • 4
  • 39
  • 59
1

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

Blindy
  • 65,249
  • 10
  • 91
  • 131
0

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

Goz
  • 61,365
  • 24
  • 124
  • 204