shadowMap.vertex.fx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifdef GL_ES
  2. precision mediump 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 mat4 world;
  13. #else
  14. uniform mat4 world;
  15. #endif
  16. uniform mat4 viewProjection;
  17. #ifdef BONES
  18. uniform mat4 mBones[BonesPerMesh];
  19. #endif
  20. #ifndef VSM
  21. varying vec4 vPosition;
  22. #endif
  23. #ifdef ALPHATEST
  24. varying vec2 vUV;
  25. uniform mat4 diffuseMatrix;
  26. #ifdef UV1
  27. attribute vec2 uv;
  28. #endif
  29. #ifdef UV2
  30. attribute vec2 uv2;
  31. #endif
  32. #endif
  33. void main(void)
  34. {
  35. #ifdef BONES
  36. mat4 m0 = mBones[int(matricesIndices.x)] * matricesWeights.x;
  37. mat4 m1 = mBones[int(matricesIndices.y)] * matricesWeights.y;
  38. mat4 m2 = mBones[int(matricesIndices.z)] * matricesWeights.z;
  39. mat4 m3 = mBones[int(matricesIndices.w)] * matricesWeights.w;
  40. mat4 finalWorld = world * (m0 + m1 + m2 + m3);
  41. gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
  42. #else
  43. #ifndef VSM
  44. vPosition = viewProjection * world * vec4(position, 1.0);
  45. #endif
  46. gl_Position = viewProjection * world * vec4(position, 1.0);
  47. #endif
  48. #ifdef ALPHATEST
  49. #ifdef UV1
  50. vUV = vec2(diffuseMatrix * vec4(uv, 1.0, 0.0));
  51. #endif
  52. #ifdef UV2
  53. vUV = vec2(diffuseMatrix * vec4(uv2, 1.0, 0.0));
  54. #endif
  55. #endif
  56. }