]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
negate the dnormal instead of negating the dotproduct result
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 23 Aug 2003 08:32:29 +0000 (08:32 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 23 Aug 2003 08:32:29 +0000 (08:32 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3410 d7cf8633-e32d-0410-b094-e92efae38249

r_light.c

index bd1bf3a8e00841b28bd769a5846937432c345c53..f5bbc46f561333118754b878aa81526de81f5ae4 100644 (file)
--- a/r_light.c
+++ b/r_light.c
@@ -540,7 +540,9 @@ void R_LightModel_CalcVertexColors(const float *ambientcolor4f, const float *dif
        float color[4], v[3], dot, dist2, f, dnormal[3];
        nearlight_t *nl;
        usediffuse = DotProduct(diffusecolor, diffusecolor) > 0;
-       VectorCopy(diffusenormal, dnormal);
+       // negate the diffuse normal to avoid the need to negate the
+       // dotproduct on each vertex
+       VectorNegate(diffusenormal, dnormal);
        if (usediffuse)
                VectorNormalize(dnormal);
        // directional shading code here
@@ -551,7 +553,7 @@ void R_LightModel_CalcVertexColors(const float *ambientcolor4f, const float *dif
                // silly directional diffuse shading
                if (usediffuse)
                {
-                       dot = -DotProduct(normal3f, dnormal);
+                       dot = DotProduct(normal3f, dnormal);
                        if (dot > 0)
                                VectorMA(color, dot, diffusecolor, color);
                }