1
0
Fork 0
forked from fte/fteqw

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
This commit is contained in:
Spoike 2018-01-02 19:59:16 +00:00
parent 99f90e25fb
commit c1392378f2

View file

@ -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.