shadowMap.vertex.fx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #ifndef VSM
  24. varying vec4 vPosition;
  25. #endif
  26. #ifdef ALPHATEST
  27. varying vec2 vUV;
  28. uniform mat4 diffuseMatrix;
  29. #ifdef UV1
  30. attribute vec2 uv;
  31. #endif
  32. #ifdef UV2
  33. attribute vec2 uv2;
  34. #endif
  35. #endif
  36. void main(void)
  37. {
  38. #ifdef INSTANCES
  39. mat4 finalWorld = mat4(world0, world1, world2, world3);
  40. #else
  41. mat4 finalWorld = world;
  42. #endif
  43. #ifdef BONES
  44. mat4 m0 = mBones[int(matricesIndices.x)] * matricesWeights.x;
  45. mat4 m1 = mBones[int(matricesIndices.y)] * matricesWeights.y;
  46. mat4 m2 = mBones[int(matricesIndices.z)] * matricesWeights.z;
  47. mat4 m3 = mBones[int(matricesIndices.w)] * matricesWeights.w;
  48. finalWorld = finalWorld * (m0 + m1 + m2 + m3);
  49. gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
  50. #else
  51. #ifndef VSM
  52. vPosition = viewProjection * finalWorld * vec4(position, 1.0);
  53. #endif
  54. gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
  55. #endif
  56. #ifdef ALPHATEST
  57. #ifdef UV1
  58. vUV = vec2(diffuseMatrix * vec4(uv, 1.0, 0.0));
  59. #endif
  60. #ifdef UV2
  61. vUV = vec2(diffuseMatrix * vec4(uv2, 1.0, 0.0));
  62. #endif
  63. #endif
  64. }