diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-12-17 11:54:24 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-12-17 11:54:24 +0300 |
commit | b253fe4d1b84a4cb42fcabf4fad6611034b505c2 (patch) | |
tree | 5b5bace35f425e832193e15a5a96d5019f62ab8d /source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl | |
parent | 99457dd9819b6d2f63e84ba80280fe2819e8928d (diff) |
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
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl | 17 |
1 files changed, 8 insertions, 9 deletions
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); |