Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: SSAO halo artifact induced by blurring

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2017

    SSAO halo artifact induced by blurring

    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:

    Click image for larger version. 

Name:	ssao_probelm pre-blur.jpg 
Views:	134 
Size:	7.5 KB 
ID:	2472

    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:

    Click image for larger version. 

Name:	ssao_problem post-blur.jpg 
Views:	105 
Size:	6.5 KB 
ID:	2473

    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:

    Code :
    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;
                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 . I'd appreciate any help, thanks in advance!

  2. #2
    Member Regular Contributor
    Join Date
    Jul 2012
    Can you show the original image without SSAO, and also the SSAO depth-map generated ?
    Also try a more simple blur shader, I mean without your condition.
    You often have to play with the SSAO options (kernel, radius) in order to have a decent result.

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2017
    Hi Silence, thanks for your reply. Sorry that I forgot to put a closure to this thread, but I found out that doing a simple blur just tends to blur the edges as well. And when that
    blurred edge is magnified, it's easy to see that the content across the edge bleed into each other, therefore produces a halo artifact when the dark/bright color matches up on the edge.
    And you are indeed right that I need to play around with the SSAO options. I managed to set them so the halo artifact looks minimum. I was able to reduce the halo artifact
    to an unnoticeable amount by trying to preserve the edge after the blur, so I ended up doing a bilateral blur (sort of). What I did was when sampling the neighbor texels, if the
    depth of that texel is too far from the depth of the center texel, that pixel is discarded from blurring, therefore preserving the hardness of edges (sort of). It didn't work very well
    because due to discarding too many texels, the noise pattern is more pronounced. So instead of discarding the texel completely, I give them a lesser weight.
    Last edited by MonterMan; 09-12-2017 at 07:32 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts