From cce6c9a0856a1a32cd98cd1dbea440a193a05b42 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 24 May 2018 20:31:06 +0200 Subject: [PATCH] - fixed precision issue with dot product. Apparently the shader math is not precise enough to ensure that two supposedly orthogonal vectors are truly orthogonal, resulting in a non-zero dot product --- wadsrc/static/shaders/glsl/material_normal.fp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/static/shaders/glsl/material_normal.fp b/wadsrc/static/shaders/glsl/material_normal.fp index 6b65de6a3..d02f7504d 100644 --- a/wadsrc/static/shaders/glsl/material_normal.fp +++ b/wadsrc/static/shaders/glsl/material_normal.fp @@ -12,7 +12,7 @@ vec3 lightContribution(int i, vec3 normal) vec3 lightdir = normalize(lightpos.xyz - pixelpos.xyz); float dotprod = dot(normal, lightdir); - if (dotprod < 0.0) return vec3(0.0); // light hits from the backside. This can happen with full sector light lists and must be rejected for all cases. + if (dotprod < -0.0001) return vec3(0.0); // light hits from the backside. This can happen with full sector light lists and must be rejected for all cases. Note that this can cause precision issues. float attenuation = clamp((lightpos.w - lightdistance) / lightpos.w, 0.0, 1.0);