From: havoc Date: Wed, 15 Jan 2003 13:09:16 +0000 (+0000) Subject: fixed bumpmapping! now looks correct X-Git-Tag: RELEASE_0_2_0_RC1~18 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ed94238a0d022888f0e309b00d1f06ecbb497907;p=xonotic%2Fdarkplaces.git fixed bumpmapping! now looks correct git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2690 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/model_shared.c b/model_shared.c index 5bec6c22..e3fa83e0 100644 --- a/model_shared.c +++ b/model_shared.c @@ -526,22 +526,24 @@ void Mod_BuildTextureVectorsAndNormals(int numverts, int numtriangles, const flo { // 4 assignments, 1 rsqrt, 2 adds, 6 multiplies VectorNormalize(normal); - sdir[0] = (vert[1][3] - vert[0][3]) * (vert[2][0] - vert[0][0]) - (vert[2][3] - vert[0][3]) * (vert[1][0] - vert[0][0]); - sdir[1] = (vert[1][3] - vert[0][3]) * (vert[2][1] - vert[0][1]) - (vert[2][3] - vert[0][3]) * (vert[1][1] - vert[0][1]); - sdir[2] = (vert[1][3] - vert[0][3]) * (vert[2][2] - vert[0][2]) - (vert[2][3] - vert[0][3]) * (vert[1][2] - vert[0][2]); + tdir[0] = ((vert[1][3] - vert[0][3]) * (vert[2][0] - vert[0][0]) - (vert[2][3] - vert[0][3]) * (vert[1][0] - vert[0][0])); + tdir[1] = ((vert[1][3] - vert[0][3]) * (vert[2][1] - vert[0][1]) - (vert[2][3] - vert[0][3]) * (vert[1][1] - vert[0][1])); + tdir[2] = ((vert[1][3] - vert[0][3]) * (vert[2][2] - vert[0][2]) - (vert[2][3] - vert[0][3]) * (vert[1][2] - vert[0][2])); // 4 assignments, 1 rsqrt, 2 adds, 6 multiplies - VectorNormalize(sdir); + VectorNormalize(tdir); // 1 assignments, 1 negates, 2 adds, 3 multiplies - f = -DotProduct(sdir, normal); + f = -DotProduct(tdir, normal); // 3 assignments, 3 adds, 3 multiplies - VectorMA(sdir, f, normal, sdir); + VectorMA(tdir, f, normal, tdir); // 4 assignments, 1 rsqrt, 2 adds, 6 multiplies - VectorNormalize(sdir); + VectorNormalize(tdir); // 3 assignments, 3 subtracts, 6 multiplies - CrossProduct(sdir, normal, tdir); + CrossProduct(tdir, normal, sdir); // this is probably not necessary // 4 assignments, 1 rsqrt, 2 adds, 6 multiplies - VectorNormalize(tdir); + VectorNormalize(sdir); + // + VectorNegate(sdir, sdir); // accumulate matrix onto verts used by triangle // 30 assignments, 27 adds for (i = 0;i < 3;i++)