<blockquote>
  <p>If I blur the whole image and apply the result on the sphere, the white background will bleed onto the sphere shape and I want to avoid that. I also don't want that the blue (3) and yellow (4) sphere merges with the red (1) and green (2) ones. But I would like that the green and red ones merges. Again This could be done using the depth but if you have more precision about how to do it it would be interesting.</p>
</blockquote>

<p>You will need to blurr in multiple passes to achieve this:
once for the blue and once for the yellow, as well as once for the red and green (together). That is: you need to render to texture, you need three textures in this instance to render to, you need to blur the individual textures and then combine them in another render pass.
If you know beforehand that the green and red spheres may blur together, you can just hardcode it, otherwise you need to come up with a way of determining, which spheres may blur together, and group your spheres to render into the same texture.</p>

<p>If you do this, keep in mind that for combining the three individual blurred textures, you need z-values for correct visibility determination.</p>

<blockquote>
  <p>I would like to blur the content of those 4 spheres using the same offset no mater their position. If I apply the same blur on all objects, far object's content will appear more blurry than ones on the foreground and I want to avoid that. I think that the depth make could help but any precision would help me.</p>
</blockquote>

<p>Yes, you can scale your blur filter with a depth value (where you should "invert" the value to make the blurriness scale to larger effects on closer proximities, i.e. smaller depths). For a box filter, you take ratios of the pixels neighbourhoods, but you need to make sure that those ratios add up to one. For this, you'd ideally increase the ratio for the center pixel based on the proximity and reduce the ratio for the neighbouring pixels accordingly.</p>

<blockquote>
  <p>performances and quality : Kawase blur, Box blur and two pass Gaussian blur.</p>
</blockquote>

<p>As to performance, I can't say anything about the three. As to quality, the Box Filter is rather simple, but that doesn't mean it doesn't suffice for your specific need. Just test them against each other.</p>

CC BY-SA 3.0
2017-12-26T23:15:24.340Z
To blur the different sphere separately, I decided to do it the same way is done in screen space subsurface scattering. I am using depth to calculate the difference between the basic depth and the blurred depth. If the difference is to high, I just don't apply blur.
MaT
CC BY-SA 3.0
2017-12-19T10:45:50.210Z
2017-12-19T10:45:50.210Z
Tare
<p>I am working on a specific blur effect that implies several behaviours. But before I would like to know what you think about those blurring algorithms according to performances and quality :
<strong>Kawase blur</strong>, <strong>Box blur</strong> and <strong>two pass Gaussian blur</strong>.</p>

<p>Next are the effects I am currently working on and I would be glad to have your thoughts on those on the proper way to achieve this. Here is a schematic view followed by my questions.</p>

<p><a href="https://i.sstatic.net/eCwIX.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/eCwIX.jpg" alt="enter image description here"></a></p>

<ol>
<li>I would like to blur the content of those 4 spheres using the same offset no mater their position. If I apply the same blur on all objects, far object's content will appear more blurry than ones on the foreground and I want to avoid that. I think that the depth make could help but any precision would help me.</li>
<li>If I blur the whole image and apply the result on the sphere, the white background will bleed onto the sphere shape and I want to avoid that. I also don't want that the blue (3) and yellow (4) sphere merges with the red (1) and green (2) ones. But I would like that the green and red ones merges. Again This could be done using the depth but if you have more precision about how to do it it would be interesting.</li>
</ol>

<p>Any ideas about those questions would be helpful.</p>

<p>Thanks a lot.</p>

CC BY-SA 3.0
2017-12-19T17:01:07.867Z
Regarding the background mixing with your objects during the blur, my recommendation would be to not render on white, but to render on transparent black. When doing the blur, you should blur using pre-multiplied alpha.  That will make the result such that you can apply it to any background color (using standard alpha blending) and it will look correct.  More information here: https://stackoverflow.com/questions/4854839/how-to-use-pre-multiplied-during-image-convolution-to-solve-alpha-bleed-problem
Alan Wolfe
<rendering><shader><gaussian-blur><blur><depth-map>
Questions about Blur effect
MaT
# Questions about Blur effect

(Asked by: username_0 on 2017-12-19)

I am working on a specific blur effect that implies several behaviours. But before I would like to know what you think about those blurring algorithms according to performances and quality :
**Kawase blur**, **Box blur** and **two pass Gaussian blur**.

Next are the effects I am currently working on and I would be glad to have your thoughts on those on the proper way to achieve this. Here is a schematic view followed by my questions.

[![enter image description here](https://i.sstatic.net/eCwIX.jpg)](https://i.sstatic.net/eCwIX.jpg)

1. I would like to blur the content of those 4 spheres using the same offset no mater their position. If I apply the same blur on all objects, far object's content will appear more blurry than ones on the foreground and I want to avoid that. I think that the depth make could help but any precision would help me.
2. If I blur the whole image and apply the result on the sphere, the white background will bleed onto the sphere shape and I want to avoid that. I also don't want that the blue (3) and yellow (4) sphere merges with the red (1) and green (2) ones. But I would like that the green and red ones merges. Again This could be done using the depth but if you have more precision about how to do it it would be interesting.

Any ideas about those questions would be helpful.

Thanks a lot.

**Tags:** rendering, shader, gaussian-blur, blur, depth-map

> **Comments:**
> **username_1**: Regarding the background mixing with your objects during the blur, my recommendation would be to not render on white, but to render on transparent black. When doing the blur, you should blur using pre-multiplied alpha.  That will make the result such that you can apply it to any background color (using standard alpha blending) and it will look correct.  More information here: https://stackoverflow.com/questions/4854839/how-to-use-pre-multiplied-during-image-convolution-to-solve-alpha-bleed-problem  

---

## 1 answers

### Answer by username_2 on 2017-12-19. Score: 2 | Accepted answer

> If I blur the whole image and apply the result on the sphere, the white background will bleed onto the sphere shape and I want to avoid that. I also don't want that the blue (3) and yellow (4) sphere merges with the red (1) and green (2) ones. But I would like that the green and red ones merges. Again This could be done using the depth but if you have more precision about how to do it it would be interesting.

You will need to blurr in multiple passes to achieve this:
once for the blue and once for the yellow, as well as once for the red and green (together). That is: you need to render to texture, you need three textures in this instance to render to, you need to blur the individual textures and then combine them in another render pass.
If you know beforehand that the green and red spheres may blur together, you can just hardcode it, otherwise you need to come up with a way of determining, which spheres may blur together, and group your spheres to render into the same texture.

If you do this, keep in mind that for combining the three individual blurred textures, you need z-values for correct visibility determination.

> I would like to blur the content of those 4 spheres using the same offset no mater their position. If I apply the same blur on all objects, far object's content will appear more blurry than ones on the foreground and I want to avoid that. I think that the depth make could help but any precision would help me.

Yes, you can scale your blur filter with a depth value (where you should "invert" the value to make the blurriness scale to larger effects on closer proximities, i.e. smaller depths). For a box filter, you take ratios of the pixels neighbourhoods, but you need to make sure that those ratios add up to one. For this, you'd ideally increase the ratio for the center pixel based on the proximity and reduce the ratio for the neighbouring pixels accordingly.

> performances and quality : Kawase blur, Box blur and two pass Gaussian blur.

As to performance, I can't say anything about the three. As to quality, the Box Filter is rather simple, but that doesn't mean it doesn't suffice for your specific need. Just test them against each other.

> **Comments:**
> **username_0**: To blur the different sphere separately, I decided to do it the same way is done in screen space subsurface scattering. I am using depth to calculate the difference between the basic depth and the blurred depth. If the difference is to high, I just don't apply blur.  

---

