shadowMap.vertex.fx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifdef GL_ES
  2. precision highp float;
  3. #endif
  4. // Attribute
  5. attribute vec3 position;
  6. #ifdef BONES
  7. attribute vec4 matricesIndices;
  8. attribute vec4 matricesWeights;
  9. #endif
  10. // Uniform
  11. #ifdef INSTANCES
  12. attribute vec4 world0;
  13. attribute vec4 world1;
  14. attribute vec4 world2;
  15. attribute vec4 world3;
  16. #else
  17. uniform mat4 world;
  18. #endif
  19. uniform mat4 viewProjection;
  20. #ifdef BONES
  21. uniform mat4 mBones[BonesPerMesh];
  22. #endif
  23. varying vec4 vPosition;
  24. #ifdef ALPHATEST
  25. varying vec2 vUV;
  26. uniform mat4 diffuseMatrix;
  27. #ifdef UV1
  28. attribute vec2 uv;
  29. #endif
  30. #ifdef UV2
  31. attribute vec2 uv2;
  32. #endif
  33. #endif
  34. void main(void)
  35. {
  36. #ifdef INSTANCES
  37. mat4 finalWorld = mat4(world0, world1, world2, world3);
  38. #else
  39. mat4 finalWorld = world;
  40. #endif
  41. #ifdef BONES
  42. mat4 m0 = mBones[int(matricesIndices.x)] * matricesWeights.x;
  43. mat4 m1 = mBones[int(matricesIndices.y)] * matricesWeights.y;
  44. mat4 m2 = mBones[int(matricesIndices.z)] * matricesWeights.z;
  45. mat4 m3 = mBones[int(matricesIndices.w)] * matricesWeights.w;
  46. finalWorld = finalWorld * (m0 + m1 + m2 + m3);
  47. #endif
  48. vPosition = viewProjection * finalWorld * vec4(position, 1.0);
  49. gl_Position = vPosition;
  50. #ifdef ALPHATEST
  51. #ifdef UV1
  52. vUV = vec2(diffuseMatrix * vec4(uv, 1.0, 0.0));
  53. #endif
  54. #ifdef UV2
  55. vUV = vec2(diffuseMatrix * vec4(uv2, 1.0, 0.0));
  56. #endif
  57. #endif
  58. }