From c1392378f26bddb25fd8b867fd499f98a11062c3 Mon Sep 17 00:00:00 2001 From: Spoike Date: Tue, 2 Jan 2018 19:59:16 +0000 Subject: [PATCH] fix silly bug that allowed excessive darkening on models. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5191 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/shaders/glsl/defaultskin.glsl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/engine/shaders/glsl/defaultskin.glsl b/engine/shaders/glsl/defaultskin.glsl index 1f72c445c..b8b5b89c5 100644 --- a/engine/shaders/glsl/defaultskin.glsl +++ b/engine/shaders/glsl/defaultskin.glsl @@ -72,7 +72,9 @@ void main () float d = dot(n,e_light_dir); if (d < 0.0) //vertex shader. this might get ugly, but I don't really want to make it per vertex. d = 0.0; //this avoids the dark side going below the ambient level. - light = e_light_ambient + (dot(n,e_light_dir)*e_light_mul); + light = e_light_ambient + (d*e_light_mul); + +//FIXME: Software rendering imitation should possibly push out normals by half a pixel or something to approximate software's over-estimation of distant model sizes (small models are drawn using JUST their verticies using the nearest pixel, which results in larger meshes) #ifdef TESS normal = n; @@ -236,7 +238,7 @@ void main () //FIXME: with this extra flag, half the permutations are redundant. lightlev *= 0.5; //counter the fact that the colourmap contains overbright values and logically ranges from 0 to 2 intead of to 1. float pal = texture2D(s_paletted, tc).r; //the palette index. hopefully not interpolated. - lightlev -= 1.0 / 128.0; //software rendering appears to round down, so make sure we favour the lower values instead of rounding to the nearest +// lightlev -= 1.0 / 128.0; //software rendering appears to round down, so make sure we favour the lower values instead of rounding to the nearest col.r = texture2D(s_colourmap, vec2(pal, 1.0-lightlev.r)).r; //do 3 lookups. this is to cope with lit files, would be a waste to not support those. col.g = texture2D(s_colourmap, vec2(pal, 1.0-lightlev.g)).g; //its not very softwarey, but re-palettizing is ugly. col.b = texture2D(s_colourmap, vec2(pal, 1.0-lightlev.b)).b; //without lits, it should be identical.