depth.vertex.fx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Attribute
  2. attribute vec3 position;
  3. #include<bonesDeclaration>
  4. #include<morphTargetsVertexGlobalDeclaration>
  5. #include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
  6. // Uniform
  7. #include<instancesDeclaration>
  8. uniform mat4 viewProjection;
  9. uniform vec2 depthValues;
  10. #if defined(ALPHATEST) || defined(NEED_UV)
  11. varying vec2 vUV;
  12. uniform mat4 diffuseMatrix;
  13. #ifdef UV1
  14. attribute vec2 uv;
  15. #endif
  16. #ifdef UV2
  17. attribute vec2 uv2;
  18. #endif
  19. #endif
  20. varying float vDepthMetric;
  21. void main(void)
  22. {
  23. vec3 positionUpdated = position;
  24. #ifdef UV1
  25. vec2 uvUpdated = uv;
  26. #endif
  27. #include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
  28. #include<instancesVertex>
  29. #include<bonesVertex>
  30. gl_Position = viewProjection * finalWorld * vec4(positionUpdated, 1.0);
  31. vDepthMetric = ((gl_Position.z + depthValues.x) / (depthValues.y));
  32. #if defined(ALPHATEST) || defined(BASIC_RENDER)
  33. #ifdef UV1
  34. vUV = vec2(diffuseMatrix * vec4(uvUpdated, 1.0, 0.0));
  35. #endif
  36. #ifdef UV2
  37. vUV = vec2(diffuseMatrix * vec4(uv2, 1.0, 0.0));
  38. #endif
  39. #endif
  40. }