1
\$\begingroup\$

I am trying to implement Exponential Shadow Maps and I've got it almost working. The part I am stuck on is the "optional" separable Gaussian blur of the depth map to give soft-looking shadows.

I am using an OpenGL Framebuffer Object attached to a temporary depth map, and I am trying to use a screen quad (two triangles) with the original depth map as an input texture. Then, I am doing the same for the second stage of the blur, with the input and output reversed. Unfortunately, this results in a depth buffer filled with 1.0 which suggests to me that nothing is being drawn.

In this example code I've found, they are using a color and depth attachment in order to draw to a screen quad with a blur shader. (unfortunately the only OpenGL example I could find)

I want to know if this is necessary or that they are only attaching and blurring the color buffer because they are storing their depth values in it.

In other words, I would like to know if it is actually possible to only use a depth buffer Framebuffer Object attachment in this scenario.

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

Specifically: blurShadowMap() uses fbo2 which has only one R32F texture set as "color".

I want to know if this is necessary or that they are only attaching and blurring the color buffer because they are storing their depth values in it.

Correct; depth is encoded into a "color" and stored in the color buffer

In other words, I would like to know if it is actually possible to only use a depth buffer Framebuffer Object attachment in this scenario.

Using the hardware depth-buffer is never required and you are free to attach your "depth"-buffer as the only color target. To render correct 3D depths to the depth map, you will need a "depth" buffer (color) to store the depths, as well as the actual hardware depth buffer(float) to ensure proper culling. While blurring in 2D, the hardware depth-buffer is not required.

\$\endgroup\$
6
  • \$\begingroup\$ Actually, on closer inspection it looks like m_fbo2Id has a color attachment but no depth attachment. Weird. I appreciate that you went through that code! \$\endgroup\$
    – usm
    Feb 8, 2015 at 18:55
  • 1
    \$\begingroup\$ I just caught my typo too. Depth is being rendered as a "color". \$\endgroup\$
    – Jon
    Feb 8, 2015 at 18:55
  • \$\begingroup\$ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) indicates the hardware depth buffer is in use, but it will be discarded upon resolution. \$\endgroup\$
    – Jon
    Feb 8, 2015 at 18:58
  • \$\begingroup\$ That makes sense, as a screen quad would write it's depth and not the depth of the scene. I think I may have just realized why they use a single color channel to do the blurring. \$\endgroup\$
    – usm
    Feb 8, 2015 at 19:02
  • \$\begingroup\$ Each component in a COLOR is only 8-bits. A DEPTH uses all 4 components to equal 32-bits. \$\endgroup\$
    – Jon
    Feb 8, 2015 at 19:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .