智慧水务管理系统 - 精河县供水工程综合管理平台

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