shadowMap.vertex.fx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Attribute
  2. attribute vec3 position;
  3. #ifdef NORMAL
  4. attribute vec3 normal;
  5. #endif
  6. #include<bonesDeclaration>
  7. #include<morphTargetsVertexGlobalDeclaration>
  8. #include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
  9. // Uniforms
  10. #include<instancesDeclaration>
  11. #include<helperFunctions>
  12. uniform mat4 viewProjection;
  13. #ifdef ALPHATEST
  14. varying vec2 vUV;
  15. uniform mat4 diffuseMatrix;
  16. #ifdef UV1
  17. attribute vec2 uv;
  18. #endif
  19. #ifdef UV2
  20. attribute vec2 uv2;
  21. #endif
  22. #endif
  23. #include<shadowMapVertexDeclaration>
  24. #include<clipPlaneVertexDeclaration>
  25. void main(void)
  26. {
  27. vec3 positionUpdated = position;
  28. #ifdef UV1
  29. vec2 uvUpdated = uv;
  30. #endif
  31. #ifdef NORMAL
  32. vec3 normalUpdated = normal;
  33. #endif
  34. #include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
  35. #include<instancesVertex>
  36. #include<bonesVertex>
  37. vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);
  38. #ifdef NORMAL
  39. mat3 normWorldSM = mat3(finalWorld);
  40. #if defined(INSTANCES) && defined(THIN_INSTANCES)
  41. vec3 vNormalW = normalUpdated / vec3(dot(normWorldSM[0], normWorldSM[0]), dot(normWorldSM[1], normWorldSM[1]), dot(normWorldSM[2], normWorldSM[2]));
  42. vNormalW = normalize(normWorldSM * vNormalW);
  43. #else
  44. #ifdef NONUNIFORMSCALING
  45. normWorldSM = transposeMat3(inverseMat3(normWorldSM));
  46. #endif
  47. vec3 vNormalW = normalize(normWorldSM * normalUpdated);
  48. #endif
  49. #endif
  50. #include<shadowMapVertexNormalBias>
  51. // Projection.
  52. gl_Position = viewProjection * worldPos;
  53. #include<shadowMapVertexMetric>
  54. #ifdef ALPHATEST
  55. #ifdef UV1
  56. vUV = vec2(diffuseMatrix * vec4(uvUpdated, 1.0, 0.0));
  57. #endif
  58. #ifdef UV2
  59. vUV = vec2(diffuseMatrix * vec4(uv2, 1.0, 0.0));
  60. #endif
  61. #endif
  62. #include<clipPlaneVertex>
  63. }