# Understand Gaussian blur algorithm and determine resulting blur amount (σ) • ### Question

• Hi community,

I'm generating blurred images with different blur amounts in Unity but I don't know how much blur (spoken in absolute values or in Sigma σ) is produced.
I would like to determine the exact Sigma values (or another measure for blur amounts if there is any?) this Gaussian blur implementation produces. I halfway understand the theoretical background of the Gaussian blur but I didn't write this whole implementation by myself, so I have a hard time to understand how the Gaussian formula is applied in this implementation and how I can precisely produce a blur amount of σ = xyz. Can you help me with this?

Here are the relevant C# code lines:
```// ...
int iterations = 2;   // increase to get more blur
float interpolation = 2f;  // increase to get more blur
int kernel = 4;

var rt2 = RenderTexture.GetTemporary(source.width, source.height, 0, source.format);

for (int i = 0; i < iterations; i++)
{
float radius = (float)i * interpolation + interpolation;   // I think this is the crucial line affecting resulting Sigma value (?)

Graphics.Blit(source, rt2, blurMaterial, 1 + kernel);

// is it a last iteration? If so, then blit to destination
if (i == iterations - 1)
{
Graphics.Blit(rt2, destination, blurMaterial, 2 + kernel);
} else {
Graphics.Blit(rt2, source, blurMaterial, 2 + kernel);
}
}
RenderTexture.ReleaseTemporary(rt2);
}
// ...```
```I don't know if it is important for you but I also provide a small (and I think the only relevant) part of the shader (written in HLSL) which uses parameters of the C# script for rendering the blur on the textures.// ...
```
```output_13tap vert13Horizontal (vertexInput IN)
{
output_13tap OUT;

OUT.vertex = UnityObjectToClipPos(IN.vertex);

float2 offset1 = float2(_MainTex_TexelSize.x * _Radius * 1.41176470, 0.0);
float2 offset2 = float2(_MainTex_TexelSize.x * _Radius * 3.29411764, 0.0);
float2 offset3 = float2(_MainTex_TexelSize.x * _Radius * 5.17647058, 0.0);

#if UNITY_VERSION >= 540
#else
float2 uv = IN.uv;
#endif

OUT.texcoord = uv;
OUT.blurTexcoord.xy = uv + offset1;
OUT.blurTexcoord.zw = uv - offset1;
OUT.blurTexcoord.xy = uv + offset2;
OUT.blurTexcoord.zw = uv - offset2;
OUT.blurTexcoord.xy = uv + offset3;
OUT.blurTexcoord.zw = uv - offset3;

return OUT;
}
// Does the same again with _MainTex_TexelSize.y for vertically blurring the image
// ...```

I appreciate any kind of help very much.
Cult

• Edited by Friday, August 3, 2018 7:22 AM
Friday, August 3, 2018 7:21 AM