diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-09-12 17:18:18 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-09-12 17:18:18 +0300 |
commit | 07e6e5edfb9fc14f4951d495871605f48d431709 (patch) | |
tree | 8d7776fb44b3de67adaaefac8953b334e766beac /source | |
parent | fc42063d1e23242f52dd92a7f81ce091c3f2e20f (diff) |
Eevee: Fix extinction of Light parallel to views.
This was a problem with orthographic views and lights without rotations. This introduce a small bias that should fix most cases.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/ltc_lib.glsl | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/ltc_lib.glsl b/source/blender/draw/engines/eevee/shaders/ltc_lib.glsl index f296eedc3ee..ffaa81c3638 100644 --- a/source/blender/draw/engines/eevee/shaders/ltc_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/ltc_lib.glsl @@ -161,9 +161,12 @@ mat3 ltc_matrix(vec4 lut) float ltc_evaluate(vec3 N, vec3 V, mat3 Minv, vec3 corners[4]) { + /* Avoid dot(N, V) == 1 in ortho mode, leading T1 normalize to fail. */ + V = normalize(V + 1e-8); + /* construct orthonormal basis around N */ vec3 T1, T2; - T1 = normalize(V - N*dot(V, N)); + T1 = normalize(V - N * dot(N, V)); T2 = cross(N, T1); /* rotate area light in (T1, T2, R) basis */ @@ -206,9 +209,12 @@ float ltc_evaluate(vec3 N, vec3 V, mat3 Minv, vec3 corners[4]) #define LTC_CIRCLE_RES 8 float ltc_evaluate_circle(vec3 N, vec3 V, mat3 Minv, vec3 p[LTC_CIRCLE_RES]) { + /* Avoid dot(N, V) == 1 in ortho mode, leading T1 normalize to fail. */ + V = normalize(V + 1e-8); + /* construct orthonormal basis around N */ vec3 T1, T2; - T1 = normalize(V - N*dot(V, N)); + T1 = normalize(V - N * dot(V, N)); T2 = cross(N, T1); /* rotate area light in (T1, T2, R) basis */ |