I'm doing shadow mapping with exponential shadow maps (ESM) in OpenGL 4.3.
This requires blurring the shadow map, which I do with a normal 2-pass gaussian blur.
What I want to do is the following:
Shadow map -> (Vertical Blur Shader) -> Intermediate Texture -> (Horizontal Blur Shader) -> Shadow Map
The shadow map is a DepthComponent32f texture and the intermediate texture uses R32f.
The first pass works fine, but for the second pass, where I want to write back to the shadow map, I can't seem to use the shadow map as a FBO color attachment, so I'm unable to write back to it.
- Is there a way to use a DepthComponent texture as a color attachment in a FBO?
- Why can I sample a texture that I'm currently writing to? Is this legal in OpenGL 4.3, or is the behavior undefined? What happens behind the scenes? Does it internally create a new texture to write to, and then discard the old one when the draw call finishes?