[Bf-blender-cvs] [b253fe4d1b8] blender2.8: Eevee: Change Bent normal calculation

Clément Foucault noreply at git.blender.org
Mon Dec 17 09:43:57 CET 2018


Commit: b253fe4d1b84a4cb42fcabf4fad6611034b505c2
Author: Clément Foucault
Date:   Mon Dec 17 09:54:24 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBb253fe4d1b84a4cb42fcabf4fad6611034b505c2

Eevee: Change Bent normal calculation

This changes the bent normal effect to be a bit more subtle.
I also tuned down the bent normal blending factor so mesh faceted look may
appear more in occluded regions. this is to increase the fidelity of the
indirect lighting. This blending might be a parameter in the future.

Based the calculation on "Bent Normals and Cones in Screen-space"
by O. Klehm, T. Ritschel, E. Eisemann, H.-P. Seidel

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

M	source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl

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

diff --git a/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl b/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
index 40c6bb1f1e0..4c9d04ff339 100644
--- a/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
@@ -177,12 +177,11 @@ void integrate_slice(vec3 normal, vec2 t_phi, vec2 horizons, inout float visibil
 
 	visibility += vis;
 
-	/* Finding Bent normal */
+	/* O. Klehm, T. Ritschel, E. Eisemann, H.-P. Seidel
+	 * Bent Normals and Cones in Screen-space
+	 * Sec. 3.1 : Bent normals */
 	float b_angle = (h.x + h.y) * 0.5;
-	/* The 0.5 factor below is here to equilibrate the accumulated vectors.
-	 * (sin(b_angle) * -t_phi) will accumulate to (phi_step * result_nor.xy * 0.5).
-	 * (cos(b_angle) * 0.5) will accumulate to (phi_step * result_nor.z * 0.5). */
-	bent_normal += vec3(sin(b_angle) * -t_phi, cos(b_angle) * 0.5);
+	bent_normal += vec3(sin(b_angle) * -t_phi, cos(b_angle)) * vis;
 }
 
 void gtao_deferred(
@@ -203,9 +202,9 @@ void gtao_deferred(
 	integrate_slice(normal, dirs.xy, horizons.xy, visibility, bent_normal);
 	integrate_slice(normal, dirs.zw, horizons.zw, visibility, bent_normal);
 
-	visibility *= 0.5; /* We integrated 2 slices. */
+	bent_normal = normalize(bent_normal / visibility);
 
-	bent_normal = normalize(bent_normal);
+	visibility *= 0.5; /* We integrated 2 slices. */
 }
 
 void gtao(vec3 normal, vec3 position, vec4 noise, out float visibility, out vec3 bent_normal)
@@ -222,7 +221,7 @@ void gtao(vec3 normal, vec3 position, vec4 noise, out float visibility, out vec3
 	vec2 horizons = search_horizon_sweep(dir, position, uvs, noise.y, max_dir);
 	integrate_slice(normal, dir, horizons, visibility, bent_normal);
 
-	bent_normal = normalize(bent_normal);
+	bent_normal = normalize(bent_normal / visibility);
 }
 
 /* Multibounce approximation base on surface albedo.
@@ -261,7 +260,7 @@ float occlusion_compute(vec3 N, vec3 vpos, float user_occlusion, vec4 rand, out
 
 		if ((int(aoSettings) & USE_BENT_NORMAL) != 0) {
 			/* The bent normal will show the facet look of the mesh. Try to minimize this. */
-			float mix_fac = visibility * visibility;
+			float mix_fac = visibility * visibility * visibility;
 			bent_normal = normalize(mix(bent_normal, vnor, mix_fac));
 
 			bent_normal = transform_direction(ViewMatrixInverse, bent_normal);



More information about the Bf-blender-cvs mailing list