uniform sampler2D depth_texture; uniform sampler2D color_texture; uniform sampler2D normal_texture; uniform float scr_w; uniform float scr_h; uniform vec3 pSphere[10] = vec3[]( vec3(-0.010735935, 0.01647018, 0.0062425877), vec3(-0.06533369, 0.3647007, -0.13746321), vec3(-0.6539235, -0.016726388, -0.53000957), vec3(0.40958285, 0.0052428036, -0.5591124), vec3(-0.1465366, 0.09899267, 0.15571679), vec3(-0.44122112, -0.5458797, 0.04912532), vec3(0.03755566, -0.10961345, -0.33040273), vec3(0.019100213, 0.29652783, 0.066237666), vec3(0.8765323, 0.011236004, 0.28265962), vec3(0.29264435, -0.40794238, 0.15964167)); varying vec2 vTexCoord; #define STRENGTH 0.09 #define FALLOFF 0.0 //0.00002 #define RAD 0.006 #define SAMPLES 10 #define INVSAMPLES 1.0/SAMPLES vec4 height_normal(in vec2 texcoord) { vec4 normaltexel; normaltexel.rgb = (texture2D(normal_texture, texcoord).xyz * 2.0) - vec3(1.0); normaltexel.a = texture2D(depth_texture, texcoord).x; return normaltexel; } void main(void) { // get a random normal vec3 fres = normalize((texture2D(color_texture, vTexCoord * (scr_w / 64)).xyz * 2.0) - vec3(1.0)); //grab depth and a normal vector vec4 currentPixelSample = height_normal(vTexCoord); vec3 samplepos = vec3(vTexCoord.xy, currentPixelSample.a); float blacklevel = 0.0; float depthDiff; vec4 occluderFragment; vec3 ray; if(length(currentPixelSample.xyz) <= 1.0) //dont calculate ssao because the pixel is in skybox { for(int i = 0; i < SAMPLES; ++i) { // trace a ray from a random normal to a random position ray = (RAD / samplepos.z) * reflect(pSphere[i], fres); occluderFragment = height_normal(samplepos.xy + (sign(dot(ray, currentPixelSample.xyz)) * ray.xy)); //get the position of the occluder depthDiff = samplepos.z - occluderFragment.a; blacklevel += step(FALLOFF, depthDiff) * (1.0 - dot(currentPixelSample.xyz, occluderFragment.xyz)) * (1.0 - smoothstep(FALLOFF, STRENGTH, depthDiff)); } } // output the result gl_FragColor = vec4(vec3(1.0 - (blacklevel * INVSAMPLES)), 1.0); }

attached is a picture of my problem the the offending pixels circled. Anyone know how to fix this?