]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fixed normalmap handling (my vectors were backwards), and corrected normalmap generat...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 16 Aug 2004 23:51:06 +0000 (23:51 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 16 Aug 2004 23:51:06 +0000 (23:51 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4333 d7cf8633-e32d-0410-b094-e92efae38249

image.c
model_shared.c

diff --git a/image.c b/image.c
index 6b5dd6a1774631a11c58df6915d43abfadde81ea..8b150c40c7da6961f9c0019112d5d5cb55b9a2a5 100644 (file)
--- a/image.c
+++ b/image.c
@@ -1502,8 +1502,8 @@ void Image_HeightmapToNormalmap(const unsigned char *inpixels, unsigned char *ou
                        n[1] = dv[0][2]*dv[1][0]-dv[0][0]*dv[1][2];
                        n[2] = dv[0][0]*dv[1][1]-dv[0][1]*dv[1][0];
                        */
-                       n[0] = ((p1[0] + p1[1] + p1[2]) - (p0[0] + p0[1] + p0[2]));
-                       n[1] = ((p0[0] + p0[1] + p0[2]) - (p2[0] + p2[1] + p2[2]));
+                       n[0] = ((p0[0] + p0[1] + p0[2]) - (p1[0] + p1[1] + p1[2]));
+                       n[1] = ((p2[0] + p2[1] + p2[2]) - (p0[0] + p0[1] + p0[2]));
                        n[2] = ibumpscale;
                        VectorNormalize(n);
                        /*
index 1fe8aa3a0e6b2fc2bce968c38e075f637b269185..2d8601a1a18ba2653cb8e9cad7de90964c5a98c0 100644 (file)
@@ -626,7 +626,7 @@ void Mod_BuildBumpVectors(const float *v0, const float *v1, const float *v2, con
        f = -DotProduct(svector3f, normal3f);
        VectorMA(svector3f, f, normal3f, svector3f);
        VectorNormalize(svector3f);
-       CrossProduct(svector3f, tvector3f, tangentcross);
+       CrossProduct(tvector3f, svector3f, tangentcross);
        // if texture is mapped the wrong way (counterclockwise), the tangents have to be flipped, this is detected by calculating a normal from the two tangents, and seeing if it is opposite the surface normal
        if (DotProduct(tangentcross, normal3f) < 0)
        {