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

PointPrimitiveCollectionVS.js 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "uniform float u_maxTotalPointSize;\n\
  3. \n\
  4. in vec4 positionHighAndSize;\n\
  5. in vec4 positionLowAndOutline;\n\
  6. in vec4 compressedAttribute0; // color, outlineColor, pick color\n\
  7. in vec4 compressedAttribute1; // show, translucency by distance, some free space\n\
  8. in vec4 scaleByDistance; // near, nearScale, far, farScale\n\
  9. in vec4 distanceDisplayConditionAndDisableDepthAndSplitDirection; // near, far, disableDepthTestDistance, splitDirection\n\
  10. \n\
  11. out vec4 v_color;\n\
  12. out vec4 v_outlineColor;\n\
  13. out float v_innerPercent;\n\
  14. out float v_pixelDistance;\n\
  15. out vec4 v_pickColor;\n\
  16. out float v_splitDirection;\n\
  17. \n\
  18. const float SHIFT_LEFT8 = 256.0;\n\
  19. const float SHIFT_RIGHT8 = 1.0 / 256.0;\n\
  20. \n\
  21. void main()\n\
  22. {\n\
  23. // Modifying this shader may also require modifications to PointPrimitive._computeScreenSpacePosition\n\
  24. \n\
  25. // unpack attributes\n\
  26. vec3 positionHigh = positionHighAndSize.xyz;\n\
  27. vec3 positionLow = positionLowAndOutline.xyz;\n\
  28. float outlineWidthBothSides = 2.0 * positionLowAndOutline.w;\n\
  29. float totalSize = positionHighAndSize.w + outlineWidthBothSides;\n\
  30. float outlinePercent = outlineWidthBothSides / totalSize;\n\
  31. // Scale in response to browser-zoom.\n\
  32. totalSize *= czm_pixelRatio;\n\
  33. \n\
  34. float temp = compressedAttribute1.x * SHIFT_RIGHT8;\n\
  35. float show = floor(temp);\n\
  36. \n\
  37. #ifdef EYE_DISTANCE_TRANSLUCENCY\n\
  38. vec4 translucencyByDistance;\n\
  39. translucencyByDistance.x = compressedAttribute1.z;\n\
  40. translucencyByDistance.z = compressedAttribute1.w;\n\
  41. \n\
  42. translucencyByDistance.y = ((temp - floor(temp)) * SHIFT_LEFT8) / 255.0;\n\
  43. \n\
  44. temp = compressedAttribute1.y * SHIFT_RIGHT8;\n\
  45. translucencyByDistance.w = ((temp - floor(temp)) * SHIFT_LEFT8) / 255.0;\n\
  46. #endif\n\
  47. \n\
  48. ///////////////////////////////////////////////////////////////////////////\n\
  49. \n\
  50. vec4 color = czm_decodeRGB8(compressedAttribute0.x);\n\
  51. vec4 outlineColor = czm_decodeRGB8(compressedAttribute0.y);\n\
  52. vec4 pickColor = czm_decodeRGB8(compressedAttribute0.z);\n\
  53. vec4 alphaPacked = czm_decodeRGB8(compressedAttribute0.w);\n\
  54. \n\
  55. color.a = alphaPacked.x;\n\
  56. outlineColor.a = alphaPacked.y;\n\
  57. pickColor.a = alphaPacked.z;\n\
  58. \n\
  59. ///////////////////////////////////////////////////////////////////////////\n\
  60. \n\
  61. vec4 p = czm_translateRelativeToEye(positionHigh, positionLow);\n\
  62. vec4 positionEC = czm_modelViewRelativeToEye * p;\n\
  63. \n\
  64. ///////////////////////////////////////////////////////////////////////////\n\
  65. \n\
  66. #if defined(EYE_DISTANCE_SCALING) || defined(EYE_DISTANCE_TRANSLUCENCY) || defined(DISTANCE_DISPLAY_CONDITION) || defined(DISABLE_DEPTH_DISTANCE)\n\
  67. float lengthSq;\n\
  68. if (czm_sceneMode == czm_sceneMode2D)\n\
  69. {\n\
  70. // 2D camera distance is a special case\n\
  71. // treat all billboards as flattened to the z=0.0 plane\n\
  72. lengthSq = czm_eyeHeight2D.y;\n\
  73. }\n\
  74. else\n\
  75. {\n\
  76. lengthSq = dot(positionEC.xyz, positionEC.xyz);\n\
  77. }\n\
  78. #endif\n\
  79. \n\
  80. #ifdef EYE_DISTANCE_SCALING\n\
  81. totalSize *= czm_nearFarScalar(scaleByDistance, lengthSq);\n\
  82. #endif\n\
  83. if (totalSize > 0.0) {\n\
  84. // Add padding for anti-aliasing on both sides.\n\
  85. totalSize += 3.0;\n\
  86. }\n\
  87. \n\
  88. // Clamp to max point size.\n\
  89. totalSize = min(totalSize, u_maxTotalPointSize);\n\
  90. // If size is too small, push vertex behind near plane for clipping.\n\
  91. // Note that context.minimumAliasedPointSize \"will be at most 1.0\".\n\
  92. if (totalSize < 1.0)\n\
  93. {\n\
  94. positionEC.xyz = vec3(0.0);\n\
  95. totalSize = 1.0;\n\
  96. }\n\
  97. \n\
  98. float translucency = 1.0;\n\
  99. #ifdef EYE_DISTANCE_TRANSLUCENCY\n\
  100. translucency = czm_nearFarScalar(translucencyByDistance, lengthSq);\n\
  101. // push vertex behind near plane for clipping\n\
  102. if (translucency < 0.004)\n\
  103. {\n\
  104. positionEC.xyz = vec3(0.0);\n\
  105. }\n\
  106. #endif\n\
  107. \n\
  108. #ifdef DISTANCE_DISPLAY_CONDITION\n\
  109. float nearSq = distanceDisplayConditionAndDisableDepthAndSplitDirection.x;\n\
  110. float farSq = distanceDisplayConditionAndDisableDepthAndSplitDirection.y;\n\
  111. if (lengthSq < nearSq || lengthSq > farSq) {\n\
  112. // push vertex behind camera to force it to be clipped\n\
  113. positionEC.xyz = vec3(0.0, 0.0, 1.0);\n\
  114. }\n\
  115. #endif\n\
  116. \n\
  117. gl_Position = czm_projection * positionEC;\n\
  118. czm_vertexLogDepth();\n\
  119. \n\
  120. #ifdef DISABLE_DEPTH_DISTANCE\n\
  121. float disableDepthTestDistance = distanceDisplayConditionAndDisableDepthAndSplitDirection.z;\n\
  122. if (disableDepthTestDistance == 0.0 && czm_minimumDisableDepthTestDistance != 0.0)\n\
  123. {\n\
  124. disableDepthTestDistance = czm_minimumDisableDepthTestDistance;\n\
  125. }\n\
  126. \n\
  127. if (disableDepthTestDistance != 0.0)\n\
  128. {\n\
  129. // Don't try to \"multiply both sides\" by w. Greater/less-than comparisons won't work for negative values of w.\n\
  130. float zclip = gl_Position.z / gl_Position.w;\n\
  131. bool clipped = (zclip < -1.0 || zclip > 1.0);\n\
  132. if (!clipped && (disableDepthTestDistance < 0.0 || (lengthSq > 0.0 && lengthSq < disableDepthTestDistance)))\n\
  133. {\n\
  134. // Position z on the near plane.\n\
  135. gl_Position.z = -gl_Position.w;\n\
  136. #ifdef LOG_DEPTH\n\
  137. czm_vertexLogDepth(vec4(czm_currentFrustum.x));\n\
  138. #endif\n\
  139. }\n\
  140. }\n\
  141. #endif\n\
  142. \n\
  143. v_color = color;\n\
  144. v_color.a *= translucency * show;\n\
  145. v_outlineColor = outlineColor;\n\
  146. v_outlineColor.a *= translucency * show;\n\
  147. \n\
  148. v_innerPercent = 1.0 - outlinePercent;\n\
  149. v_pixelDistance = 2.0 / totalSize;\n\
  150. gl_PointSize = totalSize * show;\n\
  151. gl_Position *= show;\n\
  152. \n\
  153. v_pickColor = pickColor;\n\
  154. v_splitDirection = distanceDisplayConditionAndDisableDepthAndSplitDirection.w;\n\
  155. }\n\
  156. ";