1
votes

I'm using an FBO with color, depth, and stencil attached to implement deferred shading.

Here is what I'm doing:

  1. I create an FBO with color, depth, and stencil attached, then render to it
  2. I blit the stencil to the back buffer's stencil buffer
  3. I render the final pass (using stencil tests)

Is there a way I can avoid step #2?

That is, can I just "reuse" the same stencil from step #1 in step #3 directly? I tried creating a 2nd FBO with only a stencil attached, but that didn't work -- I assume b/c attaching an FBO disables all writes to the color back buffer.

1

1 Answers

1
votes

Unfortuately, the way the GL API implements FBOs enforces this exrta blit step, although most real-world HW could probably do without it. It would have been better IMHO if they would not have made this special FBO 0 for the default buffer, but just special renderbuffers for the default color, depth and stencil buffers, so that once can mix them in an FBO (I think D3D allows this, but I'm not sure). But currently, I'm not aware of any GL feature/extension which would allow such a thing.