@cesium/engine 21.0.1 → 22.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. package/Build/ThirdParty/Workers/zip-web-worker.js +10 -7
  2. package/Build/Workers/chunk-23T2IPHV.js +55 -0
  3. package/Build/Workers/{chunk-TGJQMEL4.js → chunk-2AM4E2WD.js} +2 -2
  4. package/Build/Workers/{chunk-4CORGH7N.js → chunk-2MWF4IES.js} +16 -14
  5. package/Build/Workers/{chunk-3RKX3UFI.js → chunk-2RCIRXNI.js} +1 -1
  6. package/Build/Workers/{chunk-LV3G32QE.js → chunk-3YTMGEXW.js} +5 -1424
  7. package/Build/Workers/{chunk-PJAA7QSC.js → chunk-4BHWJWS3.js} +6 -6
  8. package/Build/Workers/{chunk-FE565QHX.js → chunk-5JKH4AMT.js} +2 -2
  9. package/Build/Workers/{chunk-KZ7GDSAJ.js → chunk-6HKAPCSO.js} +1 -1
  10. package/Build/Workers/{chunk-VVALNLSH.js → chunk-A53R2F2L.js} +4 -4
  11. package/Build/Workers/{chunk-KVB73ECP.js → chunk-A6YFUGJO.js} +7 -7
  12. package/Build/Workers/{chunk-QNOIRRJK.js → chunk-AJYWXC6I.js} +4 -4
  13. package/Build/Workers/{chunk-UKA7OISV.js → chunk-AOIO5VUS.js} +282 -2284
  14. package/Build/Workers/{chunk-OBS5EMZ6.js → chunk-B7JRBTT6.js} +10 -10
  15. package/Build/Workers/{chunk-5YXA47QD.js → chunk-CHNDJRYA.js} +20 -18
  16. package/Build/Workers/{chunk-X3ZV3XNO.js → chunk-CJOV55CW.js} +20 -18
  17. package/Build/Workers/{chunk-W6I3LNPF.js → chunk-COGPE5Z2.js} +10 -8
  18. package/Build/Workers/{chunk-2QPH5QDK.js → chunk-CW7W27IZ.js} +14 -10
  19. package/Build/Workers/{chunk-MXOGBWMP.js → chunk-DICY26ID.js} +20 -16
  20. package/Build/Workers/{chunk-W6KMV4F5.js → chunk-DMEFNTUV.js} +69 -7
  21. package/Build/Workers/{chunk-T7HU6E7G.js → chunk-DQSJEOZY.js} +1 -1
  22. package/Build/Workers/{chunk-ASVODZNK.js → chunk-GDU4RZSZ.js} +16 -36
  23. package/Build/Workers/{chunk-MQPDOWGH.js → chunk-GKWOUMYA.js} +1 -1
  24. package/Build/Workers/{chunk-A2SP2EJZ.js → chunk-GTY4K4IA.js} +9 -7
  25. package/Build/Workers/{chunk-KEPPNSBL.js → chunk-H6Q7E4BQ.js} +8 -6
  26. package/Build/Workers/{chunk-JG3C3LPY.js → chunk-HHGOFZVQ.js} +7 -5
  27. package/Build/Workers/chunk-HXKUEOOD.js +352 -0
  28. package/Build/Workers/{chunk-UFSYRVC5.js → chunk-I4REFVXB.js} +4 -4
  29. package/Build/Workers/{chunk-LU7DLY2L.js → chunk-IL5F6WEE.js} +3 -3
  30. package/Build/Workers/{chunk-RVRN4KDB.js → chunk-JKXPC5HD.js} +2 -2
  31. package/Build/Workers/{chunk-CBPNIEGH.js → chunk-KKGD7HAW.js} +13 -11
  32. package/Build/Workers/{chunk-DTKSVIH5.js → chunk-KROSQJUA.js} +2 -2
  33. package/Build/Workers/{chunk-42EJCSIV.js → chunk-L4JLDVCM.js} +5 -5
  34. package/Build/Workers/{chunk-LPKJSIMD.js → chunk-LIYMRHGR.js} +15 -13
  35. package/Build/Workers/{chunk-J2XQVKVH.js → chunk-MKMZHRB3.js} +74 -35
  36. package/Build/Workers/{chunk-CSDYSXBI.js → chunk-MO25ZQ2I.js} +14 -12
  37. package/Build/Workers/{chunk-3YNW5K6O.js → chunk-O6RZEKHZ.js} +12 -12
  38. package/Build/Workers/{chunk-RR3NCT4R.js → chunk-OOCGX2OD.js} +4 -4
  39. package/Build/Workers/{chunk-XG54SG4O.js → chunk-OXFU5HNU.js} +13 -5
  40. package/Build/Workers/{chunk-P2UKEFCK.js → chunk-P5CGIJUY.js} +2 -2
  41. package/Build/Workers/{chunk-DBHL2UVG.js → chunk-QEANVUGT.js} +2 -2
  42. package/Build/Workers/{chunk-2SI7DEW5.js → chunk-QFBCIX7J.js} +8 -6
  43. package/Build/Workers/{chunk-DDXI6UYW.js → chunk-QUAH3XOT.js} +4 -4
  44. package/Build/Workers/{chunk-PZUZCAX3.js → chunk-RXZDTDIY.js} +13 -9
  45. package/Build/Workers/{chunk-YZ3RCE45.js → chunk-SPA2KPH3.js} +14 -12
  46. package/Build/Workers/chunk-TDSVSW5A.js +1460 -0
  47. package/Build/Workers/{chunk-G3CKZ34K.js → chunk-UG2DPFOL.js} +8 -6
  48. package/Build/Workers/{chunk-IKUOV6DO.js → chunk-URGEDZBS.js} +7 -7
  49. package/Build/Workers/{chunk-U2GR5FDL.js → chunk-V35NQOJC.js} +21 -11
  50. package/Build/Workers/chunk-W4XUEDU5.js +2058 -0
  51. package/Build/Workers/chunk-WB4TSSBQ.js +3514 -0
  52. package/Build/Workers/{chunk-EBDZDBJN.js → chunk-WTLYD4FE.js} +19 -15
  53. package/Build/Workers/{chunk-WQZL6CA2.js → chunk-Y4ALZ4SS.js} +9 -7
  54. package/Build/Workers/{chunk-DAJKOQW6.js → chunk-YF2NVO5B.js} +19 -13
  55. package/Build/Workers/{chunk-XJVRYJVZ.js → chunk-YSYSXSHF.js} +1 -1
  56. package/Build/Workers/{chunk-YNOVMSUX.js → chunk-YX562XOB.js} +15 -11
  57. package/Build/Workers/{chunk-J3KPR6DJ.js → chunk-YZWA5B4R.js} +15 -13
  58. package/Build/Workers/{chunk-NYYQZ3LH.js → chunk-Z6DFT4D3.js} +15 -11
  59. package/Build/Workers/combineGeometry.js +24 -21
  60. package/Build/Workers/createBoxGeometry.js +18 -15
  61. package/Build/Workers/createBoxOutlineGeometry.js +16 -13
  62. package/Build/Workers/createCircleGeometry.js +28 -24
  63. package/Build/Workers/createCircleOutlineGeometry.js +21 -17
  64. package/Build/Workers/createCoplanarPolygonGeometry.js +35 -31
  65. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +33 -29
  66. package/Build/Workers/createCorridorGeometry.js +32 -28
  67. package/Build/Workers/createCorridorOutlineGeometry.js +30 -26
  68. package/Build/Workers/createCylinderGeometry.js +20 -17
  69. package/Build/Workers/createCylinderOutlineGeometry.js +20 -16
  70. package/Build/Workers/createEllipseGeometry.js +28 -24
  71. package/Build/Workers/createEllipseOutlineGeometry.js +21 -17
  72. package/Build/Workers/createEllipsoidGeometry.js +19 -16
  73. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -15
  74. package/Build/Workers/createFrustumGeometry.js +18 -15
  75. package/Build/Workers/createFrustumOutlineGeometry.js +18 -15
  76. package/Build/Workers/createGeometry.js +28 -22
  77. package/Build/Workers/createGroundPolylineGeometry.js +25 -21
  78. package/Build/Workers/createPlaneGeometry.js +16 -13
  79. package/Build/Workers/createPlaneOutlineGeometry.js +15 -12
  80. package/Build/Workers/createPolygonGeometry.js +35 -31
  81. package/Build/Workers/createPolygonOutlineGeometry.js +32 -28
  82. package/Build/Workers/createPolylineGeometry.js +27 -23
  83. package/Build/Workers/createPolylineVolumeGeometry.js +33 -29
  84. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +29 -25
  85. package/Build/Workers/createRectangleGeometry.js +30 -26
  86. package/Build/Workers/createRectangleOutlineGeometry.js +23 -19
  87. package/Build/Workers/createSimplePolylineGeometry.js +25 -21
  88. package/Build/Workers/createSphereGeometry.js +19 -16
  89. package/Build/Workers/createSphereOutlineGeometry.js +18 -15
  90. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  91. package/Build/Workers/createVectorTileClampedPolylines.js +16 -13
  92. package/Build/Workers/createVectorTileGeometries.js +24 -21
  93. package/Build/Workers/createVectorTilePoints.js +15 -12
  94. package/Build/Workers/createVectorTilePolygons.js +24 -20
  95. package/Build/Workers/createVectorTilePolylines.js +16 -13
  96. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +91 -0
  97. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +28 -23
  98. package/Build/Workers/createVerticesFromHeightmap.js +28 -23
  99. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +26 -279
  100. package/Build/Workers/createWallGeometry.js +26 -22
  101. package/Build/Workers/createWallOutlineGeometry.js +25 -21
  102. package/Build/Workers/decodeDraco.js +10 -10
  103. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  104. package/Build/Workers/decodeI3S.js +13 -11
  105. package/Build/Workers/gaussianSplatSorter.js +4 -4
  106. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  107. package/Build/Workers/incrementallyBuildTerrainPicker.js +121 -0
  108. package/Build/Workers/transcodeKTX2.js +6 -6
  109. package/Build/Workers/transferTypedArrayTest.js +1 -1
  110. package/Build/Workers/upsampleQuantizedTerrainMesh.js +24 -20
  111. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +95 -0
  112. package/Source/Core/ArcGISTiledElevationTerrainProvider.js +2 -2
  113. package/Source/Core/AxisAlignedBoundingBox.js +36 -0
  114. package/Source/Core/Cesium3DTilesTerrainData.js +932 -0
  115. package/Source/Core/Cesium3DTilesTerrainGeometryProcessor.js +1868 -0
  116. package/Source/Core/Cesium3DTilesTerrainProvider.js +1052 -0
  117. package/Source/Core/CesiumTerrainProvider.js +2 -2
  118. package/Source/Core/Color.js +23 -6
  119. package/Source/Core/EllipsoidalOccluder.js +2 -2
  120. package/Source/Core/FeatureDetection.js +0 -2
  121. package/Source/Core/GoogleEarthEnterpriseMetadata.js +1 -1
  122. package/Source/Core/GoogleEarthEnterpriseTerrainData.js +2 -1
  123. package/Source/Core/GoogleEarthEnterpriseTerrainProvider.js +1 -1
  124. package/Source/Core/HeightmapTerrainData.js +12 -22
  125. package/Source/Core/HilbertOrder.js +0 -6
  126. package/Source/Core/ITwinPlatform.js +6 -6
  127. package/Source/Core/IntersectionTests.js +80 -0
  128. package/Source/Core/Ion.js +1 -1
  129. package/Source/Core/IonResource.js +35 -27
  130. package/Source/Core/PixelFormat.js +2 -2
  131. package/Source/Core/QuantizedMeshTerrainData.js +24 -57
  132. package/Source/Core/Resource.js +15 -11
  133. package/Source/Core/S2Cell.js +6 -18
  134. package/Source/Core/TaskProcessor.js +1 -1
  135. package/Source/Core/TerrainData.js +2 -1
  136. package/Source/Core/TerrainEncoding.js +215 -38
  137. package/Source/Core/TerrainMesh.js +215 -8
  138. package/Source/Core/TerrainPicker.js +607 -0
  139. package/Source/Core/TerrainProvider.js +151 -0
  140. package/Source/Core/TexturePacker.js +27 -12
  141. package/Source/Core/Transforms.js +28 -19
  142. package/Source/Core/VRTheWorldTerrainProvider.js +2 -2
  143. package/Source/Core/binarySearch.js +1 -1
  144. package/Source/Core/createWorldBathymetryAsync.js +2 -2
  145. package/Source/Core/createWorldTerrainAsync.js +3 -3
  146. package/Source/Core/loadImageFromTypedArray.js +9 -3
  147. package/Source/Core/mergeSort.js +1 -1
  148. package/Source/DataSources/BillboardGraphics.js +1 -1
  149. package/Source/DataSources/BillboardVisualizer.js +7 -4
  150. package/Source/DataSources/PropertyArray.js +2 -2
  151. package/Source/Renderer/AutomaticUniforms.js +61 -0
  152. package/Source/Renderer/Buffer.js +32 -0
  153. package/Source/Renderer/BufferUsage.js +3 -1
  154. package/Source/Renderer/Context.js +98 -14
  155. package/Source/Renderer/Pass.js +10 -9
  156. package/Source/Renderer/Sync.js +104 -0
  157. package/Source/Renderer/TextureAtlas.js +67 -27
  158. package/Source/Renderer/UniformState.js +12 -0
  159. package/Source/Renderer/VertexArray.js +1 -1
  160. package/Source/Scene/ArcGisMapServerImageryProvider.js +1 -1
  161. package/Source/Scene/ArcGisMapService.js +1 -1
  162. package/Source/Scene/Azure2DImageryProvider.js +99 -13
  163. package/Source/Scene/BatchTable.js +2 -2
  164. package/Source/Scene/Billboard.js +75 -28
  165. package/Source/Scene/BillboardCollection.js +24 -15
  166. package/Source/Scene/BillboardTexture.js +56 -7
  167. package/Source/Scene/BingMapsImageryProvider.js +1 -1
  168. package/Source/Scene/BoundingVolumeSemantics.js +54 -62
  169. package/Source/Scene/Cesium3DTile.js +3 -3
  170. package/Source/Scene/Cesium3DTilesVoxelProvider.js +1 -1
  171. package/Source/Scene/Cesium3DTileset.js +1 -1
  172. package/Source/Scene/EdgeFramebuffer.js +245 -0
  173. package/Source/Scene/FrameState.js +12 -0
  174. package/Source/Scene/GaussianSplat3DTileContent.js +12 -16
  175. package/Source/Scene/GaussianSplatPrimitive.js +12 -8
  176. package/Source/Scene/GaussianSplatSorter.js +2 -2
  177. package/Source/Scene/Globe.js +4 -2
  178. package/Source/Scene/GlobeSurfaceTile.js +28 -70
  179. package/Source/Scene/GlobeSurfaceTileProvider.js +11 -0
  180. package/Source/Scene/GltfBufferViewLoader.js +18 -0
  181. package/Source/Scene/GltfLoader.js +46 -8
  182. package/Source/Scene/Google2DImageryProvider.js +48 -41
  183. package/Source/Scene/GoogleEarthEnterpriseMapsProvider.js +1 -1
  184. package/Source/Scene/I3SDataProvider.js +1 -1
  185. package/Source/Scene/I3SDecoder.js +3 -3
  186. package/Source/Scene/ITwinData.js +4 -4
  187. package/Source/Scene/ImageryLayer.js +1 -1
  188. package/Source/Scene/Implicit3DTileContent.js +18 -7
  189. package/Source/Scene/ImplicitSubtree.js +3 -3
  190. package/Source/Scene/ImplicitTileset.js +2 -2
  191. package/Source/Scene/IonImageryProvider.js +15 -84
  192. package/Source/Scene/IonImageryProviderFactory.js +194 -0
  193. package/Source/Scene/LabelCollection.js +54 -36
  194. package/Source/Scene/MetadataComponentType.js +5 -5
  195. package/Source/Scene/MetadataTableProperty.js +3 -9
  196. package/Source/Scene/Model/EdgeDetectionPipelineStage.js +42 -0
  197. package/Source/Scene/Model/EdgeVisibilityPipelineStage.js +800 -0
  198. package/Source/Scene/Model/MetadataPipelineStage.js +7 -7
  199. package/Source/Scene/Model/ModelDrawCommand.js +69 -0
  200. package/Source/Scene/Model/ModelImagery.js +4 -0
  201. package/Source/Scene/Model/ModelRuntimeNode.js +2 -2
  202. package/Source/Scene/Model/ModelRuntimePrimitive.js +13 -2
  203. package/Source/Scene/Model/ModelSceneGraph.js +15 -3
  204. package/Source/Scene/Model/ModelUtility.js +0 -1
  205. package/Source/Scene/Model/NodeRenderResources.js +1 -1
  206. package/Source/Scene/Model/PrimitiveRenderResources.js +1 -1
  207. package/Source/Scene/OIT.js +11 -1
  208. package/Source/Scene/PickFramebuffer.js +134 -50
  209. package/Source/Scene/Picking.js +195 -89
  210. package/Source/Scene/QuadtreePrimitive.js +34 -26
  211. package/Source/Scene/QuadtreeTile.js +66 -46
  212. package/Source/Scene/ResourceLoaderState.js +1 -1
  213. package/Source/Scene/Scene.js +160 -16
  214. package/Source/Scene/ScreenSpaceCameraController.js +1 -1
  215. package/Source/Scene/SensorVolumePortionToDisplay.js +6 -6
  216. package/Source/Scene/SingleTileImageryProvider.js +3 -3
  217. package/Source/Scene/Terrain.js +5 -5
  218. package/Source/Scene/TerrainFillMesh.js +1 -0
  219. package/Source/Scene/TileMapServiceImageryProvider.js +2 -2
  220. package/Source/Scene/UrlTemplateImageryProvider.js +1 -1
  221. package/Source/Scene/View.js +3 -0
  222. package/Source/Scene/VoxelPrimitive.js +196 -189
  223. package/Source/Scene/VoxelShape.js +2 -0
  224. package/Source/Scene/createWorldImageryAsync.js +1 -1
  225. package/Source/Shaders/BillboardCollectionFS.glsl +115 -62
  226. package/Source/Shaders/BillboardCollectionFS.js +115 -63
  227. package/Source/Shaders/BillboardCollectionVS.glsl +44 -37
  228. package/Source/Shaders/BillboardCollectionVS.js +45 -38
  229. package/Source/Shaders/Builtin/Constants/passCesium3DTile.glsl +1 -1
  230. package/Source/Shaders/Builtin/Constants/passCesium3DTile.js +1 -1
  231. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassification.glsl +1 -1
  232. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassification.js +1 -1
  233. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassificationIgnoreShow.glsl +1 -1
  234. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassificationIgnoreShow.js +1 -1
  235. package/Source/Shaders/Builtin/Constants/passCesium3DTileEdges.glsl +10 -0
  236. package/Source/Shaders/Builtin/Constants/passCesium3DTileEdges.js +12 -0
  237. package/Source/Shaders/Builtin/Constants/passGaussianSplats.glsl +1 -1
  238. package/Source/Shaders/Builtin/Constants/passGaussianSplats.js +1 -1
  239. package/Source/Shaders/Builtin/Constants/passOpaque.glsl +1 -1
  240. package/Source/Shaders/Builtin/Constants/passOpaque.js +1 -1
  241. package/Source/Shaders/Builtin/Constants/passOverlay.glsl +1 -1
  242. package/Source/Shaders/Builtin/Constants/passOverlay.js +1 -1
  243. package/Source/Shaders/Builtin/Constants/passTranslucent.glsl +1 -1
  244. package/Source/Shaders/Builtin/Constants/passTranslucent.js +1 -1
  245. package/Source/Shaders/Builtin/Constants/passVoxels.glsl +1 -1
  246. package/Source/Shaders/Builtin/Constants/passVoxels.js +1 -1
  247. package/Source/Shaders/Builtin/CzmBuiltins.js +2 -0
  248. package/Source/Shaders/GlobeVS.glsl +1 -1
  249. package/Source/Shaders/GlobeVS.js +1 -1
  250. package/Source/Shaders/Model/EdgeDetectionStageFS.glsl +58 -0
  251. package/Source/Shaders/Model/EdgeDetectionStageFS.js +60 -0
  252. package/Source/Shaders/Model/EdgeVisibilityStageFS.glsl +83 -0
  253. package/Source/Shaders/Model/EdgeVisibilityStageFS.js +85 -0
  254. package/Source/Shaders/Model/ModelFS.glsl +5 -0
  255. package/Source/Shaders/Model/ModelFS.js +5 -0
  256. package/Source/Shaders/Model/PrimitiveOutlineStageFS.glsl +0 -1
  257. package/Source/Shaders/Model/PrimitiveOutlineStageFS.js +0 -1
  258. package/Source/Shaders/ShadowVolumeAppearanceFS.glsl +7 -15
  259. package/Source/Shaders/ShadowVolumeAppearanceFS.js +7 -15
  260. package/Source/ThirdParty/Workers/zip-web-worker.js +1 -1
  261. package/Source/ThirdParty/zip-module.wasm +0 -0
  262. package/Source/Workers/createVerticesFromCesium3DTilesTerrain.js +46 -0
  263. package/Source/Workers/incrementallyBuildTerrainPicker.js +108 -0
  264. package/Source/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +55 -0
  265. package/index.d.ts +488 -31
  266. package/index.js +202 -190
  267. package/package.json +3 -2
@@ -1,5 +1,6 @@
1
1
  //This file is automatically rebuilt by the Cesium build process.
2
- export default "#ifdef INSTANCED\n\
2
+ export default "uniform float u_threePointDepthTestDistance;\n\
3
+ #ifdef INSTANCED\n\
3
4
  in vec2 direction;\n\
4
5
  #endif\n\
5
6
  in vec4 positionHighAndScale;\n\
@@ -10,10 +11,10 @@ in vec4 compressedAttribute2; // label horizontal origin,
10
11
  in vec4 eyeOffset; // eye offset in meters, 4 bytes free (texture range)\n\
11
12
  in vec4 scaleByDistance; // near, nearScale, far, farScale\n\
12
13
  in vec4 pixelOffsetScaleByDistance; // near, nearScale, far, farScale\n\
13
- in vec4 compressedAttribute3; // distance display condition near, far, disableDepthTestDistance, dimensions\n\
14
+ in vec4 compressedAttribute3; // distance display condition near, far, disableDepthTestDistanceSq, dimensions\n\
14
15
  in vec2 sdf; // sdf outline color (rgb) and width (w)\n\
15
16
  in float splitDirection; // splitDirection\n\
16
- #if defined(VERTEX_DEPTH_CHECK) || defined(FRAGMENT_DEPTH_CHECK)\n\
17
+ #if defined(VS_THREE_POINT_DEPTH_CHECK) || defined(FS_THREE_POINT_DEPTH_CHECK)\n\
17
18
  in vec4 textureCoordinateBoundsOrLabelTranslate; // the min and max x and y values for the texture coordinates\n\
18
19
  #endif\n\
19
20
  #ifdef VECTOR_TILE\n\
@@ -21,12 +22,12 @@ in float a_batchId;\n\
21
22
  #endif\n\
22
23
  \n\
23
24
  out vec2 v_textureCoordinates;\n\
24
- #ifdef FRAGMENT_DEPTH_CHECK\n\
25
+ #ifdef FS_THREE_POINT_DEPTH_CHECK\n\
25
26
  out vec4 v_textureCoordinateBounds;\n\
26
27
  out vec4 v_originTextureCoordinateAndTranslate;\n\
27
- out vec4 v_compressed; // x: eyeDepth, y: applyTranslate & enableDepthCheck, z: dimensions, w: imageSize\n\
28
28
  out mat2 v_rotationMatrix;\n\
29
29
  #endif\n\
30
+ out vec4 v_compressed; // x: eyeDepth, y: applyTranslate & enableDepthCheck, z: dimensions, w: imageSize\n\
30
31
  \n\
31
32
  out vec4 v_pickColor;\n\
32
33
  out vec4 v_color;\n\
@@ -93,7 +94,7 @@ vec4 addScreenSpaceOffset(vec4 positionEC, vec2 imageSize, float scale, vec2 dir
93
94
  return positionEC;\n\
94
95
  }\n\
95
96
  \n\
96
- #ifdef VERTEX_DEPTH_CHECK\n\
97
+ #ifdef VS_THREE_POINT_DEPTH_CHECK\n\
97
98
  float getGlobeDepth(vec4 positionEC)\n\
98
99
  {\n\
99
100
  vec4 posWC = czm_eyeToWindowCoordinates(positionEC);\n\
@@ -138,7 +139,7 @@ void main()\n\
138
139
  origin.y = floor(compressed * SHIFT_RIGHT3);\n\
139
140
  compressed -= origin.y * SHIFT_LEFT3;\n\
140
141
  \n\
141
- #ifdef FRAGMENT_DEPTH_CHECK\n\
142
+ #ifdef FS_THREE_POINT_DEPTH_CHECK\n\
142
143
  vec2 depthOrigin = origin.xy;\n\
143
144
  #endif\n\
144
145
  origin -= vec2(1.0);\n\
@@ -177,10 +178,10 @@ void main()\n\
177
178
  \n\
178
179
  vec2 imageSize = vec2(floor(temp), temp2);\n\
179
180
  \n\
180
- #ifdef FRAGMENT_DEPTH_CHECK\n\
181
+ #ifdef FS_THREE_POINT_DEPTH_CHECK\n\
181
182
  float labelHorizontalOrigin = floor(compressedAttribute2.w - (temp2 * SHIFT_LEFT2));\n\
182
183
  float applyTranslate = 0.0;\n\
183
- if (labelHorizontalOrigin != 0.0) // is a billboard, so set apply translate to false\n\
184
+ if (labelHorizontalOrigin != 0.0) // is a label, so set apply translate to true\n\
184
185
  {\n\
185
186
  applyTranslate = 1.0;\n\
186
187
  labelHorizontalOrigin -= 2.0;\n\
@@ -201,7 +202,7 @@ void main()\n\
201
202
  translucencyByDistance.w = ((temp - floor(temp)) * SHIFT_LEFT8) / 255.0;\n\
202
203
  #endif\n\
203
204
  \n\
204
- #if defined(VERTEX_DEPTH_CHECK) || defined(FRAGMENT_DEPTH_CHECK)\n\
205
+ #if defined(VS_THREE_POINT_DEPTH_CHECK) || defined(FS_THREE_POINT_DEPTH_CHECK)\n\
205
206
  temp = compressedAttribute3.w;\n\
206
207
  temp = temp * SHIFT_RIGHT12;\n\
207
208
  \n\
@@ -250,10 +251,6 @@ void main()\n\
250
251
  \n\
251
252
  vec4 p = czm_translateRelativeToEye(positionHigh, positionLow);\n\
252
253
  vec4 positionEC = czm_modelViewRelativeToEye * p;\n\
253
- \n\
254
- #if defined(FRAGMENT_DEPTH_CHECK) || defined(VERTEX_DEPTH_CHECK)\n\
255
- float eyeDepth = positionEC.z;\n\
256
- #endif\n\
257
254
  \n\
258
255
  positionEC = czm_eyeOffset(positionEC, eyeOffset.xyz);\n\
259
256
  positionEC.xyz *= show;\n\
@@ -312,35 +309,56 @@ void main()\n\
312
309
  mat2 rotationMatrix;\n\
313
310
  float mpp;\n\
314
311
  \n\
312
+ float enableDepthCheck = 1.0;\n\
315
313
  #ifdef DISABLE_DEPTH_DISTANCE\n\
316
- float disableDepthTestDistance = compressedAttribute3.z;\n\
314
+ float disableDepthTestDistanceSq = compressedAttribute3.z;\n\
315
+ if (disableDepthTestDistanceSq == 0.0 && czm_minimumDisableDepthTestDistance != 0.0)\n\
316
+ {\n\
317
+ disableDepthTestDistanceSq = czm_minimumDisableDepthTestDistance;\n\
318
+ }\n\
319
+ \n\
320
+ if (lengthSq < disableDepthTestDistanceSq || disableDepthTestDistanceSq < 0.0)\n\
321
+ {\n\
322
+ enableDepthCheck = 0.0;\n\
323
+ }\n\
317
324
  #endif\n\
318
325
  \n\
319
- #ifdef VERTEX_DEPTH_CHECK\n\
320
- if (lengthSq < disableDepthTestDistance) {\n\
321
- float depthsilon = 10.0;\n\
326
+ v_compressed.y = enableDepthCheck;\n\
322
327
  \n\
323
- vec2 labelTranslate = textureCoordinateBoundsOrLabelTranslate.xy;\n\
324
- vec4 pEC1 = addScreenSpaceOffset(positionEC, dimensions, scale, vec2(0.0), origin, labelTranslate, pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters, rotationMatrix, mpp);\n\
328
+ #ifdef VS_THREE_POINT_DEPTH_CHECK\n\
329
+ if (lengthSq < (u_threePointDepthTestDistance * u_threePointDepthTestDistance) && (enableDepthCheck == 1.0)) {\n\
330
+ float depthsilon = 10.0;\n\
331
+ vec2 depthOrigin;\n\
332
+ // Horizontal origin for labels comes from a special attribute. If that value is 0, this is a billboard - use the regular origin. \n\
333
+ // Otherwise, transform the label origin to -1, 0, 1 (right, center, left).\n\
334
+ depthOrigin.x = floor(compressedAttribute2.w - (temp2 * SHIFT_LEFT2));\n\
335
+ depthOrigin.x = czm_branchFreeTernary(depthOrigin.x == 0.0, origin.x, depthOrigin.x - 2.0);\n\
336
+ depthOrigin.y = origin.y;\n\
337
+ \n\
338
+ vec4 pEC1 = addScreenSpaceOffset(positionEC, dimensions, scale, vec2(0.0), depthOrigin, vec2(0.0), pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters, rotationMatrix, mpp);\n\
325
339
  float globeDepth1 = getGlobeDepth(pEC1);\n\
326
340
  \n\
327
341
  if (globeDepth1 != 0.0 && pEC1.z + depthsilon < globeDepth1)\n\
328
342
  {\n\
329
- vec4 pEC2 = addScreenSpaceOffset(positionEC, dimensions, scale, vec2(0.0, 1.0), origin, labelTranslate, pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters, rotationMatrix, mpp);\n\
343
+ vec4 pEC2 = addScreenSpaceOffset(positionEC, dimensions, scale, vec2(0.0, 1.0), depthOrigin, vec2(0.0), pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters, rotationMatrix, mpp);\n\
330
344
  float globeDepth2 = getGlobeDepth(pEC2);\n\
331
345
  \n\
332
346
  if (globeDepth2 != 0.0 && pEC2.z + depthsilon < globeDepth2)\n\
333
347
  {\n\
334
- vec4 pEC3 = addScreenSpaceOffset(positionEC, dimensions, scale, vec2(1.0), origin, labelTranslate, pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters, rotationMatrix, mpp);\n\
348
+ vec4 pEC3 = addScreenSpaceOffset(positionEC, dimensions, scale, vec2(1.0), depthOrigin, vec2(0.0), pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters, rotationMatrix, mpp);\n\
335
349
  float globeDepth3 = getGlobeDepth(pEC3);\n\
336
350
  if (globeDepth3 != 0.0 && pEC3.z + depthsilon < globeDepth3)\n\
337
351
  {\n\
352
+ // \"Discard\" this vertex, as three key points fail depth test.\n\
338
353
  positionEC.xyz = vec3(0.0);\n\
339
354
  }\n\
340
355
  }\n\
341
356
  }\n\
342
357
  }\n\
343
358
  #endif\n\
359
+ // Write out the eyespace depth before applying the screen space offset, but after potentially \"discarding\" the vertex\n\
360
+ // by setting its eyespace position to zero, via the three-point depth test above.\n\
361
+ v_compressed.x = positionEC.z;\n\
344
362
  \n\
345
363
  positionEC = addScreenSpaceOffset(positionEC, imageSize, scale, direction, origin, translate, pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters, rotationMatrix, mpp);\n\
346
364
  gl_Position = czm_projection * positionEC;\n\
@@ -351,17 +369,14 @@ if (lengthSq < disableDepthTestDistance) {\n\
351
369
  #endif\n\
352
370
  \n\
353
371
  #ifdef DISABLE_DEPTH_DISTANCE\n\
354
- if (disableDepthTestDistance == 0.0 && czm_minimumDisableDepthTestDistance != 0.0)\n\
355
- {\n\
356
- disableDepthTestDistance = czm_minimumDisableDepthTestDistance;\n\
357
- }\n\
358
372
  \n\
359
- if (disableDepthTestDistance != 0.0)\n\
373
+ if (disableDepthTestDistanceSq != 0.0)\n\
360
374
  {\n\
361
375
  // Don't try to \"multiply both sides\" by w. Greater/less-than comparisons won't work for negative values of w.\n\
362
376
  float zclip = gl_Position.z / gl_Position.w;\n\
363
377
  bool clipped = (zclip < -1.0 || zclip > 1.0);\n\
364
- if (!clipped && (disableDepthTestDistance < 0.0 || (lengthSq > 0.0 && lengthSq < disableDepthTestDistance)))\n\
378
+ // disableDepthTestDistanceSq can be less than zero if it's explicitly set to -1 in JS (as a sentinel value equivalent to infinity)\n\
379
+ if (!clipped && (disableDepthTestDistanceSq < 0.0 || (lengthSq > 0.0 && lengthSq < disableDepthTestDistanceSq)))\n\
365
380
  {\n\
366
381
  // Position z on the near plane.\n\
367
382
  gl_Position.z = -gl_Position.w;\n\
@@ -372,7 +387,7 @@ if (lengthSq < disableDepthTestDistance) {\n\
372
387
  }\n\
373
388
  #endif\n\
374
389
  \n\
375
- #ifdef FRAGMENT_DEPTH_CHECK\n\
390
+ #ifdef FS_THREE_POINT_DEPTH_CHECK\n\
376
391
  if (sizeInMeters) {\n\
377
392
  translate /= mpp;\n\
378
393
  dimensions /= mpp;\n\
@@ -384,21 +399,13 @@ if (lengthSq < disableDepthTestDistance) {\n\
384
399
  #else\n\
385
400
  v_rotationMatrix = mat2(1.0, 0.0, 0.0, 1.0);\n\
386
401
  #endif\n\
387
- \n\
388
- float enableDepthCheck = 0.0;\n\
389
- if (lengthSq < disableDepthTestDistance)\n\
390
- {\n\
391
- enableDepthCheck = 1.0;\n\
392
- }\n\
393
- \n\
394
402
  float dw = floor(clamp(dimensions.x, 0.0, SHIFT_LEFT12));\n\
395
403
  float dh = floor(clamp(dimensions.y, 0.0, SHIFT_LEFT12));\n\
396
404
  \n\
397
405
  float iw = floor(clamp(imageSize.x, 0.0, SHIFT_LEFT12));\n\
398
406
  float ih = floor(clamp(imageSize.y, 0.0, SHIFT_LEFT12));\n\
399
407
  \n\
400
- v_compressed.x = eyeDepth;\n\
401
- v_compressed.y = applyTranslate * SHIFT_LEFT1 + enableDepthCheck;\n\
408
+ v_compressed.y += applyTranslate * SHIFT_LEFT1;\n\
402
409
  v_compressed.z = dw * SHIFT_LEFT12 + dh;\n\
403
410
  v_compressed.w = iw * SHIFT_LEFT12 + ih;\n\
404
411
  v_originTextureCoordinateAndTranslate.xy = depthOrigin;\n\
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * @see czm_pass
8
8
  */
9
- const float czm_passCesium3DTile = 4.0;
9
+ const float czm_passCesium3DTile = 5.0;
@@ -7,5 +7,5 @@ export default "/**\n\
7
7
  *\n\
8
8
  * @see czm_pass\n\
9
9
  */\n\
10
- const float czm_passCesium3DTile = 4.0;\n\
10
+ const float czm_passCesium3DTile = 5.0;\n\
11
11
  ";
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * @see czm_pass
8
8
  */
9
- const float czm_passCesium3DTileClassification = 5.0;
9
+ const float czm_passCesium3DTileClassification = 6.0;
@@ -7,5 +7,5 @@ export default "/**\n\
7
7
  *\n\
8
8
  * @see czm_pass\n\
9
9
  */\n\
10
- const float czm_passCesium3DTileClassification = 5.0;\n\
10
+ const float czm_passCesium3DTileClassification = 6.0;\n\
11
11
  ";
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * @see czm_pass
8
8
  */
9
- const float czm_passCesium3DTileClassificationIgnoreShow = 6.0;
9
+ const float czm_passCesium3DTileClassificationIgnoreShow = 7.0;
@@ -7,5 +7,5 @@ export default "/**\n\
7
7
  *\n\
8
8
  * @see czm_pass\n\
9
9
  */\n\
10
- const float czm_passCesium3DTileClassificationIgnoreShow = 6.0;\n\
10
+ const float czm_passCesium3DTileClassificationIgnoreShow = 7.0;\n\
11
11
  ";
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE_EDGES}
3
+ *
4
+ * @name czm_passCesium3DTileEdges
5
+ * @glslConstant
6
+ *
7
+ * @see czm_pass
8
+ */
9
+ const float czm_passCesium3DTileEdges = 4.0;
10
+
@@ -0,0 +1,12 @@
1
+ //This file is automatically rebuilt by the Cesium build process.
2
+ export default "/**\n\
3
+ * The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE_EDGES}\n\
4
+ *\n\
5
+ * @name czm_passCesium3DTileEdges\n\
6
+ * @glslConstant\n\
7
+ *\n\
8
+ * @see czm_pass\n\
9
+ */\n\
10
+ const float czm_passCesium3DTileEdges = 4.0;\n\
11
+ \n\
12
+ ";
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * @see czm_pass
8
8
  */
9
- const float czm_passGaussianSplats = 10.0;
9
+ const float czm_passGaussianSplats = 11.0;
@@ -7,5 +7,5 @@ export default "/**\n\
7
7
  *\n\
8
8
  * @see czm_pass\n\
9
9
  */\n\
10
- const float czm_passGaussianSplats = 10.0;\n\
10
+ const float czm_passGaussianSplats = 11.0;\n\
11
11
  ";
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * @see czm_pass
8
8
  */
9
- const float czm_passOpaque = 7.0;
9
+ const float czm_passOpaque = 8.0;
@@ -7,5 +7,5 @@ export default "/**\n\
7
7
  *\n\
8
8
  * @see czm_pass\n\
9
9
  */\n\
10
- const float czm_passOpaque = 7.0;\n\
10
+ const float czm_passOpaque = 8.0;\n\
11
11
  ";
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * @see czm_pass
8
8
  */
9
- const float czm_passOverlay = 11.0;
9
+ const float czm_passOverlay = 12.0;
@@ -7,5 +7,5 @@ export default "/**\n\
7
7
  *\n\
8
8
  * @see czm_pass\n\
9
9
  */\n\
10
- const float czm_passOverlay = 11.0;\n\
10
+ const float czm_passOverlay = 12.0;\n\
11
11
  ";
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * @see czm_pass
8
8
  */
9
- const float czm_passTranslucent = 8.0;
9
+ const float czm_passTranslucent = 9.0;
@@ -7,5 +7,5 @@ export default "/**\n\
7
7
  *\n\
8
8
  * @see czm_pass\n\
9
9
  */\n\
10
- const float czm_passTranslucent = 8.0;\n\
10
+ const float czm_passTranslucent = 9.0;\n\
11
11
  ";
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * @see czm_pass
8
8
  */
9
- const float czm_passVoxels = 9.0;
9
+ const float czm_passVoxels = 10.0;
@@ -7,5 +7,5 @@ export default "/**\n\
7
7
  *\n\
8
8
  * @see czm_pass\n\
9
9
  */\n\
10
- const float czm_passVoxels = 9.0;\n\
10
+ const float czm_passVoxels = 10.0;\n\
11
11
  ";
@@ -14,6 +14,7 @@ import czm_oneOverTwoPi from './Constants/oneOverTwoPi.js'
14
14
  import czm_passCesium3DTile from './Constants/passCesium3DTile.js'
15
15
  import czm_passCesium3DTileClassification from './Constants/passCesium3DTileClassification.js'
16
16
  import czm_passCesium3DTileClassificationIgnoreShow from './Constants/passCesium3DTileClassificationIgnoreShow.js'
17
+ import czm_passCesium3DTileEdges from './Constants/passCesium3DTileEdges.js'
17
18
  import czm_passClassification from './Constants/passClassification.js'
18
19
  import czm_passCompute from './Constants/passCompute.js'
19
20
  import czm_passEnvironment from './Constants/passEnvironment.js'
@@ -153,6 +154,7 @@ export default {
153
154
  czm_passCesium3DTile : czm_passCesium3DTile,
154
155
  czm_passCesium3DTileClassification : czm_passCesium3DTileClassification,
155
156
  czm_passCesium3DTileClassificationIgnoreShow : czm_passCesium3DTileClassificationIgnoreShow,
157
+ czm_passCesium3DTileEdges : czm_passCesium3DTileEdges,
156
158
  czm_passClassification : czm_passClassification,
157
159
  czm_passCompute : czm_passCompute,
158
160
  czm_passEnvironment : czm_passEnvironment,
@@ -141,7 +141,7 @@ void main()
141
141
  #elif defined(INCLUDE_WEB_MERCATOR_Y)
142
142
  float webMercatorT = czm_decompressTextureCoordinates(compressed0.w).x;
143
143
  float encodedNormal = 0.0;
144
- #elif defined(ENABLE_VERTEX_LIGHTING) || defined(GENERATE_POSITION_AND_NORMAL)
144
+ #elif defined(ENABLE_VERTEX_LIGHTING) || defined(GENERATE_POSITION_AND_NORMAL) || defined(APPLY_MATERIAL)
145
145
  float webMercatorT = textureCoordinates.y;
146
146
  float encodedNormal = compressed0.w;
147
147
  #else
@@ -142,7 +142,7 @@ void main()\n\
142
142
  #elif defined(INCLUDE_WEB_MERCATOR_Y)\n\
143
143
  float webMercatorT = czm_decompressTextureCoordinates(compressed0.w).x;\n\
144
144
  float encodedNormal = 0.0;\n\
145
- #elif defined(ENABLE_VERTEX_LIGHTING) || defined(GENERATE_POSITION_AND_NORMAL)\n\
145
+ #elif defined(ENABLE_VERTEX_LIGHTING) || defined(GENERATE_POSITION_AND_NORMAL) || defined(APPLY_MATERIAL)\n\
146
146
  float webMercatorT = textureCoordinates.y;\n\
147
147
  float encodedNormal = compressed0.w;\n\
148
148
  #else\n\
@@ -0,0 +1,58 @@
1
+ void edgeDetectionStage(inout vec4 color, inout FeatureIds featureIds) {
2
+ if (u_isEdgePass) {
3
+ return;
4
+ }
5
+
6
+ vec2 screenCoord = gl_FragCoord.xy / czm_viewport.zw;
7
+
8
+ vec4 edgeColor = texture(czm_edgeColorTexture, screenCoord);
9
+ vec4 edgeId = texture(czm_edgeIdTexture, screenCoord);
10
+
11
+ // Packed window-space depth from edge pass (0..1)
12
+ float edgeDepthWin = czm_unpackDepth(texture(czm_edgeDepthTexture, screenCoord));
13
+
14
+ // Near / far for current frustum
15
+ float n = czm_currentFrustum.x;
16
+ float f = czm_currentFrustum.y;
17
+
18
+ // geometry depth in eye coordinate
19
+ vec4 geomEC = czm_windowToEyeCoordinates(gl_FragCoord);
20
+ float geomDepthLinear = -geomEC.z;
21
+
22
+ // Convert edge depth to linear depth
23
+ float z_ndc_edge = edgeDepthWin * 2.0 - 1.0;
24
+ float edgeDepthLinear = (2.0 * n * f) / (f + n - z_ndc_edge * (f - n));
25
+
26
+ float d = abs(edgeDepthLinear - geomDepthLinear);
27
+
28
+ // Adaptive epsilon using linear depth fwidth for robustness
29
+ float pixelStepLinear = fwidth(geomDepthLinear);
30
+ float rel = geomDepthLinear * 0.0005;
31
+ float eps = max(n * 1e-4, max(pixelStepLinear * 1.5, rel));
32
+
33
+ // If Edge isn't behind any geometry and the pixel has edge data
34
+ if (d < eps && edgeId.r > 0.0) {
35
+ #ifdef HAS_EDGE_FEATURE_ID
36
+ float edgeFeatureId = edgeId.g;
37
+ float currentFeatureId = float(featureIds.featureId_0);
38
+ #endif
39
+ float globeDepth = czm_unpackDepth(texture(czm_globeDepthTexture, screenCoord));
40
+ // Background / sky / globe: always show edge
41
+ bool isBackground = geomDepthLinear > globeDepth;
42
+ bool drawEdge = isBackground;
43
+
44
+ #ifdef HAS_EDGE_FEATURE_ID
45
+ bool hasEdgeFeature = edgeFeatureId > 0.0;
46
+ bool hasCurrentFeature = currentFeatureId > 0.0;
47
+ bool featuresMatch = edgeFeatureId == currentFeatureId;
48
+
49
+ drawEdge = drawEdge || !hasEdgeFeature || !hasCurrentFeature || featuresMatch;
50
+ #else
51
+ drawEdge = true;
52
+ #endif
53
+
54
+ if (drawEdge) {
55
+ color = edgeColor;
56
+ }
57
+ }
58
+ }
@@ -0,0 +1,60 @@
1
+ //This file is automatically rebuilt by the Cesium build process.
2
+ export default "void edgeDetectionStage(inout vec4 color, inout FeatureIds featureIds) {\n\
3
+ if (u_isEdgePass) {\n\
4
+ return;\n\
5
+ }\n\
6
+ \n\
7
+ vec2 screenCoord = gl_FragCoord.xy / czm_viewport.zw;\n\
8
+ \n\
9
+ vec4 edgeColor = texture(czm_edgeColorTexture, screenCoord);\n\
10
+ vec4 edgeId = texture(czm_edgeIdTexture, screenCoord);\n\
11
+ \n\
12
+ // Packed window-space depth from edge pass (0..1)\n\
13
+ float edgeDepthWin = czm_unpackDepth(texture(czm_edgeDepthTexture, screenCoord));\n\
14
+ \n\
15
+ // Near / far for current frustum\n\
16
+ float n = czm_currentFrustum.x;\n\
17
+ float f = czm_currentFrustum.y;\n\
18
+ \n\
19
+ // geometry depth in eye coordinate\n\
20
+ vec4 geomEC = czm_windowToEyeCoordinates(gl_FragCoord);\n\
21
+ float geomDepthLinear = -geomEC.z;\n\
22
+ \n\
23
+ // Convert edge depth to linear depth\n\
24
+ float z_ndc_edge = edgeDepthWin * 2.0 - 1.0;\n\
25
+ float edgeDepthLinear = (2.0 * n * f) / (f + n - z_ndc_edge * (f - n));\n\
26
+ \n\
27
+ float d = abs(edgeDepthLinear - geomDepthLinear);\n\
28
+ \n\
29
+ // Adaptive epsilon using linear depth fwidth for robustness\n\
30
+ float pixelStepLinear = fwidth(geomDepthLinear);\n\
31
+ float rel = geomDepthLinear * 0.0005;\n\
32
+ float eps = max(n * 1e-4, max(pixelStepLinear * 1.5, rel));\n\
33
+ \n\
34
+ // If Edge isn't behind any geometry and the pixel has edge data\n\
35
+ if (d < eps && edgeId.r > 0.0) {\n\
36
+ #ifdef HAS_EDGE_FEATURE_ID\n\
37
+ float edgeFeatureId = edgeId.g;\n\
38
+ float currentFeatureId = float(featureIds.featureId_0);\n\
39
+ #endif\n\
40
+ float globeDepth = czm_unpackDepth(texture(czm_globeDepthTexture, screenCoord));\n\
41
+ // Background / sky / globe: always show edge\n\
42
+ bool isBackground = geomDepthLinear > globeDepth;\n\
43
+ bool drawEdge = isBackground;\n\
44
+ \n\
45
+ #ifdef HAS_EDGE_FEATURE_ID\n\
46
+ bool hasEdgeFeature = edgeFeatureId > 0.0;\n\
47
+ bool hasCurrentFeature = currentFeatureId > 0.0;\n\
48
+ bool featuresMatch = edgeFeatureId == currentFeatureId;\n\
49
+ \n\
50
+ drawEdge = drawEdge || !hasEdgeFeature || !hasCurrentFeature || featuresMatch;\n\
51
+ #else\n\
52
+ drawEdge = true;\n\
53
+ #endif\n\
54
+ \n\
55
+ if (drawEdge) {\n\
56
+ color = edgeColor;\n\
57
+ }\n\
58
+ }\n\
59
+ }\n\
60
+ ";
@@ -0,0 +1,83 @@
1
+ // CESIUM_REDIRECTED_COLOR_OUTPUT flag is used to avoid color attachment conflicts
2
+ // when shaders are processed by different rendering pipelines (e.g., OIT).
3
+ // Only declare MRT outputs when not in a derived shader context.
4
+ #if defined(HAS_EDGE_VISIBILITY_MRT) && !defined(CESIUM_REDIRECTED_COLOR_OUTPUT)
5
+ layout(location = 1) out vec4 out_id; // edge id / metadata
6
+ layout(location = 2) out vec4 out_edgeDepth; // packed depth
7
+ #endif
8
+
9
+ void edgeVisibilityStage(inout vec4 color, inout FeatureIds featureIds)
10
+ {
11
+ #ifdef HAS_EDGE_VISIBILITY
12
+
13
+ if (!u_isEdgePass) {
14
+ return;
15
+ }
16
+
17
+ float edgeTypeInt = v_edgeType * 255.0;
18
+
19
+ // Color code different edge types
20
+ vec4 edgeColor = vec4(0.0);
21
+
22
+ if (edgeTypeInt < 0.5) { // HIDDEN (0)
23
+ edgeColor = vec4(0.0, 0.0, 0.0, 0.0); // Transparent for hidden edges
24
+ }
25
+ else if (edgeTypeInt > 0.5 && edgeTypeInt < 1.5) { // SILHOUETTE (1) - Conditional visibility
26
+ // Proper silhouette detection using face normals
27
+ vec3 normalA = normalize(v_faceNormalAView);
28
+ vec3 normalB = normalize(v_faceNormalBView);
29
+
30
+ // Calculate view direction using existing eye-space position varying (v_positionEC)
31
+ vec3 viewDir = -normalize(v_positionEC);
32
+
33
+ // Calculate dot products to determine triangle facing
34
+ float dotA = dot(normalA, viewDir);
35
+ float dotB = dot(normalB, viewDir);
36
+
37
+ const float eps = 1e-3;
38
+ bool frontA = dotA > eps;
39
+ bool backA = dotA < -eps;
40
+ bool frontB = dotB > eps;
41
+ bool backB = dotB < -eps;
42
+
43
+ // True silhouette: one triangle front-facing, other back-facing
44
+ bool oppositeFacing = (frontA && backB) || (backA && frontB);
45
+
46
+ // Exclude edges where both triangles are nearly grazing (perpendicular to view)
47
+ // This handles the top-view cylinder case where both normals are ~horizontal
48
+ bool bothNearGrazing = (abs(dotA) <= eps && abs(dotB) <= eps);
49
+
50
+ if (!(oppositeFacing && !bothNearGrazing)) {
51
+ discard; // Not a true silhouette edge
52
+ } else {
53
+ // True silhouette
54
+ edgeColor = vec4(1.0, 0.0, 0.0, 1.0);
55
+ }
56
+ }
57
+ else if (edgeTypeInt > 1.5 && edgeTypeInt < 2.5) { // HARD (2) - BRIGHT GREEN
58
+ edgeColor = vec4(0.0, 1.0, 0.0, 1.0); // Extra bright green
59
+ }
60
+ else if (edgeTypeInt > 2.5 && edgeTypeInt < 3.5) { // REPEATED (3)
61
+ edgeColor = vec4(0.0, 0.0, 1.0, 1.0);
62
+ } else {
63
+ edgeColor = vec4(0.0, 0.0, 0.0, 0.0);
64
+ }
65
+
66
+ // Temporary color: white
67
+ edgeColor = vec4(1.0, 1.0, 1.0, 1.0);
68
+ color = edgeColor;
69
+
70
+ #if defined(HAS_EDGE_VISIBILITY_MRT) && !defined(CESIUM_REDIRECTED_COLOR_OUTPUT)
71
+ // Write edge metadata
72
+ out_id = vec4(0.0);
73
+ out_id.r = edgeTypeInt; // Edge type (0-3)
74
+ #ifdef HAS_EDGE_FEATURE_ID
75
+ out_id.g = float(featureIds.featureId_0); // Feature ID if available
76
+ #else
77
+ out_id.g = 0.0;
78
+ #endif
79
+ // Pack depth into separate MRT attachment
80
+ out_edgeDepth = czm_packDepth(gl_FragCoord.z);
81
+ #endif
82
+ #endif
83
+ }