]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fix glsl model lighting on unlit maps (normal vector was calculated as (0,0,0) as...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 7 May 2007 18:23:22 +0000 (18:23 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 7 May 2007 18:23:22 +0000 (18:23 +0000)
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

gl_rmain.c

index cda8dfcf25eaeb44dfc23a40f0bc195d6b4ea621..6d010a612ed0ff92b86e49cf2e6baa0dfdd60610 100644 (file)
@@ -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;