Fix T62580 Workbench: Shadow glitch due to degenerate threshold

Fix by adding a threshold instead of direct null comparison.
This commit is contained in:
Clément Foucault 2019-07-09 20:38:40 +02:00
parent 29ebb37419
commit 2893417d67
Notes: blender-bot 2023-02-14 03:21:32 +01:00
Referenced by issue #62580, Blender 2.8. Shadow glitch in viewport (and same in Workbench render at once)
1 changed files with 2 additions and 1 deletions

View File

@ -37,6 +37,7 @@ in VertexData
vData[];
#define DEGENERATE_TRIS_WORKAROUND
#define DEGENERATE_TRIS_AREA_THRESHOLD 4e-17
#define len_sqr(a) dot(a, a)
@ -67,7 +68,7 @@ void main()
#ifdef DEGENERATE_TRIS_WORKAROUND
/* Check if area is null */
vec2 faces_area = vec2(len_sqr(n1), len_sqr(n2));
bvec2 degen_faces = equal(abs(faces_area), vec2(0.0));
bvec2 degen_faces = lessThan(abs(faces_area), vec2(DEGENERATE_TRIS_AREA_THRESHOLD));
/* Both triangles are degenerate, abort. */
if (all(degen_faces)) {