mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-05-31 08:41:11 +00:00
Add mvp_mat and some comments.
This commit is contained in:
parent
59c5bf2f9e
commit
15d35fbdc9
1 changed files with 8 additions and 5 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
uniform mat4 mvp_mat;
|
||||||
uniform mat4 bonemats[80];
|
uniform mat4 bonemats[80];
|
||||||
attribute vec4 vcolor;
|
attribute vec4 vcolor;
|
||||||
attribute vec4 vweights;
|
attribute vec4 vweights;
|
||||||
|
@ -24,14 +25,15 @@ main (void)
|
||||||
m += bonemats[int (vbones.y)] * vweights.y;
|
m += bonemats[int (vbones.y)] * vweights.y;
|
||||||
m += bonemats[int (vbones.z)] * vweights.z;
|
m += bonemats[int (vbones.z)] * vweights.z;
|
||||||
m += bonemats[int (vbones.w)] * vweights.w;
|
m += bonemats[int (vbones.w)] * vweights.w;
|
||||||
q0 = m[0].yzwx;
|
q0 = m[0].yzwx; //swizzle for conversion betwen QF and GL
|
||||||
qe = m[1].yzwx;
|
qe = m[1].yzwx; //swizzle for conversion betwen QF and GL
|
||||||
sh = m[2].xyz;
|
sh = m[2].xyz;
|
||||||
sc = m[3].xyz;
|
sc = m[3].xyz;
|
||||||
|
|
||||||
|
// extract translation from dual quaternion
|
||||||
tr = 2.0 * (q0.w * qe.xyz - qe.w * q0.xyz - cross (qe.xyz, q0.xyz));
|
tr = 2.0 * (q0.w * qe.xyz - qe.w * q0.xyz - cross (qe.xyz, q0.xyz));
|
||||||
v = position;
|
|
||||||
// apply rotation and translation
|
// apply rotation and translation
|
||||||
|
v = position;
|
||||||
v += 2.0 * cross (q0.xyz, cross (q0.xyz, v) + q0.w * v) + tr;
|
v += 2.0 * cross (q0.xyz, cross (q0.xyz, v) + q0.w * v) + tr;
|
||||||
// apply shear
|
// apply shear
|
||||||
v.z += v.y * sh.z + v.x * sh.y;
|
v.z += v.y * sh.z + v.x * sh.y;
|
||||||
|
@ -47,8 +49,9 @@ main (void)
|
||||||
t = vtangent.xyz;
|
t = vtangent.xyz;
|
||||||
t += 2.0 * cross (q0.xyz, cross (q0.xyz, t) + q0.w * t);
|
t += 2.0 * cross (q0.xyz, cross (q0.xyz, t) + q0.w * t);
|
||||||
gl_Position = mvp_mat * vec4 (v, 1.0);
|
gl_Position = mvp_mat * vec4 (v, 1.0);
|
||||||
normal = mat3 (mvp_mat[0].xyz, mvp_mat[1].xyz, mvp_mat[3].xyz) * n;
|
mat3 rot = mat3 (mvp_mat[0].xyz, mvp_mat[1].xyz, mvp_mat[3].xyz)
|
||||||
tangent = mat3 (mvp_mat[0].xyz, mvp_mat[1].xyz, mvp_mat[3].xyz) * t;
|
normal = rot * n;
|
||||||
|
tangent = rot * t;
|
||||||
bitangent = cross (normal, tangent) * vtangent.w;
|
bitangent = cross (normal, tangent) * vtangent.w;
|
||||||
color = vcolor;
|
color = vcolor;
|
||||||
st = texcoord;
|
st = texcoord;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue