ShadowVolumeAppearanceVS.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "in vec3 position3DHigh;\n\
  3. in vec3 position3DLow;\n\
  4. in float batchId;\n\
  5. \n\
  6. #ifdef EXTRUDED_GEOMETRY\n\
  7. in vec3 extrudeDirection;\n\
  8. \n\
  9. uniform float u_globeMinimumAltitude;\n\
  10. #endif // EXTRUDED_GEOMETRY\n\
  11. \n\
  12. #ifdef PER_INSTANCE_COLOR\n\
  13. out vec4 v_color;\n\
  14. #endif // PER_INSTANCE_COLOR\n\
  15. \n\
  16. #ifdef TEXTURE_COORDINATES\n\
  17. #ifdef SPHERICAL\n\
  18. out vec4 v_sphericalExtents;\n\
  19. #else // SPHERICAL\n\
  20. out vec2 v_inversePlaneExtents;\n\
  21. out vec4 v_westPlane;\n\
  22. out vec4 v_southPlane;\n\
  23. #endif // SPHERICAL\n\
  24. out vec3 v_uvMinAndSphericalLongitudeRotation;\n\
  25. out vec3 v_uMaxAndInverseDistance;\n\
  26. out vec3 v_vMaxAndInverseDistance;\n\
  27. #endif // TEXTURE_COORDINATES\n\
  28. \n\
  29. void main()\n\
  30. {\n\
  31. vec4 position = czm_computePosition();\n\
  32. \n\
  33. #ifdef EXTRUDED_GEOMETRY\n\
  34. float delta = min(u_globeMinimumAltitude, czm_geometricToleranceOverMeter * length(position.xyz));\n\
  35. delta *= czm_sceneMode == czm_sceneMode3D ? 1.0 : 0.0;\n\
  36. \n\
  37. //extrudeDirection is zero for the top layer\n\
  38. position = position + vec4(extrudeDirection * delta, 0.0);\n\
  39. #endif\n\
  40. \n\
  41. #ifdef TEXTURE_COORDINATES\n\
  42. #ifdef SPHERICAL\n\
  43. v_sphericalExtents = czm_batchTable_sphericalExtents(batchId);\n\
  44. v_uvMinAndSphericalLongitudeRotation.z = czm_batchTable_longitudeRotation(batchId);\n\
  45. #else // SPHERICAL\n\
  46. #ifdef COLUMBUS_VIEW_2D\n\
  47. vec4 planes2D_high = czm_batchTable_planes2D_HIGH(batchId);\n\
  48. vec4 planes2D_low = czm_batchTable_planes2D_LOW(batchId);\n\
  49. \n\
  50. // If the primitive is split across the IDL (planes2D_high.x > planes2D_high.w):\n\
  51. // - If this vertex is on the east side of the IDL (position3DLow.y > 0.0, comparison with position3DHigh may produce artifacts)\n\
  52. // - existing \"east\" is on the wrong side of the world, far away (planes2D_high/low.w)\n\
  53. // - so set \"east\" as beyond the eastmost extent of the projection (idlSplitNewPlaneHiLow)\n\
  54. vec2 idlSplitNewPlaneHiLow = vec2(EAST_MOST_X_HIGH - (WEST_MOST_X_HIGH - planes2D_high.w), EAST_MOST_X_LOW - (WEST_MOST_X_LOW - planes2D_low.w));\n\
  55. bool idlSplit = planes2D_high.x > planes2D_high.w && position3DLow.y > 0.0;\n\
  56. planes2D_high.w = czm_branchFreeTernary(idlSplit, idlSplitNewPlaneHiLow.x, planes2D_high.w);\n\
  57. planes2D_low.w = czm_branchFreeTernary(idlSplit, idlSplitNewPlaneHiLow.y, planes2D_low.w);\n\
  58. \n\
  59. // - else, if this vertex is on the west side of the IDL (position3DLow.y < 0.0)\n\
  60. // - existing \"west\" is on the wrong side of the world, far away (planes2D_high/low.x)\n\
  61. // - so set \"west\" as beyond the westmost extent of the projection (idlSplitNewPlaneHiLow)\n\
  62. idlSplit = planes2D_high.x > planes2D_high.w && position3DLow.y < 0.0;\n\
  63. idlSplitNewPlaneHiLow = vec2(WEST_MOST_X_HIGH - (EAST_MOST_X_HIGH - planes2D_high.x), WEST_MOST_X_LOW - (EAST_MOST_X_LOW - planes2D_low.x));\n\
  64. planes2D_high.x = czm_branchFreeTernary(idlSplit, idlSplitNewPlaneHiLow.x, planes2D_high.x);\n\
  65. planes2D_low.x = czm_branchFreeTernary(idlSplit, idlSplitNewPlaneHiLow.y, planes2D_low.x);\n\
  66. \n\
  67. vec3 southWestCorner = (czm_modelViewRelativeToEye * czm_translateRelativeToEye(vec3(0.0, planes2D_high.xy), vec3(0.0, planes2D_low.xy))).xyz;\n\
  68. vec3 northWestCorner = (czm_modelViewRelativeToEye * czm_translateRelativeToEye(vec3(0.0, planes2D_high.x, planes2D_high.z), vec3(0.0, planes2D_low.x, planes2D_low.z))).xyz;\n\
  69. vec3 southEastCorner = (czm_modelViewRelativeToEye * czm_translateRelativeToEye(vec3(0.0, planes2D_high.w, planes2D_high.y), vec3(0.0, planes2D_low.w, planes2D_low.y))).xyz;\n\
  70. #else // COLUMBUS_VIEW_2D\n\
  71. // 3D case has smaller \"plane extents,\" so planes encoded as a 64 bit position and 2 vec3s for distances/direction\n\
  72. vec3 southWestCorner = (czm_modelViewRelativeToEye * czm_translateRelativeToEye(czm_batchTable_southWest_HIGH(batchId), czm_batchTable_southWest_LOW(batchId))).xyz;\n\
  73. vec3 northWestCorner = czm_normal * czm_batchTable_northward(batchId) + southWestCorner;\n\
  74. vec3 southEastCorner = czm_normal * czm_batchTable_eastward(batchId) + southWestCorner;\n\
  75. #endif // COLUMBUS_VIEW_2D\n\
  76. \n\
  77. vec3 eastWard = southEastCorner - southWestCorner;\n\
  78. float eastExtent = length(eastWard);\n\
  79. eastWard /= eastExtent;\n\
  80. \n\
  81. vec3 northWard = northWestCorner - southWestCorner;\n\
  82. float northExtent = length(northWard);\n\
  83. northWard /= northExtent;\n\
  84. \n\
  85. v_westPlane = vec4(eastWard, -dot(eastWard, southWestCorner));\n\
  86. v_southPlane = vec4(northWard, -dot(northWard, southWestCorner));\n\
  87. v_inversePlaneExtents = vec2(1.0 / eastExtent, 1.0 / northExtent);\n\
  88. #endif // SPHERICAL\n\
  89. vec4 uvMinAndExtents = czm_batchTable_uvMinAndExtents(batchId);\n\
  90. vec4 uMaxVmax = czm_batchTable_uMaxVmax(batchId);\n\
  91. \n\
  92. v_uMaxAndInverseDistance = vec3(uMaxVmax.xy, uvMinAndExtents.z);\n\
  93. v_vMaxAndInverseDistance = vec3(uMaxVmax.zw, uvMinAndExtents.w);\n\
  94. v_uvMinAndSphericalLongitudeRotation.xy = uvMinAndExtents.xy;\n\
  95. #endif // TEXTURE_COORDINATES\n\
  96. \n\
  97. #ifdef PER_INSTANCE_COLOR\n\
  98. v_color = czm_batchTable_color(batchId);\n\
  99. #endif\n\
  100. \n\
  101. gl_Position = czm_depthClamp(czm_modelViewProjectionRelativeToEye * position);\n\
  102. }\n\
  103. ";