depth.vertex.fx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #if defined(ALPHATEST) || defined(NEED_UV)
  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 INSTANCES
  36. mat4 finalWorld = mat4(world0, world1, world2, world3);
  37. #else
  38. mat4 finalWorld = world;
  39. #endif
  40. #ifdef BONES
  41. mat4 m0 = mBones[int(matricesIndices.x)] * matricesWeights.x;
  42. mat4 m1 = mBones[int(matricesIndices.y)] * matricesWeights.y;
  43. mat4 m2 = mBones[int(matricesIndices.z)] * matricesWeights.z;
  44. mat4 m3 = mBones[int(matricesIndices.w)] * matricesWeights.w;
  45. finalWorld = finalWorld * (m0 + m1 + m2 + m3);
  46. gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
  47. #else
  48. gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
  49. #endif
  50. #if defined(ALPHATEST) || defined(BASIC_RENDER)
  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. }