PointPrimitiveCollectionVS.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "uniform float u_maxTotalPointSize;\n\
  3. attribute vec4 positionHighAndSize;\n\
  4. attribute vec4 positionLowAndOutline;\n\
  5. attribute vec4 compressedAttribute0;\n\
  6. attribute vec4 compressedAttribute1;\n\
  7. attribute vec4 scaleByDistance;\n\
  8. attribute vec3 distanceDisplayConditionAndDisableDepth;\n\
  9. varying vec4 v_color;\n\
  10. varying vec4 v_outlineColor;\n\
  11. varying float v_innerPercent;\n\
  12. varying float v_pixelDistance;\n\
  13. varying vec4 v_pickColor;\n\
  14. const float SHIFT_LEFT8 = 256.0;\n\
  15. const float SHIFT_RIGHT8 = 1.0 / 256.0;\n\
  16. void main()\n\
  17. {\n\
  18. vec3 positionHigh = positionHighAndSize.xyz;\n\
  19. vec3 positionLow = positionLowAndOutline.xyz;\n\
  20. float outlineWidthBothSides = 2.0 * positionLowAndOutline.w;\n\
  21. float totalSize = positionHighAndSize.w + outlineWidthBothSides;\n\
  22. float outlinePercent = outlineWidthBothSides / totalSize;\n\
  23. totalSize *= czm_pixelRatio;\n\
  24. totalSize += 3.0;\n\
  25. float temp = compressedAttribute1.x * SHIFT_RIGHT8;\n\
  26. float show = floor(temp);\n\
  27. #ifdef EYE_DISTANCE_TRANSLUCENCY\n\
  28. vec4 translucencyByDistance;\n\
  29. translucencyByDistance.x = compressedAttribute1.z;\n\
  30. translucencyByDistance.z = compressedAttribute1.w;\n\
  31. translucencyByDistance.y = ((temp - floor(temp)) * SHIFT_LEFT8) / 255.0;\n\
  32. temp = compressedAttribute1.y * SHIFT_RIGHT8;\n\
  33. translucencyByDistance.w = ((temp - floor(temp)) * SHIFT_LEFT8) / 255.0;\n\
  34. #endif\n\
  35. vec4 color;\n\
  36. vec4 outlineColor;\n\
  37. vec4 pickColor;\n\
  38. temp = compressedAttribute0.z * SHIFT_RIGHT8;\n\
  39. pickColor.b = (temp - floor(temp)) * SHIFT_LEFT8;\n\
  40. temp = floor(temp) * SHIFT_RIGHT8;\n\
  41. pickColor.g = (temp - floor(temp)) * SHIFT_LEFT8;\n\
  42. pickColor.r = floor(temp);\n\
  43. temp = compressedAttribute0.x * SHIFT_RIGHT8;\n\
  44. color.b = (temp - floor(temp)) * SHIFT_LEFT8;\n\
  45. temp = floor(temp) * SHIFT_RIGHT8;\n\
  46. color.g = (temp - floor(temp)) * SHIFT_LEFT8;\n\
  47. color.r = floor(temp);\n\
  48. temp = compressedAttribute0.y * SHIFT_RIGHT8;\n\
  49. outlineColor.b = (temp - floor(temp)) * SHIFT_LEFT8;\n\
  50. temp = floor(temp) * SHIFT_RIGHT8;\n\
  51. outlineColor.g = (temp - floor(temp)) * SHIFT_LEFT8;\n\
  52. outlineColor.r = floor(temp);\n\
  53. temp = compressedAttribute0.w * SHIFT_RIGHT8;\n\
  54. pickColor.a = (temp - floor(temp)) * SHIFT_LEFT8;\n\
  55. pickColor = pickColor / 255.0;\n\
  56. temp = floor(temp) * SHIFT_RIGHT8;\n\
  57. outlineColor.a = (temp - floor(temp)) * SHIFT_LEFT8;\n\
  58. outlineColor /= 255.0;\n\
  59. color.a = floor(temp);\n\
  60. color /= 255.0;\n\
  61. vec4 p = czm_translateRelativeToEye(positionHigh, positionLow);\n\
  62. vec4 positionEC = czm_modelViewRelativeToEye * p;\n\
  63. #if defined(EYE_DISTANCE_SCALING) || defined(EYE_DISTANCE_TRANSLUCENCY) || defined(DISTANCE_DISPLAY_CONDITION) || defined(DISABLE_DEPTH_DISTANCE)\n\
  64. float lengthSq;\n\
  65. if (czm_sceneMode == czm_sceneMode2D)\n\
  66. {\n\
  67. lengthSq = czm_eyeHeight2D.y;\n\
  68. }\n\
  69. else\n\
  70. {\n\
  71. lengthSq = dot(positionEC.xyz, positionEC.xyz);\n\
  72. }\n\
  73. #endif\n\
  74. #ifdef EYE_DISTANCE_SCALING\n\
  75. totalSize *= czm_nearFarScalar(scaleByDistance, lengthSq);\n\
  76. #endif\n\
  77. totalSize = min(totalSize, u_maxTotalPointSize);\n\
  78. if (totalSize < 1.0)\n\
  79. {\n\
  80. positionEC.xyz = vec3(0.0);\n\
  81. totalSize = 1.0;\n\
  82. }\n\
  83. float translucency = 1.0;\n\
  84. #ifdef EYE_DISTANCE_TRANSLUCENCY\n\
  85. translucency = czm_nearFarScalar(translucencyByDistance, lengthSq);\n\
  86. if (translucency < 0.004)\n\
  87. {\n\
  88. positionEC.xyz = vec3(0.0);\n\
  89. }\n\
  90. #endif\n\
  91. #ifdef DISTANCE_DISPLAY_CONDITION\n\
  92. float nearSq = distanceDisplayConditionAndDisableDepth.x;\n\
  93. float farSq = distanceDisplayConditionAndDisableDepth.y;\n\
  94. if (lengthSq < nearSq || lengthSq > farSq) {\n\
  95. positionEC.xyz = vec3(0.0);\n\
  96. }\n\
  97. #endif\n\
  98. gl_Position = czm_projection * positionEC;\n\
  99. czm_vertexLogDepth();\n\
  100. #ifdef DISABLE_DEPTH_DISTANCE\n\
  101. float disableDepthTestDistance = distanceDisplayConditionAndDisableDepth.z;\n\
  102. if (disableDepthTestDistance == 0.0 && czm_minimumDisableDepthTestDistance != 0.0)\n\
  103. {\n\
  104. disableDepthTestDistance = czm_minimumDisableDepthTestDistance;\n\
  105. }\n\
  106. if (disableDepthTestDistance != 0.0)\n\
  107. {\n\
  108. float zclip = gl_Position.z / gl_Position.w;\n\
  109. bool clipped = (zclip < -1.0 || zclip > 1.0);\n\
  110. if (!clipped && (disableDepthTestDistance < 0.0 || (lengthSq > 0.0 && lengthSq < disableDepthTestDistance)))\n\
  111. {\n\
  112. gl_Position.z = -gl_Position.w;\n\
  113. #ifdef LOG_DEPTH\n\
  114. czm_vertexLogDepth(vec4(czm_currentFrustum.x));\n\
  115. #endif\n\
  116. }\n\
  117. }\n\
  118. #endif\n\
  119. v_color = color;\n\
  120. v_color.a *= translucency * show;\n\
  121. v_outlineColor = outlineColor;\n\
  122. v_outlineColor.a *= translucency * show;\n\
  123. v_innerPercent = 1.0 - outlinePercent;\n\
  124. v_pixelDistance = 2.0 / totalSize;\n\
  125. gl_PointSize = totalSize * show;\n\
  126. gl_Position *= show;\n\
  127. v_pickColor = pickColor;\n\
  128. }\n\
  129. ";