Vector3DTileClampedPolylinesFS.js 1.9 KB

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