Skip to content
Snippets Groups Projects
Commit 34d3f94d authored by Geenz Linden's avatar Geenz Linden
Browse files

Fix for SSAO not behaving properly.

SL-18662
parent ade79bc6
No related branches found
No related tags found
No related merge requests found
Showing
with 15 additions and 15 deletions
...@@ -50,7 +50,7 @@ float getDepthAo(vec2 pos_screen) ...@@ -50,7 +50,7 @@ float getDepthAo(vec2 pos_screen)
vec4 getPositionAo(vec2 pos_screen) vec4 getPositionAo(vec2 pos_screen)
{ {
float depth = getDepthAo(pos_screen); float depth = getDepthAo(pos_screen);
vec2 sc = (pos_screen); vec2 sc = getScreenCoordinateAo(pos_screen);
vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
vec4 pos = inv_proj * ndc; vec4 pos = inv_proj * ndc;
pos /= pos.w; pos /= pos.w;
...@@ -71,7 +71,7 @@ vec2 getKern(int i) ...@@ -71,7 +71,7 @@ vec2 getKern(int i)
kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875; kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000; kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000;
return kern[i]; return kern[i] / screen_res;
} }
//calculate decreases in ambient lighting when crowded out (SSAO) //calculate decreases in ambient lighting when crowded out (SSAO)
...@@ -79,8 +79,8 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm, vec2 pos_screen) ...@@ -79,8 +79,8 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm, vec2 pos_screen)
{ {
float ret = 1.0; float ret = 1.0;
vec3 pos_world = pos.xyz; vec3 pos_world = pos.xyz;
vec2 noise_reflect = texture2D(noiseMap, pos_screen.xy).xy; vec2 noise_reflect = texture2D(noiseMap, pos_screen.xy * (screen_res / 128)).xy;
float angle_hidden = 0.0; float angle_hidden = 0.0;
float points = 0; float points = 0;
...@@ -91,7 +91,7 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm, vec2 pos_screen) ...@@ -91,7 +91,7 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm, vec2 pos_screen)
{ {
vec2 samppos_screen = pos_screen + scale * reflect(getKern(i), noise_reflect); vec2 samppos_screen = pos_screen + scale * reflect(getKern(i), noise_reflect);
vec3 samppos_world = getPositionAo(samppos_screen).xyz; vec3 samppos_world = getPositionAo(samppos_screen).xyz;
vec3 diff = pos_world - samppos_world; vec3 diff = pos_world - samppos_world;
float dist2 = dot(diff, diff); float dist2 = dot(diff, diff);
......
...@@ -76,7 +76,7 @@ void main() ...@@ -76,7 +76,7 @@ void main()
vec4 spec = texture2D(specularRect, frag.xy); vec4 spec = texture2D(specularRect, frag.xy);
vec3 diff = texture2D(diffuseRect, frag.xy).rgb; vec3 diff = texture2D(diffuseRect, frag.xy).rgb;
float noise = texture2D(noiseMap, frag.xy / 128.0).b; float noise = texture2D(noiseMap, frag.xy).b;
vec3 npos = normalize(-pos); vec3 npos = normalize(-pos);
// As of OSX 10.6.7 ATI Apple's crash when using a variable size loop // As of OSX 10.6.7 ATI Apple's crash when using a variable size loop
......
...@@ -172,7 +172,7 @@ void main() ...@@ -172,7 +172,7 @@ void main()
discard; discard;
} }
float noise = texture2D(noiseMap, frag.xy/128.0).b; float noise = texture2D(noiseMap, frag.xy).b;
dist_atten *= noise; dist_atten *= noise;
lv = proj_origin-pos.xyz; lv = proj_origin-pos.xyz;
......
...@@ -86,7 +86,7 @@ void main() ...@@ -86,7 +86,7 @@ void main()
lv = normalize(lv); lv = normalize(lv);
da = dot(norm, lv); da = dot(norm, lv);
float noise = texture2D(noiseMap, frag.xy/128.0).b; float noise = texture2D(noiseMap, frag.xy).b;
vec3 col = texture2D(diffuseRect, frag.xy).rgb; vec3 col = texture2D(diffuseRect, frag.xy).rgb;
......
...@@ -181,7 +181,7 @@ void main() ...@@ -181,7 +181,7 @@ void main()
vec4 spec = texture2D(specularRect, frag.xy); vec4 spec = texture2D(specularRect, frag.xy);
float noise = texture2D(noiseMap, frag.xy/128.0).b; float noise = texture2D(noiseMap, frag.xy).b;
vec3 dlit = vec3(0, 0, 0); vec3 dlit = vec3(0, 0, 0);
if (proj_tc.z > 0.0 && if (proj_tc.z > 0.0 &&
......
...@@ -195,7 +195,7 @@ void main() ...@@ -195,7 +195,7 @@ void main()
vec3 dlit = vec3(0, 0, 0); vec3 dlit = vec3(0, 0, 0);
float noise = texture2D(noiseMap, frag.xy/128.0).b; float noise = texture2D(noiseMap, frag.xy).b;
if (proj_tc.z > 0.0 && if (proj_tc.z > 0.0 &&
proj_tc.x < 1.0 && proj_tc.x < 1.0 &&
proj_tc.y < 1.0 && proj_tc.y < 1.0 &&
......
...@@ -192,7 +192,7 @@ void main() ...@@ -192,7 +192,7 @@ void main()
vec4 spec = texture2D(specularRect, frag.xy); vec4 spec = texture2D(specularRect, frag.xy);
vec3 dlit = vec3(0, 0, 0); vec3 dlit = vec3(0, 0, 0);
float noise = texture2D(noiseMap, frag.xy/128.0).b; float noise = texture2D(noiseMap, frag.xy).b;
if (proj_tc.z > 0.0 && if (proj_tc.z > 0.0 &&
proj_tc.x < 1.0 && proj_tc.x < 1.0 &&
proj_tc.y < 1.0 && proj_tc.y < 1.0 &&
......
...@@ -133,7 +133,7 @@ void main() ...@@ -133,7 +133,7 @@ void main()
else else
{ {
float noise = texture2D(noiseMap, tc/128.0).b; float noise = texture2D(noiseMap, tc).b;
diffuse = srgb_to_linear(diffuse); diffuse = srgb_to_linear(diffuse);
spec.rgb = srgb_to_linear(spec.rgb); spec.rgb = srgb_to_linear(spec.rgb);
......
...@@ -187,7 +187,7 @@ void main() ...@@ -187,7 +187,7 @@ void main()
diffuse = srgb_to_linear(diffuse); diffuse = srgb_to_linear(diffuse);
spec.rgb = srgb_to_linear(spec.rgb); spec.rgb = srgb_to_linear(spec.rgb);
float noise = texture2D(noiseMap, tc/128.0).b; float noise = texture2D(noiseMap, tc).b;
if (proj_tc.z > 0.0 && if (proj_tc.z > 0.0 &&
proj_tc.x < 1.0 && proj_tc.x < 1.0 &&
proj_tc.y < 1.0 && proj_tc.y < 1.0 &&
......
...@@ -126,7 +126,7 @@ void main() ...@@ -126,7 +126,7 @@ void main()
diffuse = srgb_to_linear(diffuse); diffuse = srgb_to_linear(diffuse);
spec.rgb = srgb_to_linear(spec.rgb); spec.rgb = srgb_to_linear(spec.rgb);
float noise = texture2D(noiseMap, tc/128.0).b; float noise = texture2D(noiseMap, tc).b;
float lit = nl * dist_atten * noise; float lit = nl * dist_atten * noise;
final_color = color.rgb*lit*diffuse; final_color = color.rgb*lit*diffuse;
......
...@@ -193,7 +193,7 @@ void main() ...@@ -193,7 +193,7 @@ void main()
diffuse = srgb_to_linear(diffuse); diffuse = srgb_to_linear(diffuse);
spec.rgb = srgb_to_linear(spec.rgb); spec.rgb = srgb_to_linear(spec.rgb);
float noise = texture2D(noiseMap, tc/128.0).b; float noise = texture2D(noiseMap, tc).b;
if (proj_tc.z > 0.0 && if (proj_tc.z > 0.0 &&
proj_tc.x < 1.0 && proj_tc.x < 1.0 &&
proj_tc.y < 1.0 && proj_tc.y < 1.0 &&
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment