From: divverent Date: Mon, 7 May 2007 18:23:22 +0000 (+0000) Subject: fix glsl model lighting on unlit maps (normal vector was calculated as (0,0,0) as... X-Git-Tag: xonotic-v0.1.0preview~3199 X-Git-Url: https://de.git.xonotic.org/?a=commitdiff_plain;h=22e8d3384e857accf847d37b3516645a5ce0c058;p=xonotic%2Fdarkplaces.git fix glsl model lighting on unlit maps (normal vector was calculated as (0,0,0) as there was no contribution from the map -> GLSL calls normalize() on that -> (nan,nan,nan), which apparently counts as black). The fix replaces these zero normal vectors by (0,0,1) (which vector is actually chosen does not matter, as its contribution is scaled by zero anyway). git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7248 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/gl_rmain.c b/gl_rmain.c index cda8dfcf..6d010a61 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -1686,7 +1686,14 @@ static void R_UpdateEntityLighting(entity_render_t *ent) // move the light direction into modelspace coordinates for lighting code Matrix4x4_Transform3x3(&ent->inversematrix, tempdiffusenormal, ent->modellight_lightdir); - VectorNormalize(ent->modellight_lightdir); + if(VectorLength2(ent->modellight_lightdir) > 0) + { + VectorNormalize(ent->modellight_lightdir); + } + else + { + VectorSet(ent->modellight_lightdir, 0, 0, 1); // have to set SOME valid vector here + } // scale ambient and directional light contributions according to rendering variables ent->modellight_ambient[0] *= ent->colormod[0] * r_refdef.lightmapintensity;