Monster0VS.glsl 739 B

12345678910111213141516171819202122
  1. precision highp float;
  2. attribute vec3 a_position;
  3. attribute vec3 a_normal;
  4. varying vec3 v_normal;
  5. attribute vec4 a_joint;
  6. attribute vec4 a_weight;
  7. uniform mat4 u_jointMat[32];
  8. uniform mat3 u_normalMatrix;
  9. uniform mat4 u_modelViewMatrix;
  10. uniform mat4 u_projectionMatrix;
  11. attribute vec2 a_texcoord0;
  12. varying vec2 v_texcoord0;
  13. void main(void) {
  14. mat4 skinMat = a_weight.x * u_jointMat[int(a_joint.x)];
  15. skinMat += a_weight.y * u_jointMat[int(a_joint.y)];
  16. skinMat += a_weight.z * u_jointMat[int(a_joint.z)];
  17. skinMat += a_weight.w * u_jointMat[int(a_joint.w)];
  18. vec4 pos = u_modelViewMatrix * skinMat * vec4(a_position,1.0);
  19. v_normal = u_normalMatrix * mat3(skinMat)* a_normal;
  20. v_texcoord0 = a_texcoord0;
  21. gl_Position = u_projectionMatrix * pos;
  22. }