2014-05-19 05:49:16 +08:00
|
|
|
|
|
|
|
const char* cc3D_PositionTex_vert = STRINGIFY(
|
|
|
|
|
|
|
|
attribute vec4 a_position;
|
|
|
|
attribute vec2 a_texCoord;
|
|
|
|
|
|
|
|
varying vec2 TextureCoordOut;
|
|
|
|
|
|
|
|
void main(void)
|
|
|
|
{
|
|
|
|
gl_Position = CC_MVPMatrix * a_position;
|
|
|
|
TextureCoordOut = a_texCoord;
|
|
|
|
TextureCoordOut.y = 1.0 - TextureCoordOut.y;
|
|
|
|
}
|
|
|
|
);
|
2014-06-05 16:36:01 +08:00
|
|
|
|
|
|
|
const char* cc3D_SkinPositionTex_vert = STRINGIFY(
|
2014-07-04 09:25:06 +08:00
|
|
|
attribute vec3 a_position;
|
2014-06-05 16:36:01 +08:00
|
|
|
|
2014-06-09 18:37:58 +08:00
|
|
|
attribute vec4 a_blendWeight;
|
|
|
|
attribute vec4 a_blendIndex;
|
2014-06-05 16:36:01 +08:00
|
|
|
|
|
|
|
attribute vec2 a_texCoord;
|
|
|
|
|
2014-06-13 19:26:46 +08:00
|
|
|
const int SKINNING_JOINT_COUNT = 60;
|
2014-06-05 16:36:01 +08:00
|
|
|
// Uniforms
|
|
|
|
uniform vec4 u_matrixPalette[SKINNING_JOINT_COUNT * 3];
|
|
|
|
|
|
|
|
// Varyings
|
|
|
|
varying vec2 TextureCoordOut;
|
|
|
|
|
|
|
|
vec4 getPosition()
|
|
|
|
{
|
2014-06-09 18:37:58 +08:00
|
|
|
float blendWeight = a_blendWeight[0];
|
2014-06-25 17:36:55 +08:00
|
|
|
|
2014-06-09 18:37:58 +08:00
|
|
|
int matrixIndex = int (a_blendIndex[0]) * 3;
|
2014-06-23 19:08:26 +08:00
|
|
|
vec4 matrixPalette1 = u_matrixPalette[matrixIndex] * blendWeight;
|
|
|
|
vec4 matrixPalette2 = u_matrixPalette[matrixIndex + 1] * blendWeight;
|
|
|
|
vec4 matrixPalette3 = u_matrixPalette[matrixIndex + 2] * blendWeight;
|
2014-06-05 16:36:01 +08:00
|
|
|
|
2014-06-25 17:36:55 +08:00
|
|
|
|
2014-06-09 18:37:58 +08:00
|
|
|
blendWeight = a_blendWeight[1];
|
2014-06-25 17:36:55 +08:00
|
|
|
if (blendWeight > 0.0)
|
|
|
|
{
|
|
|
|
matrixIndex = int(a_blendIndex[1]) * 3;
|
|
|
|
matrixPalette1 += u_matrixPalette[matrixIndex] * blendWeight;
|
|
|
|
matrixPalette2 += u_matrixPalette[matrixIndex + 1] * blendWeight;
|
|
|
|
matrixPalette3 += u_matrixPalette[matrixIndex + 2] * blendWeight;
|
|
|
|
}
|
|
|
|
|
2014-06-05 16:36:01 +08:00
|
|
|
|
2014-06-09 18:37:58 +08:00
|
|
|
blendWeight = a_blendWeight[2];
|
2014-06-25 17:36:55 +08:00
|
|
|
if (blendWeight > 0.0)
|
|
|
|
{
|
|
|
|
matrixIndex = int(a_blendIndex[2]) * 3;
|
|
|
|
matrixPalette1 += u_matrixPalette[matrixIndex] * blendWeight;
|
|
|
|
matrixPalette2 += u_matrixPalette[matrixIndex + 1] * blendWeight;
|
|
|
|
matrixPalette3 += u_matrixPalette[matrixIndex + 2] * blendWeight;
|
|
|
|
}
|
|
|
|
|
2014-06-05 16:36:01 +08:00
|
|
|
|
2014-06-09 18:37:58 +08:00
|
|
|
blendWeight = a_blendWeight[3];
|
2014-06-25 17:36:55 +08:00
|
|
|
if (blendWeight > 0.0)
|
|
|
|
{
|
|
|
|
matrixIndex = int(a_blendIndex[3]) * 3;
|
|
|
|
matrixPalette1 += u_matrixPalette[matrixIndex] * blendWeight;
|
|
|
|
matrixPalette2 += u_matrixPalette[matrixIndex + 1] * blendWeight;
|
|
|
|
matrixPalette3 += u_matrixPalette[matrixIndex + 2] * blendWeight;
|
|
|
|
}
|
|
|
|
|
2014-06-09 18:37:58 +08:00
|
|
|
|
2014-06-25 17:36:55 +08:00
|
|
|
vec4 _skinnedPosition;
|
2014-07-04 09:25:06 +08:00
|
|
|
vec4 postion = vec4(a_position, 1.0);
|
|
|
|
_skinnedPosition.x = dot(postion, matrixPalette1);
|
|
|
|
_skinnedPosition.y = dot(postion, matrixPalette2);
|
|
|
|
_skinnedPosition.z = dot(postion, matrixPalette3);
|
|
|
|
_skinnedPosition.w = postion.w;
|
2014-06-15 22:45:56 +08:00
|
|
|
|
2014-06-05 16:36:01 +08:00
|
|
|
return _skinnedPosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2014-06-12 18:46:45 +08:00
|
|
|
vec4 position = getPosition();
|
2014-06-05 16:36:01 +08:00
|
|
|
gl_Position = CC_MVPMatrix * position;
|
|
|
|
|
|
|
|
TextureCoordOut = a_texCoord;
|
|
|
|
TextureCoordOut.y = 1.0 - TextureCoordOut.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|