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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "float interpolateByDistance(vec4 nearFarScalar, float distance)\n\
  3. {\n\
  4. float startDistance = nearFarScalar.x;\n\
  5. float startValue = nearFarScalar.y;\n\
  6. float endDistance = nearFarScalar.z;\n\
  7. float endValue = nearFarScalar.w;\n\
  8. float t = clamp((distance - startDistance) / (endDistance - startDistance), 0.0, 1.0);\n\
  9. return mix(startValue, endValue, t);\n\
  10. }\n\
  11. \n\
  12. void computeAtmosphereScattering(vec3 positionWC, vec3 lightDirection, out vec3 rayleighColor, out vec3 mieColor, out float opacity, out float underTranslucentGlobe)\n\
  13. {\n\
  14. float ellipsoidRadiiDifference = czm_ellipsoidRadii.x - czm_ellipsoidRadii.z;\n\
  15. \n\
  16. // Adjustment to the atmosphere radius applied based on the camera height.\n\
  17. float distanceAdjustMin = czm_ellipsoidRadii.x / 4.0;\n\
  18. float distanceAdjustMax = czm_ellipsoidRadii.x;\n\
  19. float distanceAdjustModifier = ellipsoidRadiiDifference / 2.0;\n\
  20. float distanceAdjust = distanceAdjustModifier * clamp((czm_eyeHeight - distanceAdjustMin) / (distanceAdjustMax - distanceAdjustMin), 0.0, 1.0);\n\
  21. \n\
  22. // Since atmosphere scattering assumes the atmosphere is a spherical shell, we compute an inner radius of the atmosphere best fit\n\
  23. // for the position on the ellipsoid.\n\
  24. float radiusAdjust = (ellipsoidRadiiDifference / 4.0) + distanceAdjust;\n\
  25. float atmosphereInnerRadius = (length(czm_viewerPositionWC) - czm_eyeHeight) - radiusAdjust;\n\
  26. \n\
  27. // Setup the primary ray: from the camera position to the vertex position.\n\
  28. vec3 cameraToPositionWC = positionWC - czm_viewerPositionWC;\n\
  29. vec3 cameraToPositionWCDirection = normalize(cameraToPositionWC);\n\
  30. czm_ray primaryRay = czm_ray(czm_viewerPositionWC, cameraToPositionWCDirection);\n\
  31. \n\
  32. underTranslucentGlobe = 0.0;\n\
  33. \n\
  34. // Brighten the sky atmosphere under the Earth's atmosphere when translucency is enabled.\n\
  35. #if defined(GLOBE_TRANSLUCENT)\n\
  36. \n\
  37. // Check for intersection with the inner radius of the atmopshere.\n\
  38. czm_raySegment primaryRayEarthIntersect = czm_raySphereIntersectionInterval(primaryRay, vec3(0.0), atmosphereInnerRadius + radiusAdjust);\n\
  39. if (primaryRayEarthIntersect.start > 0.0 && primaryRayEarthIntersect.stop > 0.0) {\n\
  40. \n\
  41. // Compute position on globe.\n\
  42. vec3 direction = normalize(positionWC);\n\
  43. czm_ray ellipsoidRay = czm_ray(positionWC, -direction);\n\
  44. czm_raySegment ellipsoidIntersection = czm_rayEllipsoidIntersectionInterval(ellipsoidRay, vec3(0.0), czm_ellipsoidInverseRadii);\n\
  45. vec3 onEarth = positionWC - (direction * ellipsoidIntersection.start);\n\
  46. \n\
  47. // Control the color using the camera angle.\n\
  48. float angle = dot(normalize(czm_viewerPositionWC), normalize(onEarth));\n\
  49. \n\
  50. // Control the opacity using the distance from Earth.\n\
  51. opacity = interpolateByDistance(vec4(0.0, 1.0, czm_ellipsoidRadii.x, 0.0), length(czm_viewerPositionWC - onEarth));\n\
  52. vec3 horizonColor = vec3(0.1, 0.2, 0.3);\n\
  53. vec3 nearColor = vec3(0.0);\n\
  54. \n\
  55. rayleighColor = mix(nearColor, horizonColor, exp(-angle) * opacity);\n\
  56. \n\
  57. // Set the traslucent flag to avoid alpha adjustment in computeFinalColor funciton.\n\
  58. underTranslucentGlobe = 1.0;\n\
  59. return;\n\
  60. }\n\
  61. #endif\n\
  62. \n\
  63. computeScattering(\n\
  64. primaryRay,\n\
  65. length(cameraToPositionWC),\n\
  66. lightDirection,\n\
  67. atmosphereInnerRadius,\n\
  68. rayleighColor,\n\
  69. mieColor,\n\
  70. opacity\n\
  71. );\n\
  72. \n\
  73. // Alter the opacity based on how close the viewer is to the ground.\n\
  74. // (0.0 = At edge of atmosphere, 1.0 = On ground)\n\
  75. float cameraHeight = czm_eyeHeight + atmosphereInnerRadius;\n\
  76. float atmosphereOuterRadius = atmosphereInnerRadius + ATMOSPHERE_THICKNESS;\n\
  77. opacity = clamp((atmosphereOuterRadius - cameraHeight) / (atmosphereOuterRadius - atmosphereInnerRadius), 0.0, 1.0);\n\
  78. \n\
  79. // Alter alpha based on time of day (0.0 = night , 1.0 = day)\n\
  80. float nightAlpha = (u_radiiAndDynamicAtmosphereColor.z != 0.0) ? clamp(dot(normalize(positionWC), lightDirection), 0.0, 1.0) : 1.0;\n\
  81. opacity *= pow(nightAlpha, 0.5);\n\
  82. }\n\
  83. ";