Vector3DTileClampedPolylinesFS.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "#ifdef GL_EXT_frag_depth\n\
  3. #extension GL_EXT_frag_depth : enable\n\
  4. #endif\n\
  5. \n\
  6. varying vec4 v_startPlaneEC;\n\
  7. varying vec4 v_endPlaneEC;\n\
  8. varying vec4 v_rightPlaneEC;\n\
  9. varying float v_halfWidth;\n\
  10. varying vec3 v_volumeUpEC;\n\
  11. \n\
  12. uniform vec4 u_highlightColor;\n\
  13. void main()\n\
  14. {\n\
  15. float logDepthOrDepth = czm_branchFreeTernary(czm_sceneMode == czm_sceneMode2D, gl_FragCoord.z, czm_unpackDepth(texture2D(czm_globeDepthTexture, gl_FragCoord.xy / czm_viewport.zw)));\n\
  16. \n\
  17. // Discard for sky\n\
  18. if (logDepthOrDepth == 0.0) {\n\
  19. #ifdef DEBUG_SHOW_VOLUME\n\
  20. gl_FragColor = vec4(0.0, 0.0, 1.0, 0.5);\n\
  21. return;\n\
  22. #else // DEBUG_SHOW_VOLUME\n\
  23. discard;\n\
  24. #endif // DEBUG_SHOW_VOLUME\n\
  25. }\n\
  26. \n\
  27. vec4 eyeCoordinate = czm_windowToEyeCoordinates(gl_FragCoord.xy, logDepthOrDepth);\n\
  28. eyeCoordinate /= eyeCoordinate.w;\n\
  29. \n\
  30. float halfMaxWidth = v_halfWidth * czm_metersPerPixel(eyeCoordinate);\n\
  31. \n\
  32. // Expand halfMaxWidth if direction to camera is almost perpendicular with the volume's up direction\n\
  33. halfMaxWidth += halfMaxWidth * (1.0 - dot(-normalize(eyeCoordinate.xyz), v_volumeUpEC));\n\
  34. \n\
  35. // Check distance of the eye coordinate against the right-facing plane\n\
  36. float widthwiseDistance = czm_planeDistance(v_rightPlaneEC, eyeCoordinate.xyz);\n\
  37. \n\
  38. // Check eye coordinate against the mitering planes\n\
  39. float distanceFromStart = czm_planeDistance(v_startPlaneEC, eyeCoordinate.xyz);\n\
  40. float distanceFromEnd = czm_planeDistance(v_endPlaneEC, eyeCoordinate.xyz);\n\
  41. \n\
  42. if (abs(widthwiseDistance) > halfMaxWidth || distanceFromStart < 0.0 || distanceFromEnd < 0.0) {\n\
  43. #ifdef DEBUG_SHOW_VOLUME\n\
  44. gl_FragColor = vec4(logDepthOrDepth, 0.0, 0.0, 0.5);\n\
  45. return;\n\
  46. #else // DEBUG_SHOW_VOLUME\n\
  47. discard;\n\
  48. #endif // DEBUG_SHOW_VOLUME\n\
  49. }\n\
  50. gl_FragColor = u_highlightColor;\n\
  51. \n\
  52. czm_writeDepthClamp();\n\
  53. }\n\
  54. ";