Fix for SSAO not behaving properly.

SL-18662
meow-7.2.2
Geenz Linden 2022-11-20 11:09:05 +01:00
parent ade79bc6f6
commit 34d3f94db6
11 changed files with 15 additions and 15 deletions

View File

@ -50,7 +50,7 @@ float getDepthAo(vec2 pos_screen)
vec4 getPositionAo(vec2 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 pos = inv_proj * ndc;
pos /= pos.w;
@ -71,7 +71,7 @@ vec2 getKern(int i)
kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
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)
@ -79,8 +79,8 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm, vec2 pos_screen)
{
float ret = 1.0;
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 points = 0;
@ -91,7 +91,7 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm, vec2 pos_screen)
{
vec2 samppos_screen = pos_screen + scale * reflect(getKern(i), noise_reflect);
vec3 samppos_world = getPositionAo(samppos_screen).xyz;
vec3 diff = pos_world - samppos_world;
float dist2 = dot(diff, diff);

View File

@ -76,7 +76,7 @@ void main()
vec4 spec = texture2D(specularRect, frag.xy);
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);
// As of OSX 10.6.7 ATI Apple's crash when using a variable size loop

View File

@ -172,7 +172,7 @@ void main()
discard;
}
float noise = texture2D(noiseMap, frag.xy/128.0).b;
float noise = texture2D(noiseMap, frag.xy).b;
dist_atten *= noise;
lv = proj_origin-pos.xyz;

View File

@ -86,7 +86,7 @@ void main()
lv = normalize(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;

View File

@ -181,7 +181,7 @@ void main()
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);
if (proj_tc.z > 0.0 &&

View File

@ -195,7 +195,7 @@ void main()
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 &&
proj_tc.x < 1.0 &&
proj_tc.y < 1.0 &&

View File

@ -192,7 +192,7 @@ void main()
vec4 spec = texture2D(specularRect, frag.xy);
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 &&
proj_tc.x < 1.0 &&
proj_tc.y < 1.0 &&

View File

@ -133,7 +133,7 @@ void main()
else
{
float noise = texture2D(noiseMap, tc/128.0).b;
float noise = texture2D(noiseMap, tc).b;
diffuse = srgb_to_linear(diffuse);
spec.rgb = srgb_to_linear(spec.rgb);

View File

@ -187,7 +187,7 @@ void main()
diffuse = srgb_to_linear(diffuse);
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 &&
proj_tc.x < 1.0 &&
proj_tc.y < 1.0 &&

View File

@ -126,7 +126,7 @@ void main()
diffuse = srgb_to_linear(diffuse);
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;
final_color = color.rgb*lit*diffuse;

View File

@ -193,7 +193,7 @@ void main()
diffuse = srgb_to_linear(diffuse);
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 &&
proj_tc.x < 1.0 &&
proj_tc.y < 1.0 &&