Fix T51216: SSAO attenuation not being scale invariant.
Unfortunately this does break compatibility in that the viewport will look a bit different depending on the settings, but the old behavior was simply not usable for higher distances.
This commit is contained in:
parent
5fa4f397c2
commit
e280c70aa9
Notes:
blender-bot
2023-02-14 07:03:49 +01:00
Referenced by issue #51216, SSAO doesn't scale gracefully
|
@ -798,7 +798,9 @@ bool GPU_fx_do_composite_pass(
|
|||
ssao_shader = GPU_shader_get_builtin_fx_shader(GPU_SHADER_FX_SSAO, is_persp);
|
||||
if (ssao_shader) {
|
||||
const GPUSSAOSettings *fx_ssao = fx->settings.ssao;
|
||||
float ssao_params[4] = {fx_ssao->distance_max, fx_ssao->factor, fx_ssao->attenuation, 0.0f};
|
||||
/* adjust attenuation to be scale invariant */
|
||||
float attenuation = fx_ssao->attenuation / (fx_ssao->distance_max * fx_ssao->distance_max);
|
||||
float ssao_params[4] = {fx_ssao->distance_max, fx_ssao->factor, attenuation, 0.0f};
|
||||
float sample_params[3];
|
||||
|
||||
sample_params[0] = fx->ssao_sample_count_cache;
|
||||
|
|
|
@ -75,7 +75,7 @@ float calculate_ssao_factor(float depth)
|
|||
float f = dot(dir, normal);
|
||||
|
||||
/* use minor bias here to avoid self shadowing */
|
||||
if (f > 0.05 * len + 0.0001)
|
||||
if (f > 0.05 * len)
|
||||
factor += f * 1.0 / (len * (1.0 + len * len * ssao_params.z));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue