From: divverent Date: Sun, 20 Jan 2013 21:11:58 +0000 (+0000) Subject: Fix typos in GPU skeletal; explain the crossproduct hack X-Git-Tag: xonotic-v0.7.0~67 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=fb938b81a66661b4c6178a4ef09d6dec65e62229;p=xonotic%2Fdarkplaces.git Fix typos in GPU skeletal; explain the crossproduct hack git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11883 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=c9f91aea3b2cb789ece619699e7f41db9b88443a --- diff --git a/gl_rmain.c b/gl_rmain.c index 7a10c491..ef397326 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -9293,9 +9293,9 @@ void RSurf_PrepareVerticesForBatch(int batchneed, int texturenumsurfaces, const if (vn) { // the normal transformation matrix is a set of cross products... - CrossProduct(m[1], m[0], n[0]); + CrossProduct(m[1], m[2], n[0]); CrossProduct(m[2], m[0], n[1]); - CrossProduct(m[0], m[1], n[2]); + CrossProduct(m[0], m[1], n[2]); // is actually transpose(inverse(m)) * det(m) VectorCopy(vn, tn); vn[0] = tn[0] * n[0][0] + tn[1] * n[0][1] + tn[2] * n[0][2]; vn[1] = tn[0] * n[1][0] + tn[1] * n[1][1] + tn[2] * n[1][2]; diff --git a/shader_glsl.h b/shader_glsl.h index ac0dd80a..cc0f88b1 100644 --- a/shader_glsl.h +++ b/shader_glsl.h @@ -572,7 +572,7 @@ " vec4 SkeletalMatrix2 = Skeletal_Transform12[si1.x] * sw.x + Skeletal_Transform12[si1.y] * sw.y + Skeletal_Transform12[si1.z] * sw.z + Skeletal_Transform12[si1.w] * sw.w;\n" " vec4 SkeletalMatrix3 = Skeletal_Transform12[si2.x] * sw.x + Skeletal_Transform12[si2.y] * sw.y + Skeletal_Transform12[si2.z] * sw.z + Skeletal_Transform12[si2.w] * sw.w;\n" " mat4 SkeletalMatrix = mat4(SkeletalMatrix1, SkeletalMatrix2, SkeletalMatrix3, vec4(0.0, 0.0, 0.0, 1.0));\n" -" mat3 SkeletalNormalMatrix = mat3(cross(SkeletalMatrix[1].xyz, SkeletalMatrix[0].xyz), cross(SkeletalMatrix[2].xyz, SkeletalMatrix[0].xyz), cross(SkeletalMatrix[0].xyz, SkeletalMatrix[1].xyz));\n" +" mat3 SkeletalNormalMatrix = mat3(cross(SkeletalMatrix[1].xyz, SkeletalMatrix[2].xyz), cross(SkeletalMatrix[2].xyz, SkeletalMatrix[0].xyz), cross(SkeletalMatrix[0].xyz, SkeletalMatrix[1].xyz)); // is actually transpose(inverse(mat3(SkeletalMatrix))) * det(mat3(SkeletalMatrix))\n" " vec4 SkeletalVertex = Attrib_Position * SkeletalMatrix;\n" " vec3 SkeletalSVector = normalize(Attrib_TexCoord1.xyz * SkeletalNormalMatrix);\n" " vec3 SkeletalTVector = normalize(Attrib_TexCoord2.xyz * SkeletalNormalMatrix);\n" @@ -1070,7 +1070,7 @@ " vec4 SkeletalMatrix2 = Skeletal_Transform12[si1.x] * sw.x + Skeletal_Transform12[si1.y] * sw.y + Skeletal_Transform12[si1.z] * sw.z + Skeletal_Transform12[si1.w] * sw.w;\n" " vec4 SkeletalMatrix3 = Skeletal_Transform12[si2.x] * sw.x + Skeletal_Transform12[si2.y] * sw.y + Skeletal_Transform12[si2.z] * sw.z + Skeletal_Transform12[si2.w] * sw.w;\n" " mat4 SkeletalMatrix = mat4(SkeletalMatrix1, SkeletalMatrix2, SkeletalMatrix3, vec4(0.0, 0.0, 0.0, 1.0));\n" -" mat3 SkeletalNormalMatrix = mat3(cross(SkeletalMatrix[1].xyz, SkeletalMatrix[0].xyz), cross(SkeletalMatrix[2].xyz, SkeletalMatrix[0].xyz), cross(SkeletalMatrix[0].xyz, SkeletalMatrix[1].xyz));\n" +" mat3 SkeletalNormalMatrix = mat3(cross(SkeletalMatrix[1].xyz, SkeletalMatrix[2].xyz), cross(SkeletalMatrix[2].xyz, SkeletalMatrix[0].xyz), cross(SkeletalMatrix[0].xyz, SkeletalMatrix[1].xyz)); // is actually transpose(inverse(mat3(SkeletalMatrix))) * det(mat3(SkeletalMatrix))\n" " vec4 SkeletalVertex = Attrib_Position * SkeletalMatrix;\n" " vec3 SkeletalSVector = normalize(Attrib_TexCoord1.xyz * SkeletalNormalMatrix);\n" " vec3 SkeletalTVector = normalize(Attrib_TexCoord2.xyz * SkeletalNormalMatrix);\n" @@ -1260,7 +1260,7 @@ " mat4 SkeletalMatrix = mat4(SkeletalMatrix1, SkeletalMatrix2, SkeletalMatrix3, vec4(0.0, 0.0, 0.0, 1.0));\n" "// ivec4 si = ivec4(Attrib_SkeletalIndex);\n" "// mat4 SkeletalMatrix = Skeletal_Transform[si.x] * Attrib_SkeletalWeight.x + Skeletal_Transform[si.y] * Attrib_SkeletalWeight.y + Skeletal_Transform[si.z] * Attrib_SkeletalWeight.z + Skeletal_Transform[si.w] * Attrib_SkeletalWeight.w;\n" -" mat3 SkeletalNormalMatrix = mat3(cross(SkeletalMatrix[1].xyz, SkeletalMatrix[0].xyz), cross(SkeletalMatrix[2].xyz, SkeletalMatrix[0].xyz), cross(SkeletalMatrix[0].xyz, SkeletalMatrix[1].xyz));\n" +" mat3 SkeletalNormalMatrix = mat3(cross(SkeletalMatrix[1].xyz, SkeletalMatrix[2].xyz), cross(SkeletalMatrix[2].xyz, SkeletalMatrix[0].xyz), cross(SkeletalMatrix[0].xyz, SkeletalMatrix[1].xyz)); // is actually transpose(inverse(mat3(SkeletalMatrix))) * det(mat3(SkeletalMatrix))\n" " vec4 SkeletalVertex = Attrib_Position * SkeletalMatrix;\n" " SkeletalVertex.w = 1.0;\n" " vec3 SkeletalSVector = normalize(Attrib_TexCoord1.xyz * SkeletalNormalMatrix);\n"