DepthPlaneFS.glsl 954 B

123456789101112131415161718192021222324252627282930313233343536
  1. in vec4 positionEC;
  2. void main()
  3. {
  4. vec3 position;
  5. vec3 direction;
  6. if (czm_orthographicIn3D == 1.0)
  7. {
  8. vec2 uv = (gl_FragCoord.xy - czm_viewport.xy) / czm_viewport.zw;
  9. vec2 minPlane = vec2(czm_frustumPlanes.z, czm_frustumPlanes.y); // left, bottom
  10. vec2 maxPlane = vec2(czm_frustumPlanes.w, czm_frustumPlanes.x); // right, top
  11. position = vec3(mix(minPlane, maxPlane, uv), 0.0);
  12. direction = vec3(0.0, 0.0, -1.0);
  13. }
  14. else
  15. {
  16. position = vec3(0.0);
  17. direction = normalize(positionEC.xyz);
  18. }
  19. czm_ray ray = czm_ray(position, direction);
  20. vec3 ellipsoid_center = czm_view[3].xyz;
  21. czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid_center, czm_ellipsoidInverseRadii);
  22. if (!czm_isEmpty(intersection))
  23. {
  24. out_FragColor = vec4(1.0, 1.0, 0.0, 1.0);
  25. }
  26. else
  27. {
  28. discard;
  29. }
  30. czm_writeLogDepth();
  31. }