Hi all:
I’ve finished an SSAO pass to add soft shadow to my scene, but problem arises when I try to blur the visibility texture to reduce noise. I’ve followed John Chapman’s tutorial on SSAO and this is what I get for SSAO, pre-blur:
[ATTACH=CONFIG]1552[/ATTACH]
After that, All I do is a basic standard 4x4 blur, nothing fancy. However, the standard blur can produce halos around certain edges. This is what it looks like in the same scene, but post-blur:
[ATTACH=CONFIG]1553[/ATTACH]
This is what it looks like when the SSAO pass is done at full res, not up-sampled or anything like that. The shader code for my blur pass looks like this:
uniform vec2 SSAONoiseTexSize; //4x4 noise texture size, always remains as vec2(4, 4)
uniform sampler2D SSAOOcclusionTex; //visibility texture
in {
vec2 TexCoord; //texture coordinate, [0, 1]
} Fragment;
void main()
int BlurIteration = int(SSAONoiseTexSize.x) / 2;
vec2 TexelSize = 1.0f / vec2(textureSize(SSAOOcclusionTex, 0));
float Offset = 0.5f;
float SumCount = 0;
float OcclusionSum = 0.0f;
for (int I = -BlurIteration; I < BlurIteration; ++I)
{
vec2 NeighborOffset;
if (Has(Flags, SHADER_OCCLUSION_HORIZONTAL_BLUR))
NeighborOffset = vec2(float(I) + Offset, 0);
else if (Has(Flags, SHADER_OCCLUSION_VERTICAL_BLUR))
NeighborOffset = vec2(0, float(I) + Offset);
float NeighborOcclusion = texture(SSAOOcclusionTex, Fragment.TexCoord + NeighborOffset * TexelSize).r;
OcclusionSum += NeighborOcclusion;
SumCount += 1.0f;
}
if (SumCount > 0)
OcclusionSum /= SumCount;
else
OcclusionSum = 1.0f;
Output0.r = OcclusionSum;
}
Output0.r is supposed to be the visibility. 1.0f is fully visible, 0.0f is completely occluded.
I’ve been thinking about why it caused that, but I can’t wrap my head around why a 4x4 blur would do that :doh:. I’d appreciate any help, thanks in advance!