PolylineShadowVolumeVS.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "attribute vec3 position3DHigh;\n\
  3. attribute vec3 position3DLow;\n\
  4. #ifndef COLUMBUS_VIEW_2D\n\
  5. attribute vec4 startHiAndForwardOffsetX;\n\
  6. attribute vec4 startLoAndForwardOffsetY;\n\
  7. attribute vec4 startNormalAndForwardOffsetZ;\n\
  8. attribute vec4 endNormalAndTextureCoordinateNormalizationX;\n\
  9. attribute vec4 rightNormalAndTextureCoordinateNormalizationY;\n\
  10. #else\n\
  11. attribute vec4 startHiLo2D;\n\
  12. attribute vec4 offsetAndRight2D;\n\
  13. attribute vec4 startEndNormals2D;\n\
  14. attribute vec2 texcoordNormalization2D;\n\
  15. #endif\n\
  16. attribute float batchId;\n\
  17. varying vec4 v_startPlaneNormalEcAndHalfWidth;\n\
  18. varying vec4 v_endPlaneNormalEcAndBatchId;\n\
  19. varying vec4 v_rightPlaneEC;\n\
  20. varying vec4 v_endEcAndStartEcX;\n\
  21. varying vec4 v_texcoordNormalizationAndStartEcYZ;\n\
  22. #ifdef WIDTH_VARYING\n\
  23. varying float v_width;\n\
  24. #endif\n\
  25. #ifdef ANGLE_VARYING\n\
  26. varying float v_polylineAngle;\n\
  27. #endif\n\
  28. #ifdef PER_INSTANCE_COLOR\n\
  29. varying vec4 v_color;\n\
  30. #endif\n\
  31. void main()\n\
  32. {\n\
  33. #ifdef COLUMBUS_VIEW_2D\n\
  34. vec3 ecStart = (czm_modelViewRelativeToEye * czm_translateRelativeToEye(vec3(0.0, startHiLo2D.xy), vec3(0.0, startHiLo2D.zw))).xyz;\n\
  35. vec3 forwardDirectionEC = czm_normal * vec3(0.0, offsetAndRight2D.xy);\n\
  36. vec3 ecEnd = forwardDirectionEC + ecStart;\n\
  37. forwardDirectionEC = normalize(forwardDirectionEC);\n\
  38. v_rightPlaneEC.xyz = czm_normal * vec3(0.0, offsetAndRight2D.zw);\n\
  39. v_rightPlaneEC.w = -dot(v_rightPlaneEC.xyz, ecStart);\n\
  40. vec4 startPlaneEC;\n\
  41. startPlaneEC.xyz = czm_normal * vec3(0.0, startEndNormals2D.xy);\n\
  42. startPlaneEC.w = -dot(startPlaneEC.xyz, ecStart);\n\
  43. vec4 endPlaneEC;\n\
  44. endPlaneEC.xyz = czm_normal * vec3(0.0, startEndNormals2D.zw);\n\
  45. endPlaneEC.w = -dot(endPlaneEC.xyz, ecEnd);\n\
  46. v_texcoordNormalizationAndStartEcYZ.x = abs(texcoordNormalization2D.x);\n\
  47. v_texcoordNormalizationAndStartEcYZ.y = texcoordNormalization2D.y;\n\
  48. #else // COLUMBUS_VIEW_2D\n\
  49. vec3 ecStart = (czm_modelViewRelativeToEye * czm_translateRelativeToEye(startHiAndForwardOffsetX.xyz, startLoAndForwardOffsetY.xyz)).xyz;\n\
  50. vec3 offset = czm_normal * vec3(startHiAndForwardOffsetX.w, startLoAndForwardOffsetY.w, startNormalAndForwardOffsetZ.w);\n\
  51. vec3 ecEnd = ecStart + offset;\n\
  52. vec3 forwardDirectionEC = normalize(offset);\n\
  53. vec4 startPlaneEC;\n\
  54. startPlaneEC.xyz = czm_normal * startNormalAndForwardOffsetZ.xyz;\n\
  55. startPlaneEC.w = -dot(startPlaneEC.xyz, ecStart);\n\
  56. vec4 endPlaneEC;\n\
  57. endPlaneEC.xyz = czm_normal * endNormalAndTextureCoordinateNormalizationX.xyz;\n\
  58. endPlaneEC.w = -dot(endPlaneEC.xyz, ecEnd);\n\
  59. v_rightPlaneEC.xyz = czm_normal * rightNormalAndTextureCoordinateNormalizationY.xyz;\n\
  60. v_rightPlaneEC.w = -dot(v_rightPlaneEC.xyz, ecStart);\n\
  61. v_texcoordNormalizationAndStartEcYZ.x = abs(endNormalAndTextureCoordinateNormalizationX.w);\n\
  62. v_texcoordNormalizationAndStartEcYZ.y = rightNormalAndTextureCoordinateNormalizationY.w;\n\
  63. #endif // COLUMBUS_VIEW_2D\n\
  64. v_endEcAndStartEcX.xyz = ecEnd;\n\
  65. v_endEcAndStartEcX.w = ecStart.x;\n\
  66. v_texcoordNormalizationAndStartEcYZ.zw = ecStart.yz;\n\
  67. #ifdef PER_INSTANCE_COLOR\n\
  68. v_color = czm_batchTable_color(batchId);\n\
  69. #endif // PER_INSTANCE_COLOR\n\
  70. vec4 positionRelativeToEye = czm_computePosition();\n\
  71. vec4 positionEC = czm_modelViewRelativeToEye * positionRelativeToEye;\n\
  72. float absStartPlaneDistance = abs(czm_planeDistance(startPlaneEC, positionEC.xyz));\n\
  73. float absEndPlaneDistance = abs(czm_planeDistance(endPlaneEC, positionEC.xyz));\n\
  74. vec3 planeDirection = czm_branchFreeTernary(absStartPlaneDistance < absEndPlaneDistance, startPlaneEC.xyz, endPlaneEC.xyz);\n\
  75. vec3 upOrDown = normalize(cross(v_rightPlaneEC.xyz, planeDirection));\n\
  76. vec3 normalEC = normalize(cross(planeDirection, upOrDown));\n\
  77. upOrDown = cross(forwardDirectionEC, normalEC);\n\
  78. upOrDown = float(czm_sceneMode == czm_sceneMode3D) * upOrDown;\n\
  79. upOrDown = float(v_texcoordNormalizationAndStartEcYZ.y > 1.0 || v_texcoordNormalizationAndStartEcYZ.y < 0.0) * upOrDown;\n\
  80. upOrDown = min(GLOBE_MINIMUM_ALTITUDE, czm_geometricToleranceOverMeter * length(positionRelativeToEye.xyz)) * upOrDown;\n\
  81. positionEC.xyz += upOrDown;\n\
  82. v_texcoordNormalizationAndStartEcYZ.y = czm_branchFreeTernary(v_texcoordNormalizationAndStartEcYZ.y > 1.0, 0.0, abs(v_texcoordNormalizationAndStartEcYZ.y));\n\
  83. float width = czm_batchTable_width(batchId);\n\
  84. #ifdef WIDTH_VARYING\n\
  85. v_width = width;\n\
  86. #endif\n\
  87. v_startPlaneNormalEcAndHalfWidth.xyz = startPlaneEC.xyz;\n\
  88. v_startPlaneNormalEcAndHalfWidth.w = width * 0.5;\n\
  89. v_endPlaneNormalEcAndBatchId.xyz = endPlaneEC.xyz;\n\
  90. v_endPlaneNormalEcAndBatchId.w = batchId;\n\
  91. width = width * max(0.0, czm_metersPerPixel(positionEC));\n\
  92. width = width / dot(normalEC, v_rightPlaneEC.xyz);\n\
  93. #ifdef COLUMBUS_VIEW_2D\n\
  94. normalEC *= sign(texcoordNormalization2D.x);\n\
  95. #else\n\
  96. normalEC *= sign(endNormalAndTextureCoordinateNormalizationX.w);\n\
  97. #endif\n\
  98. positionEC.xyz += width * normalEC;\n\
  99. gl_Position = czm_depthClampFarPlane(czm_projection * positionEC);\n\
  100. #ifdef ANGLE_VARYING\n\
  101. vec2 approxLineDirection = normalize(vec2(forwardDirectionEC.x, -forwardDirectionEC.y));\n\
  102. approxLineDirection.y = czm_branchFreeTernary(approxLineDirection.x == 0.0 && approxLineDirection.y == 0.0, -1.0, approxLineDirection.y);\n\
  103. v_polylineAngle = czm_fastApproximateAtan(approxLineDirection.x, approxLineDirection.y);\n\
  104. #endif\n\
  105. }\n\
  106. ";