0.9);
sum += texture2DRect(tex_ssao, nuv_rect) * coef;
denom += coef;
}
for (int i = 1; i <= 4; ++i) {
vec2 nuv = uv + o * -i;
vec2 nuv_rect = vec2(gl_TextureMatrix[0] * vec4(nuv, 1,1)).st;
vec3 norm2 = texture2DRect(tex_normals, nuv_rect).xyz;
float coef = (NUM_BLUR_SAMPLES + 1 - i) * int(dot(norm, norm2) > 0.9);
sum += texture2DRect(tex_ssao, nuv_rect) * coef;
denom += coef;
}
vec4 ssao = sum / denom;
vec4 image = texture2DRect(tex_color, uv_rect);
gl_FragColor = vec4((image*ssao).rgb ,0);
// Calculate depth of fragment;
// subtracting a proportion of far_clip to prevent small circle in center of frame at far plane
vec3 viewPos = normalize(ray) * (farDistance-farDistance*0.1) * depth;
vec4 projPos = projmat * vec4(viewPos, 1);
gl_FragDepth = finalDepth(projPos);
}
]]>