EllipsoidVS.js 1.5 KB

1234567891011121314151617181920212223242526272829303132
  1. //This file is automatically rebuilt by the Cesium build process.
  2. /*global define*/
  3. define(function() {
  4. "use strict";
  5. return "attribute vec3 position;\n\
  6. \n\
  7. uniform vec3 u_radii;\n\
  8. \n\
  9. varying vec3 v_positionEC;\n\
  10. \n\
  11. void main() \n\
  12. {\n\
  13. // In the vertex data, the cube goes from (-1.0, -1.0, -1.0) to (1.0, 1.0, 1.0) in model coordinates.\n\
  14. // Scale to consider the radii. We could also do this once on the CPU when using the BoxGeometry,\n\
  15. // but doing it here allows us to change the radii without rewriting the vertex data, and\n\
  16. // allows all ellipsoids to reuse the same vertex data.\n\
  17. vec4 p = vec4(u_radii * position, 1.0);\n\
  18. \n\
  19. v_positionEC = (czm_modelView * p).xyz; // position in eye coordinates\n\
  20. gl_Position = czm_modelViewProjection * p; // position in clip coordinates\n\
  21. \n\
  22. // With multi-frustum, when the ellipsoid primitive is positioned on the intersection of two frustums \n\
  23. // and close to terrain, the terrain (writes depth) in the closest frustum can overwrite part of the \n\
  24. // ellipsoid (does not write depth) that was rendered in the farther frustum.\n\
  25. //\n\
  26. // Here, we clamp the depth in the vertex shader to avoid being overwritten; however, this creates\n\
  27. // artifacts since some fragments can be alpha blended twice. This is solved by only rendering\n\
  28. // the ellipsoid in the closest frustum to the viewer.\n\
  29. gl_Position.z = clamp(gl_Position.z, czm_depthRange.near, czm_depthRange.far);\n\
  30. }\n\
  31. ";
  32. });