2016-01-28 00:58:00 +01:00
|
|
|
#version 450
|
|
|
|
|
2015-12-17 20:07:23 +01:00
|
|
|
#ifdef GL_ES
|
|
|
|
precision highp float;
|
|
|
|
#endif
|
|
|
|
|
2016-02-15 12:48:15 +01:00
|
|
|
#ifdef _NMTex
|
|
|
|
#define _AMTex
|
2015-12-17 20:07:23 +01:00
|
|
|
#endif
|
|
|
|
|
2016-01-28 00:58:00 +01:00
|
|
|
in vec3 pos;
|
2016-03-09 13:08:46 +01:00
|
|
|
in vec3 nor;
|
2016-02-15 12:48:15 +01:00
|
|
|
#ifdef _AMTex
|
2016-01-28 00:58:00 +01:00
|
|
|
in vec2 tex;
|
2015-12-17 20:07:23 +01:00
|
|
|
#endif
|
|
|
|
#ifdef _VCols
|
2016-01-28 00:58:00 +01:00
|
|
|
in vec4 col;
|
2015-12-17 20:07:23 +01:00
|
|
|
#endif
|
2016-02-15 12:48:15 +01:00
|
|
|
#ifdef _NMTex
|
2016-01-28 00:58:00 +01:00
|
|
|
in vec3 tan;
|
|
|
|
in vec3 bitan;
|
2015-12-17 20:07:23 +01:00
|
|
|
#endif
|
|
|
|
#ifdef _Skinning
|
2016-01-28 00:58:00 +01:00
|
|
|
in vec4 bone;
|
|
|
|
in vec4 weight;
|
2015-12-17 20:07:23 +01:00
|
|
|
#endif
|
|
|
|
#ifdef _Instancing
|
2016-01-28 00:58:00 +01:00
|
|
|
in vec3 off;
|
2015-12-17 20:07:23 +01:00
|
|
|
#endif
|
|
|
|
|
2016-02-07 23:03:52 +01:00
|
|
|
uniform mat4 LMVP;
|
2016-04-07 00:06:57 +02:00
|
|
|
#ifdef _Skinning
|
|
|
|
uniform float skinBones[50 * 12];
|
|
|
|
#endif
|
2015-12-17 20:07:23 +01:00
|
|
|
|
2016-01-28 00:58:00 +01:00
|
|
|
out vec4 position;
|
2015-12-17 20:07:23 +01:00
|
|
|
|
2016-04-07 00:06:57 +02:00
|
|
|
#ifdef _Skinning
|
|
|
|
mat4 getBoneMat(const int boneIndex) {
|
|
|
|
vec4 v0 = vec4(skinBones[boneIndex * 12 + 0],
|
|
|
|
skinBones[boneIndex * 12 + 1],
|
|
|
|
skinBones[boneIndex * 12 + 2],
|
|
|
|
skinBones[boneIndex * 12 + 3]);
|
|
|
|
vec4 v1 = vec4(skinBones[boneIndex * 12 + 4],
|
|
|
|
skinBones[boneIndex * 12 + 5],
|
|
|
|
skinBones[boneIndex * 12 + 6],
|
|
|
|
skinBones[boneIndex * 12 + 7]);
|
|
|
|
vec4 v2 = vec4(skinBones[boneIndex * 12 + 8],
|
|
|
|
skinBones[boneIndex * 12 + 9],
|
|
|
|
skinBones[boneIndex * 12 + 10],
|
|
|
|
skinBones[boneIndex * 12 + 11]);
|
|
|
|
return mat4(v0.x, v0.y, v0.z, v0.w,
|
|
|
|
v1.x, v1.y, v1.z, v1.w,
|
|
|
|
v2.x, v2.y, v2.z, v2.w,
|
|
|
|
0, 0, 0, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
mat4 getSkinningMat() {
|
|
|
|
return weight.x * getBoneMat(int(bone.x)) +
|
|
|
|
weight.y * getBoneMat(int(bone.y)) +
|
|
|
|
weight.z * getBoneMat(int(bone.z)) +
|
|
|
|
weight.w * getBoneMat(int(bone.w));
|
|
|
|
}
|
|
|
|
|
|
|
|
mat3 getSkinningMatVec(const mat4 skinningMat) {
|
|
|
|
return mat3(skinningMat[0].xyz, skinningMat[1].xyz, skinningMat[2].xyz);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-01-24 22:32:51 +01:00
|
|
|
void main() {
|
2016-04-07 00:06:57 +02:00
|
|
|
#ifdef _Instancing
|
|
|
|
vec4 sPos = (vec4(pos + off, 1.0));
|
2015-12-17 20:07:23 +01:00
|
|
|
#else
|
2016-04-07 00:06:57 +02:00
|
|
|
vec4 sPos = (vec4(pos, 1.0));
|
2015-12-17 20:07:23 +01:00
|
|
|
#endif
|
2016-04-07 00:06:57 +02:00
|
|
|
|
|
|
|
#ifdef _Skinning
|
|
|
|
mat4 skinningMat = getSkinningMat();
|
|
|
|
mat3 skinningMatVec = getSkinningMatVec(skinningMat);
|
|
|
|
sPos = sPos * skinningMat;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
gl_Position = LMVP * sPos;
|
2015-12-17 20:07:23 +01:00
|
|
|
position = gl_Position;
|
|
|
|
}
|