[Bf-blender-cvs] [e280c70aa94] master: Fix T51216: SSAO attenuation not being scale invariant.

Brecht Van Lommel noreply at git.blender.org
Sat Apr 15 00:46:29 CEST 2017


Commit: e280c70aa942829e7bfbd403fbb971a3c4502821
Author: Brecht Van Lommel
Date:   Sat Apr 15 00:02:55 2017 +0200
Branches: master
https://developer.blender.org/rBe280c70aa942829e7bfbd403fbb971a3c4502821

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.

===================================================================

M	source/blender/gpu/intern/gpu_compositing.c
M	source/blender/gpu/shaders/gpu_shader_fx_ssao_frag.glsl

===================================================================

diff --git a/source/blender/gpu/intern/gpu_compositing.c b/source/blender/gpu/intern/gpu_compositing.c
index 964c2b5051e..2f2a16f9e1d 100644
--- a/source/blender/gpu/intern/gpu_compositing.c
+++ b/source/blender/gpu/intern/gpu_compositing.c
@@ -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;
diff --git a/source/blender/gpu/shaders/gpu_shader_fx_ssao_frag.glsl b/source/blender/gpu/shaders/gpu_shader_fx_ssao_frag.glsl
index 50c8e255162..f19ff4ec65a 100644
--- a/source/blender/gpu/shaders/gpu_shader_fx_ssao_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_fx_ssao_frag.glsl
@@ -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));
 		}
 	}




More information about the Bf-blender-cvs mailing list