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
// 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;