From: havoc Date: Mon, 16 Aug 2004 23:51:06 +0000 (+0000) Subject: fixed normalmap handling (my vectors were backwards), and corrected normalmap generat... X-Git-Tag: xonotic-v0.1.0preview~5744 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f17bd2cd61289ccb751faeea3d246b2890b1b11d;p=xonotic%2Fdarkplaces.git fixed normalmap handling (my vectors were backwards), and corrected normalmap generator accordingly git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4333 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/image.c b/image.c index 6b5dd6a1..8b150c40 100644 --- 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); /* diff --git a/model_shared.c b/model_shared.c index 1fe8aa3a..2d8601a1 100644 --- a/model_shared.c +++ b/model_shared.c @@ -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) {