EllipsoidVS.js 1.5 KB

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