<p>I've implemented the convolution shadow mapping technique <a href="https://jankautz.com/publications/csmEGSR07.pdf" rel="nofollow noreferrer">(CSM)</a> and want to apply a gaussian filter to receive soft shadows.</p>
<p>The filter size of the filtered pixels is not static. With help of a summed area table I found regions (pixels) which need to be blurred more than others.</p>
<p>I know, that the gaussian kernel needs to be applied to the <span class="math-container">$b_i$</span> values (16 values in my case, because I choose <span class="math-container">$m=8$</span>).
But I don't understand how to apply them.</p>
<p>I tested it by simply using a convolution (read 5x5 surrounding pixels <span class="math-container">$b_i$</span> values) and blur them by multiplying with respect to my e.g. 5x5 gaussian kernel. But this does not lead to soft shadows. It turns out, that this leads to wider shadows. In case the gaussian kernel size is 16x16, a small shadow caster would cast a too large shadow, which is soft only at the very outside pixel.</p>
<p>At school I learned, that in fourierspace a convolution is a simple multiplication of a fourierspaced kernel. So it came into my mind to apply the gaussian kernel into fourierspace as well. But I don't know how I can do that, and would this be the correct solution to achieve wide soft shadows?</p>
<p>Some pictures of my results (Left: no blurring, right: every pixel same gaussian blur 9x9):
<a href="https://i.sstatic.net/zLT4y.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/zLT4y.png" alt="enter image description here" /></a></p>
<p>As you can see on the right image, there is only the most outer pixel line soft (maybe two pixel lines). the rest is turned into black completely. The width of the shadow is too large. I hoped to get the blurring also within the shadowed region like in this example:
<a href="https://i.sstatic.net/yDJ70.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/yDJ70.png" alt="enter image description here" /></a></p>

CC BY-SA 4.0
2022-11-11T13:35:06.663Z
Out of curiosity, why choose Convolution Shadow Maps? Generally Variance and Exponential shadow maps use less memory, perform better, and produce results that are almost as good. They also tend to be easier to implement.
pmw1234
CC BY-SA 4.0
2022-11-11T14:48:53.593Z
@pmw1234 I have switched from Variance shadow mapping to Convolution shadow mapping, because light bleeding was visible in almost every scene.
Thomas
CC BY-SA 4.0
2022-11-11T15:20:22.470Z
exponential shadow maps don't have the light bleeding issue (not exponential variance but rather exponential that is based on convolution shadow maps) It uses a single channel float32 format and doesn't require mip maps. But does require a fall back to PCF in some cases. Anyway, not suggesting you switch, just wondering the reasons. Also, is this being done on top of cascade shadow maps? For large scenes cascade shadow maps are really the way to go.
pmw1234
CC BY-SA 4.0
2022-11-11T15:37:57.363Z
yes, the cascade shadow map technique is implemented by using layered rendering... and after each pixel received the depth value, each shadow map will be analyzed by atomic add the min and max depth value. Afterwards with help of the min/max values the convolution shadow map is created, so that the depth span is optimal. Final step would be the blurring... but it is easy to change to other shadow map techniques... for example exponential shadow maps.
Thomas
CC BY-SA 4.0
2022-11-11T16:26:55.500Z
@pmw1234 can I add blur to exponential shadow maps?
Thomas
CC BY-SA 4.0
2022-11-11T16:38:25.037Z
Here is a link to the paper. It discusses how to convolve the ESM and has several direct comparisons to both CSM and PCF in terms of memory, quality and performance. https://jankautz.com/publications/esm_gi08.pdf
pmw1234
CC BY-SA 4.0
2022-11-11T16:58:34.287Z
@pmw1234 I read the paper and I saw this: "In our implementation we also use a linear depth buffer". I am using OpenGL, how can I define the depth buffer to be linear? have you implemented this algorithm?
Thomas
CC BY-SA 4.0
2022-11-11T17:14:41.387Z
The easiest way to create a linear depth buffer in opengl is to write the value you want directly into gl_FragDepth in the fragment shader. Oh, and yes I have implemented it, but haven't used it heavily as Cascade shadows maps with up to 6 cascades mapped to 1024x1024 buffers seems to always be better.
pmw1234
CC BY-SA 4.0
2022-11-13T16:17:44.583Z
@pmw1234 you are right, but cascaded shadow mapping only makes a better resolution of the shadow on visible surfaces. I would like to have soft shadows... I found this paper: https://www.google.com/url?sa=t&source=web&rct=j&url=https://jankautz.com/publications/ConvolutionSoftShadows_SIG08.pdf&ved=2ahUKEwiPiIyVx6v7AhULsKQKHfV9Cco4ChAWegQIHBAB&usg=AOvVaw04ixs8B6ui0oOAYvh1q8q6
Thomas
<shadow-mapping><blur>
Convolution shadow mapping apply filter
Thomas
# Convolution shadow mapping apply filter

(Asked by: username_0 on 2022-11-10)

I've implemented the convolution shadow mapping technique [(CSM)](https://jankautz.com/publications/csmEGSR07.pdf) and want to apply a gaussian filter to receive soft shadows.

The filter size of the filtered pixels is not static. With help of a summed area table I found regions (pixels) which need to be blurred more than others.

I know, that the gaussian kernel needs to be applied to the $b\_i$ values (16 values in my case, because I choose $m=8$).
But I don't understand how to apply them.

I tested it by simply using a convolution (read 5x5 surrounding pixels $b\_i$ values) and blur them by multiplying with respect to my e.g. 5x5 gaussian kernel. But this does not lead to soft shadows. It turns out, that this leads to wider shadows. In case the gaussian kernel size is 16x16, a small shadow caster would cast a too large shadow, which is soft only at the very outside pixel.

At school I learned, that in fourierspace a convolution is a simple multiplication of a fourierspaced kernel. So it came into my mind to apply the gaussian kernel into fourierspace as well. But I don't know how I can do that, and would this be the correct solution to achieve wide soft shadows?

Some pictures of my results (Left: no blurring, right: every pixel same gaussian blur 9x9):
[![enter image description here](https://i.sstatic.net/zLT4y.png)](https://i.sstatic.net/zLT4y.png)

As you can see on the right image, there is only the most outer pixel line soft (maybe two pixel lines). the rest is turned into black completely. The width of the shadow is too large. I hoped to get the blurring also within the shadowed region like in this example:
[![enter image description here](https://i.sstatic.net/yDJ70.png)](https://i.sstatic.net/yDJ70.png)

**Tags:** shadow-mapping, blur

> **Comments:**
> **username_1**: Out of curiosity, why choose Convolution Shadow Maps? Generally Variance and Exponential shadow maps use less memory, perform better, and produce results that are almost as good. They also tend to be easier to implement.  
> **username_0**: @username_1 I have switched from Variance shadow mapping to Convolution shadow mapping, because light bleeding was visible in almost every scene.  
> **username_1**: exponential shadow maps don't have the light bleeding issue (not exponential variance but rather exponential that is based on convolution shadow maps) It uses a single channel float32 format and doesn't require mip maps. But does require a fall back to PCF in some cases. Anyway, not suggesting you switch, just wondering the reasons. Also, is this being done on top of cascade shadow maps? For large scenes cascade shadow maps are really the way to go.  
> **username_0**: yes, the cascade shadow map technique is implemented by using layered rendering... and after each pixel received the depth value, each shadow map will be analyzed by atomic add the min and max depth value. Afterwards with help of the min/max values the convolution shadow map is created, so that the depth span is optimal. Final step would be the blurring... but it is easy to change to other shadow map techniques... for example exponential shadow maps.  
> **username_0**: @username_1 can I add blur to exponential shadow maps?  
> **username_1**: Here is a link to the paper. It discusses how to convolve the ESM and has several direct comparisons to both CSM and PCF in terms of memory, quality and performance. https://jankautz.com/publications/esm_gi08.pdf  
> **username_0**: @username_1 I read the paper and I saw this: "In our implementation we also use a linear depth buffer". I am using OpenGL, how can I define the depth buffer to be linear? have you implemented this algorithm?  
> **username_1**: The easiest way to create a linear depth buffer in opengl is to write the value you want directly into gl_FragDepth in the fragment shader. Oh, and yes I have implemented it, but haven't used it heavily as Cascade shadows maps with up to 6 cascades mapped to 1024x1024 buffers seems to always be better.  
> **username_0**: @username_1 you are right, but cascaded shadow mapping only makes a better resolution of the shadow on visible surfaces. I would like to have soft shadows... I found this paper: https://www.google.com/url?sa=t&source=web&rct=j&url=https://jankautz.com/publications/ConvolutionSoftShadows_SIG08.pdf&ved=2ahUKEwiPiIyVx6v7AhULsKQKHfV9Cco4ChAWegQIHBAB&usg=AOvVaw04ixs8B6ui0oOAYvh1q8q6  

---

## 0 answers

