Skip to content
Snippets Groups Projects
Commit e833e7ad authored by David Parks's avatar David Parks
Browse files

CTS-54 Fix for SSAO artifacts far away.

parent 512a5736
Branches
Tags
No related merge requests found
...@@ -52,6 +52,12 @@ vec4 getPosition(vec2 pos_screen) ...@@ -52,6 +52,12 @@ vec4 getPosition(vec2 pos_screen)
//calculate decreases in ambient lighting when crowded out (SSAO) //calculate decreases in ambient lighting when crowded out (SSAO)
float calcAmbientOcclusion(vec4 pos, vec3 norm) float calcAmbientOcclusion(vec4 pos, vec3 norm)
{
float ret = 1.0;
float dist = dot(pos.xyz,pos.xyz);
if (dist < 64.0*64.0)
{ {
vec2 kern[8]; vec2 kern[8];
// exponentially (^2) distant occlusion samples spread around origin // exponentially (^2) distant occlusion samples spread around origin
...@@ -97,7 +103,11 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm) ...@@ -97,7 +103,11 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm)
angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0); angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0);
return (1.0 - (float(points != 0) * angle_hidden)); ret = (1.0 - (float(points != 0) * angle_hidden));
ret += max((dist-32.0*32.0)/(32.0*32.0), 0.0);
}
return min(ret, 1.0);
} }
void main() void main()
......
...@@ -54,6 +54,12 @@ vec4 getPosition(vec2 pos_screen) ...@@ -54,6 +54,12 @@ vec4 getPosition(vec2 pos_screen)
//calculate decreases in ambient lighting when crowded out (SSAO) //calculate decreases in ambient lighting when crowded out (SSAO)
float calcAmbientOcclusion(vec4 pos, vec3 norm) float calcAmbientOcclusion(vec4 pos, vec3 norm)
{
float ret = 1.0;
float dist = dot(pos.xyz,pos.xyz);
if (dist < 64.0*64.0)
{ {
vec2 kern[8]; vec2 kern[8];
// exponentially (^2) distant occlusion samples spread around origin // exponentially (^2) distant occlusion samples spread around origin
...@@ -99,7 +105,11 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm) ...@@ -99,7 +105,11 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm)
angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0); angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0);
return (1.0 - (float(points != 0) * angle_hidden)); ret = (1.0 - (float(points != 0) * angle_hidden));
ret += max((dist-32.0*32.0)/(32.0*32.0), 0.0);
}
return min(ret, 1.0);
} }
float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl) float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment