@cesium/engine 17.0.0 → 18.0.1-splats.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 (188) hide show
  1. package/Build/ThirdParty/Workers/z-worker-pako.js +1 -1
  2. package/Build/Workers/{chunk-UC7KH56Y.js → chunk-2AXKROJA.js} +5 -5
  3. package/Build/Workers/{chunk-IKDQX7DY.js → chunk-2J5ZZ7CY.js} +4 -4
  4. package/Build/Workers/{chunk-4TIR5UPL.js → chunk-2SYY3UBI.js} +1 -1
  5. package/Build/Workers/{chunk-CC2WKHIW.js → chunk-2WKW3BEB.js} +6 -6
  6. package/Build/Workers/{chunk-CBFJVM6I.js → chunk-2ZO6BCHN.js} +11 -11
  7. package/Build/Workers/{chunk-7PHT4JHA.js → chunk-3UKG5X7F.js} +12 -12
  8. package/Build/Workers/{chunk-PM4Q36WX.js → chunk-4GYIDPXP.js} +9 -9
  9. package/Build/Workers/{chunk-QUFN3GEO.js → chunk-6EP7ED36.js} +3 -3
  10. package/Build/Workers/{chunk-QJTIOB2Z.js → chunk-6QOBORNG.js} +6 -6
  11. package/Build/Workers/{chunk-YE6MDFDA.js → chunk-6WWHK2ER.js} +14 -14
  12. package/Build/Workers/{chunk-RX65FA7X.js → chunk-6Y6TVYHS.js} +7 -7
  13. package/Build/Workers/{chunk-P2N5IDWU.js → chunk-744VWE2U.js} +13 -13
  14. package/Build/Workers/{chunk-LVGYWPEX.js → chunk-7PQ52XCW.js} +4 -4
  15. package/Build/Workers/{chunk-PS3OKVOQ.js → chunk-A5UFJW2M.js} +12 -12
  16. package/Build/Workers/{chunk-CAKU6ZPR.js → chunk-AQKVFTWV.js} +8 -8
  17. package/Build/Workers/{chunk-236N6BJN.js → chunk-BKTEHJFD.js} +2 -2
  18. package/Build/Workers/{chunk-5PC577K7.js → chunk-CQXYKPAW.js} +16 -16
  19. package/Build/Workers/{chunk-DRMXU674.js → chunk-DI7PHKC6.js} +5 -5
  20. package/Build/Workers/{chunk-CQMXZF4A.js → chunk-DKKIQS6F.js} +6 -6
  21. package/Build/Workers/{chunk-J2HTPGC7.js → chunk-DTVWE5YL.js} +2 -2
  22. package/Build/Workers/{chunk-SSLK4U3V.js → chunk-ERPS2WZC.js} +4 -4
  23. package/Build/Workers/chunk-EYMZ5FSQ.js +280 -0
  24. package/Build/Workers/{chunk-LPGOAMYH.js → chunk-F43TQW5B.js} +2 -2
  25. package/Build/Workers/{chunk-5RPUEFSA.js → chunk-FOMRN6II.js} +6 -6
  26. package/Build/Workers/{chunk-2BJXFXD7.js → chunk-FOTXJYKS.js} +4 -4
  27. package/Build/Workers/{chunk-VXAKU6EV.js → chunk-G2Y7EA4W.js} +5 -5
  28. package/Build/Workers/{chunk-KE45DUDH.js → chunk-GY4E4ZP6.js} +10 -10
  29. package/Build/Workers/{chunk-NZSBSY5K.js → chunk-HDG3VHYL.js} +2 -2
  30. package/Build/Workers/{chunk-WP3IJYLC.js → chunk-HOEUXPBL.js} +9 -9
  31. package/Build/Workers/{chunk-5YEFZMMM.js → chunk-IWDYVJ56.js} +12 -12
  32. package/Build/Workers/{chunk-SQKTLDSD.js → chunk-JA4KPQJL.js} +12 -12
  33. package/Build/Workers/{chunk-MAIKDIBS.js → chunk-JZZQEZMA.js} +6 -6
  34. package/Build/Workers/{chunk-77MDEA47.js → chunk-KPLU3WDY.js} +5 -5
  35. package/Build/Workers/{chunk-E7SMO47Q.js → chunk-LHM6V4D6.js} +5 -5
  36. package/Build/Workers/{chunk-HBNWBMAM.js → chunk-LMTGCD6P.js} +1 -1
  37. package/Build/Workers/{chunk-XYGBWBD5.js → chunk-LWZOYSSF.js} +1 -1
  38. package/Build/Workers/{chunk-OBHLT34A.js → chunk-M6U7SV4T.js} +7 -7
  39. package/Build/Workers/{chunk-MS5NWDHH.js → chunk-O25M56DO.js} +2 -2
  40. package/Build/Workers/{chunk-UX5JWAC7.js → chunk-OE2WXO2Z.js} +10 -10
  41. package/Build/Workers/{chunk-C5DCX2YQ.js → chunk-PFD462OE.js} +6 -6
  42. package/Build/Workers/{chunk-37PA7GZW.js → chunk-PPI33PXH.js} +7 -7
  43. package/Build/Workers/{chunk-4BGKMM7J.js → chunk-PRQQHLUB.js} +1 -1
  44. package/Build/Workers/{chunk-IFIS4CVK.js → chunk-RTUZ7MJB.js} +2 -2
  45. package/Build/Workers/{chunk-G6JUXZUO.js → chunk-S6QBTP5U.js} +4 -4
  46. package/Build/Workers/{chunk-UFV3YUIN.js → chunk-SMFCIGM3.js} +5 -5
  47. package/Build/Workers/{chunk-P57PR3WM.js → chunk-TC3LEKFJ.js} +5 -5
  48. package/Build/Workers/{chunk-7IIMO7ZZ.js → chunk-UTLYCPFY.js} +16 -16
  49. package/Build/Workers/{chunk-HGEGZ67N.js → chunk-V7LEBY53.js} +6 -6
  50. package/Build/Workers/{chunk-GO3RZX2R.js → chunk-VE3UKRDB.js} +9 -9
  51. package/Build/Workers/{chunk-ZTBZMRQT.js → chunk-W3FBD4FE.js} +8 -8
  52. package/Build/Workers/{chunk-K5JTWJPE.js → chunk-YRR6CJGG.js} +4 -4
  53. package/Build/Workers/{chunk-UZ6KXWCA.js → chunk-ZVTKMLU6.js} +4 -4
  54. package/Build/Workers/combineGeometry.js +21 -21
  55. package/Build/Workers/createBoxGeometry.js +15 -15
  56. package/Build/Workers/createBoxOutlineGeometry.js +13 -13
  57. package/Build/Workers/createCircleGeometry.js +23 -23
  58. package/Build/Workers/createCircleOutlineGeometry.js +16 -16
  59. package/Build/Workers/createCoplanarPolygonGeometry.js +30 -30
  60. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +28 -28
  61. package/Build/Workers/createCorridorGeometry.js +26 -26
  62. package/Build/Workers/createCorridorOutlineGeometry.js +25 -25
  63. package/Build/Workers/createCylinderGeometry.js +17 -17
  64. package/Build/Workers/createCylinderOutlineGeometry.js +15 -15
  65. package/Build/Workers/createEllipseGeometry.js +23 -23
  66. package/Build/Workers/createEllipseOutlineGeometry.js +16 -16
  67. package/Build/Workers/createEllipsoidGeometry.js +16 -16
  68. package/Build/Workers/createEllipsoidOutlineGeometry.js +15 -15
  69. package/Build/Workers/createFrustumGeometry.js +15 -15
  70. package/Build/Workers/createFrustumOutlineGeometry.js +15 -15
  71. package/Build/Workers/createGeometry.js +23 -21
  72. package/Build/Workers/createGroundPolylineGeometry.js +19 -19
  73. package/Build/Workers/createPlaneGeometry.js +13 -13
  74. package/Build/Workers/createPlaneOutlineGeometry.js +12 -12
  75. package/Build/Workers/createPolygonGeometry.js +29 -29
  76. package/Build/Workers/createPolygonOutlineGeometry.js +27 -27
  77. package/Build/Workers/createPolylineGeometry.js +22 -22
  78. package/Build/Workers/createPolylineVolumeGeometry.js +28 -28
  79. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +24 -24
  80. package/Build/Workers/createRectangleGeometry.js +24 -24
  81. package/Build/Workers/createRectangleOutlineGeometry.js +17 -17
  82. package/Build/Workers/createSimplePolylineGeometry.js +20 -20
  83. package/Build/Workers/createSphereGeometry.js +16 -16
  84. package/Build/Workers/createSphereOutlineGeometry.js +15 -15
  85. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  86. package/Build/Workers/createVectorTileClampedPolylines.js +12 -12
  87. package/Build/Workers/createVectorTileGeometries.js +21 -21
  88. package/Build/Workers/createVectorTilePoints.js +11 -11
  89. package/Build/Workers/createVectorTilePolygons.js +19 -19
  90. package/Build/Workers/createVectorTilePolylines.js +12 -12
  91. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +19 -19
  92. package/Build/Workers/createVerticesFromHeightmap.js +19 -19
  93. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +16 -16
  94. package/Build/Workers/createWallGeometry.js +21 -21
  95. package/Build/Workers/createWallOutlineGeometry.js +20 -20
  96. package/Build/Workers/decodeDraco.js +10 -10
  97. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  98. package/Build/Workers/decodeI3S.js +9 -9
  99. package/Build/Workers/gaussianSplatSorter.js +62 -0
  100. package/Build/Workers/gaussianSplatTextureGenerator.js +68 -0
  101. package/Build/Workers/transcodeKTX2.js +78 -7
  102. package/Build/Workers/transferTypedArrayTest.js +1 -1
  103. package/Build/Workers/upsampleQuantizedTerrainMesh.js +19 -19
  104. package/Source/Core/Ion.js +1 -1
  105. package/Source/Core/PixelFormat.js +98 -0
  106. package/Source/Renderer/Context.js +2 -0
  107. package/Source/Renderer/Pass.js +3 -2
  108. package/Source/Renderer/Texture.js +1 -0
  109. package/Source/Renderer/Texture3D.js +568 -0
  110. package/Source/Renderer/VertexArray.js +33 -8
  111. package/Source/Renderer/createUniform.js +3 -0
  112. package/Source/Renderer/createUniformArray.js +1 -0
  113. package/Source/Scene/ArcGisMapService.js +1 -1
  114. package/Source/Scene/Cesium3DTileContentFactory.js +23 -0
  115. package/Source/Scene/Cesium3DTileset.js +197 -2
  116. package/Source/Scene/GaussianSplat3DTileContent.js +504 -0
  117. package/Source/Scene/GaussianSplatPrimitive.js +932 -0
  118. package/Source/Scene/GaussianSplatRenderResources.js +81 -0
  119. package/Source/Scene/GaussianSplatSorter.js +73 -0
  120. package/Source/Scene/GaussianSplatTextureGenerator.js +64 -0
  121. package/Source/Scene/GlobeSurfaceShaderSet.js +4 -5
  122. package/Source/Scene/GltfLoader.js +82 -4
  123. package/Source/Scene/GltfSpzLoader.js +222 -0
  124. package/Source/Scene/GltfVertexBufferLoader.js +98 -3
  125. package/Source/Scene/ImageryLayer.js +19 -4
  126. package/Source/Scene/ImageryLayerCollection.js +3 -2
  127. package/Source/Scene/Model/CartesianRectangle.js +108 -0
  128. package/Source/Scene/Model/ImageryConfiguration.js +25 -0
  129. package/Source/Scene/Model/ImageryCoverage.js +488 -0
  130. package/Source/Scene/Model/ImageryFlags.js +31 -0
  131. package/Source/Scene/Model/ImageryInput.js +60 -0
  132. package/Source/Scene/Model/ImageryPipelineStage.js +1040 -0
  133. package/Source/Scene/Model/MappedPositions.js +84 -0
  134. package/Source/Scene/Model/Model.js +38 -0
  135. package/Source/Scene/Model/ModelImagery.js +403 -0
  136. package/Source/Scene/Model/ModelImageryMapping.js +489 -0
  137. package/Source/Scene/Model/ModelPrimitiveImagery.js +972 -0
  138. package/Source/Scene/Model/ModelReader.js +810 -0
  139. package/Source/Scene/Model/ModelRenderResources.js +13 -0
  140. package/Source/Scene/Model/ModelRuntimePrimitive.js +20 -0
  141. package/Source/Scene/Model/ModelSceneGraph.js +133 -27
  142. package/Source/Scene/Model/ModelUtility.js +2 -0
  143. package/Source/Scene/Model/NodeRenderResources.js +10 -0
  144. package/Source/Scene/ModelComponents.js +10 -0
  145. package/Source/Scene/PrimitiveLoadPlan.js +59 -0
  146. package/Source/Scene/ResourceCache.js +60 -3
  147. package/Source/Scene/ResourceCacheKey.js +39 -1
  148. package/Source/Scene/Scene.js +32 -1
  149. package/Source/Scene/VertexAttributeSemantic.js +30 -0
  150. package/Source/Scene/VoxelPrimitive.js +22 -37
  151. package/Source/Scene/VoxelRenderResources.js +1 -1
  152. package/Source/Scene/processVoxelProperties.js +41 -100
  153. package/Source/Shaders/Builtin/Constants/passGaussianSplats.glsl +9 -0
  154. package/Source/Shaders/Builtin/Constants/passGaussianSplats.js +11 -0
  155. package/Source/Shaders/Builtin/Constants/passOverlay.glsl +1 -1
  156. package/Source/Shaders/Builtin/Constants/passOverlay.js +1 -1
  157. package/Source/Shaders/Builtin/CzmBuiltins.js +2 -0
  158. package/Source/Shaders/Builtin/Functions/windowToEyeCoordinates.glsl +0 -1
  159. package/Source/Shaders/Builtin/Functions/windowToEyeCoordinates.js +0 -1
  160. package/Source/Shaders/GlobeFS.glsl +22 -0
  161. package/Source/Shaders/GlobeFS.js +22 -0
  162. package/Source/Shaders/Model/MaterialStageFS.glsl +4 -0
  163. package/Source/Shaders/Model/MaterialStageFS.js +4 -0
  164. package/Source/Shaders/Model/ModelFS.glsl +3 -1
  165. package/Source/Shaders/Model/ModelFS.js +3 -1
  166. package/Source/Shaders/Model/ModelVS.glsl +5 -1
  167. package/Source/Shaders/Model/ModelVS.js +5 -1
  168. package/Source/Shaders/Model/PointCloudStylingStageVS.glsl +1 -1
  169. package/Source/Shaders/Model/PointCloudStylingStageVS.js +2 -1
  170. package/Source/Shaders/PrimitiveGaussianSplatFS.glsl +18 -0
  171. package/Source/Shaders/PrimitiveGaussianSplatFS.js +20 -0
  172. package/Source/Shaders/PrimitiveGaussianSplatVS.glsl +108 -0
  173. package/Source/Shaders/PrimitiveGaussianSplatVS.js +109 -0
  174. package/Source/Shaders/Voxels/IntersectDepth.glsl +10 -3
  175. package/Source/Shaders/Voxels/IntersectDepth.js +10 -3
  176. package/Source/Shaders/Voxels/Intersection.glsl +1 -3
  177. package/Source/Shaders/Voxels/Intersection.js +1 -3
  178. package/Source/Shaders/Voxels/IntersectionUtils.glsl +1 -0
  179. package/Source/Shaders/Voxels/IntersectionUtils.js +1 -0
  180. package/Source/Shaders/Voxels/VoxelFS.glsl +37 -24
  181. package/Source/Shaders/Voxels/VoxelFS.js +37 -24
  182. package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
  183. package/Source/ThirdParty/wasm_splats_bg.wasm +0 -0
  184. package/Source/Workers/gaussianSplatSorter.js +34 -0
  185. package/Source/Workers/gaussianSplatTextureGenerator.js +39 -0
  186. package/index.d.ts +66 -2
  187. package/index.js +101 -80
  188. package/package.json +6 -4
@@ -1,5 +1,6 @@
1
1
 
2
2
  precision highp float;
3
+
3
4
  czm_modelMaterial defaultModelMaterial()
4
5
  {
5
6
  czm_modelMaterial material;
@@ -86,7 +87,7 @@ void main()
86
87
 
87
88
  // When not picking metadata END
88
89
  //========================================================================
89
- #else
90
+ #else
90
91
  //========================================================================
91
92
  // When picking metadata START
92
93
 
@@ -124,3 +125,4 @@ void main()
124
125
 
125
126
  out_FragColor = color;
126
127
  }
128
+
@@ -1,6 +1,7 @@
1
1
  //This file is automatically rebuilt by the Cesium build process.
2
2
  export default "\n\
3
3
  precision highp float;\n\
4
+ \n\
4
5
  czm_modelMaterial defaultModelMaterial()\n\
5
6
  {\n\
6
7
  czm_modelMaterial material;\n\
@@ -87,7 +88,7 @@ void main()\n\
87
88
  \n\
88
89
  // When not picking metadata END\n\
89
90
  //========================================================================\n\
90
- #else \n\
91
+ #else\n\
91
92
  //========================================================================\n\
92
93
  // When picking metadata START\n\
93
94
  \n\
@@ -125,4 +126,5 @@ void main()\n\
125
126
  \n\
126
127
  out_FragColor = color;\n\
127
128
  }\n\
129
+ \n\
128
130
  ";
@@ -14,6 +14,10 @@ void main()
14
14
  ProcessedAttributes attributes;
15
15
  initializeAttributes(attributes);
16
16
 
17
+ #ifdef HAS_IMAGERY
18
+ initializeImageryAttributes();
19
+ #endif
20
+
17
21
  // Dequantize the quantized ones and add them to the
18
22
  // attributes struct.
19
23
  #ifdef USE_DEQUANTIZATION
@@ -141,7 +145,7 @@ void main()
141
145
  #else
142
146
  gl_PointSize = 1.0;
143
147
  #endif
144
-
148
+
145
149
  gl_PointSize *= show;
146
150
  #endif
147
151
 
@@ -14,6 +14,10 @@ void main()\n\
14
14
  // attributes except quantized ones.\n\
15
15
  ProcessedAttributes attributes;\n\
16
16
  initializeAttributes(attributes);\n\
17
+ \n\
18
+ #ifdef HAS_IMAGERY\n\
19
+ initializeImageryAttributes();\n\
20
+ #endif\n\
17
21
  \n\
18
22
  // Dequantize the quantized ones and add them to the\n\
19
23
  // attributes struct.\n\
@@ -142,7 +146,7 @@ void main()\n\
142
146
  #else\n\
143
147
  gl_PointSize = 1.0;\n\
144
148
  #endif\n\
145
- \n\
149
+ \n\
146
150
  gl_PointSize *= show;\n\
147
151
  #endif\n\
148
152
  \n\
@@ -42,4 +42,4 @@ float pointCloudBackFaceCullingStage() {
42
42
  return 1.0;
43
43
  #endif
44
44
  }
45
- #endif
45
+ #endif
@@ -43,4 +43,5 @@ float pointCloudBackFaceCullingStage() {\n\
43
43
  return 1.0;\n\
44
44
  #endif\n\
45
45
  }\n\
46
- #endif";
46
+ #endif\n\
47
+ ";
@@ -0,0 +1,18 @@
1
+ //
2
+ // Fragment shader for Gaussian splats.
3
+ // Renders a Gaussian splat within a quad, discarding fragments outside the unit circle.
4
+ // Applies an approximate Gaussian falloff based on distance from the center and outputs
5
+ // a color modulated by the alpha and Gaussian weight.
6
+ //
7
+ void main() {
8
+ if (v_splitDirection < 0.0 && gl_FragCoord.x > czm_splitPosition) discard;
9
+ if (v_splitDirection > 0.0 && gl_FragCoord.x < czm_splitPosition) discard;
10
+
11
+ mediump float A = dot(v_vertPos, v_vertPos);
12
+ if(A > 1.0) {
13
+ discard;
14
+ }
15
+ mediump float scale = 4.0;
16
+ mediump float B = exp(-A * scale) * (v_splatColor.a);
17
+ out_FragColor = vec4(v_splatColor.rgb * B, B);
18
+ }
@@ -0,0 +1,20 @@
1
+ //This file is automatically rebuilt by the Cesium build process.
2
+ export default "//\n\
3
+ // Fragment shader for Gaussian splats.\n\
4
+ // Renders a Gaussian splat within a quad, discarding fragments outside the unit circle.\n\
5
+ // Applies an approximate Gaussian falloff based on distance from the center and outputs\n\
6
+ // a color modulated by the alpha and Gaussian weight.\n\
7
+ //\n\
8
+ void main() {\n\
9
+ if (v_splitDirection < 0.0 && gl_FragCoord.x > czm_splitPosition) discard;\n\
10
+ if (v_splitDirection > 0.0 && gl_FragCoord.x < czm_splitPosition) discard;\n\
11
+ \n\
12
+ mediump float A = dot(v_vertPos, v_vertPos);\n\
13
+ if(A > 1.0) {\n\
14
+ discard;\n\
15
+ }\n\
16
+ mediump float scale = 4.0;\n\
17
+ mediump float B = exp(-A * scale) * (v_splatColor.a);\n\
18
+ out_FragColor = vec4(v_splatColor.rgb * B, B);\n\
19
+ }\n\
20
+ ";
@@ -0,0 +1,108 @@
1
+ //
2
+ // Vertex shader for Gaussian splats.
3
+
4
+ // The splats are rendered as quads in view space. Splat attributes are loaded from a texture with precomputed 3D covariance.
5
+
6
+ // Passes local quad coordinates and color to the fragment shader for Gaussian evaluation.
7
+ //
8
+ // Discards splats outside the view frustum or with negligible screen size.
9
+ //
10
+
11
+ // Transforms and projects splat covariance into screen space and extracts the major and minor axes of the Gaussian ellipsoid
12
+ // which is used to calculate the vertex position in clip space.
13
+ vec4 calcCovVectors(vec3 viewPos, mat3 Vrk) {
14
+ vec4 t = vec4(viewPos, 1.0);
15
+ float focal = czm_viewport.z * czm_projection[0][0];
16
+
17
+ float J1 = focal / t.z;
18
+ vec2 J2 = -J1 / t.z * t.xy;
19
+ mat3 J = mat3(
20
+ J1, 0.0, J2.x,
21
+ 0.0, J1, J2.y,
22
+ 0.0, 0.0, 0.0
23
+ );
24
+
25
+ //We need to take our view and remove the scale component
26
+ //quantized models can have a scaled matrix which will throw our splat size off
27
+ mat3 R = mat3(czm_modelView);
28
+ vec3 scale;
29
+ scale.x = length(R[0].xyz);
30
+ scale.y = length(R[1].xyz);
31
+ scale.z = length(R[2].xyz);
32
+
33
+ mat3 Rs = mat3(
34
+ R[0].xyz / scale.x,
35
+ R[1].xyz / scale.y,
36
+ R[2].xyz / scale.z
37
+ );
38
+
39
+ //transform our covariance into view space
40
+ //ensures orientation is correct
41
+ mat3 Vrk_view = Rs * Vrk * transpose(Rs);
42
+
43
+ mat3 cov = transpose(J) * Vrk_view * J;
44
+
45
+ float diagonal1 = cov[0][0] + .3;
46
+ float offDiagonal = cov[0][1];
47
+ float diagonal2 = cov[1][1] + .3;
48
+
49
+ float mid = 0.5 * (diagonal1 + diagonal2);
50
+ float radius = length(vec2((diagonal1 - diagonal2) * 0.5, offDiagonal));
51
+ float lambda1 = mid + radius;
52
+ float lambda2 = max(mid - radius, 0.1);
53
+
54
+ vec2 diagonalVector = normalize(vec2(offDiagonal, lambda1 - diagonal1));
55
+
56
+ return vec4(
57
+ min(sqrt(2.0 * lambda1), 1024.0) * diagonalVector,
58
+ min(sqrt(2.0 * lambda2), 1024.0) * vec2(diagonalVector.y, -diagonalVector.x)
59
+ );
60
+ }
61
+
62
+ highp vec4 discardVec = vec4(0.0, 0.0, 2.0, 1.0);
63
+
64
+ void main() {
65
+ uint texIdx = uint(a_splatIndex);
66
+ ivec2 posCoord = ivec2((texIdx & 0x3ffu) << 1, texIdx >> 10);
67
+ vec4 splatPosition = vec4( uintBitsToFloat(uvec4(texelFetch(u_splatAttributeTexture, posCoord, 0))) );
68
+
69
+ vec4 splatViewPos = czm_modelView * vec4(splatPosition.xyz, 1.0);
70
+ vec4 clipPosition = czm_projection * splatViewPos;
71
+
72
+ float clip = 1.2 * clipPosition.w;
73
+ if (clipPosition.z < -clip || clipPosition.x < -clip || clipPosition.x > clip ||
74
+ clipPosition.y < -clip || clipPosition.y > clip) {
75
+ gl_Position = vec4(0.0, 0.0, 2.0, 1.0);
76
+ return;
77
+ }
78
+
79
+ ivec2 covCoord = ivec2(((texIdx & 0x3ffu) << 1) | 1u, texIdx >> 10);
80
+ uvec4 covariance = uvec4(texelFetch(u_splatAttributeTexture, covCoord, 0));
81
+
82
+ gl_Position = clipPosition;
83
+
84
+ vec2 u1 = unpackHalf2x16(covariance.x) ;
85
+ vec2 u2 = unpackHalf2x16(covariance.y);
86
+ vec2 u3 = unpackHalf2x16(covariance.z);
87
+ mat3 Vrk = mat3(u1.x, u1.y, u2.x, u1.y, u2.y, u3.x, u2.x, u3.x, u3.y);
88
+
89
+ //we can still apply scale here even though cov3d is pre-computed
90
+ Vrk *= u_splatScale;
91
+
92
+ vec4 covVectors = calcCovVectors(splatViewPos.xyz, Vrk);
93
+
94
+ if (dot(covVectors.xy, covVectors.xy) < 4.0 && dot(covVectors.zw, covVectors.zw) < 4.0) {
95
+ gl_Position = discardVec;
96
+ return;
97
+ }
98
+
99
+ vec2 corner = vec2((gl_VertexID << 1) & 2, gl_VertexID & 2) - 1.;
100
+
101
+ gl_Position += vec4((corner.x * covVectors.xy + corner.y * covVectors.zw) / czm_viewport.zw * gl_Position.w, 0, 0);
102
+ gl_Position.z = clamp(gl_Position.z, -abs(gl_Position.w), abs(gl_Position.w));
103
+
104
+ v_vertPos = corner ;
105
+ v_splatColor = vec4(covariance.w & 0xffu, (covariance.w >> 8) & 0xffu, (covariance.w >> 16) & 0xffu, (covariance.w >> 24) & 0xffu) / 255.0;
106
+
107
+ v_splitDirection = u_splitDirection;
108
+ }
@@ -0,0 +1,109 @@
1
+ //This file is automatically rebuilt by the Cesium build process.
2
+ export default "//\n\
3
+ // Vertex shader for Gaussian splats.\n\
4
+ \n\
5
+ // The splats are rendered as quads in view space. Splat attributes are loaded from a texture with precomputed 3D covariance.\n\
6
+ \n\
7
+ // Passes local quad coordinates and color to the fragment shader for Gaussian evaluation. \n\
8
+ //\n\
9
+ // Discards splats outside the view frustum or with negligible screen size.\n\
10
+ //\n\
11
+ \n\
12
+ // Transforms and projects splat covariance into screen space and extracts the major and minor axes of the Gaussian ellipsoid\n\
13
+ // which is used to calculate the vertex position in clip space.\n\
14
+ vec4 calcCovVectors(vec3 viewPos, mat3 Vrk) {\n\
15
+ vec4 t = vec4(viewPos, 1.0);\n\
16
+ float focal = czm_viewport.z * czm_projection[0][0];\n\
17
+ \n\
18
+ float J1 = focal / t.z;\n\
19
+ vec2 J2 = -J1 / t.z * t.xy;\n\
20
+ mat3 J = mat3(\n\
21
+ J1, 0.0, J2.x,\n\
22
+ 0.0, J1, J2.y,\n\
23
+ 0.0, 0.0, 0.0\n\
24
+ );\n\
25
+ \n\
26
+ //We need to take our view and remove the scale component\n\
27
+ //quantized models can have a scaled matrix which will throw our splat size off\n\
28
+ mat3 R = mat3(czm_modelView);\n\
29
+ vec3 scale;\n\
30
+ scale.x = length(R[0].xyz);\n\
31
+ scale.y = length(R[1].xyz);\n\
32
+ scale.z = length(R[2].xyz);\n\
33
+ \n\
34
+ mat3 Rs = mat3(\n\
35
+ R[0].xyz / scale.x,\n\
36
+ R[1].xyz / scale.y,\n\
37
+ R[2].xyz / scale.z\n\
38
+ );\n\
39
+ \n\
40
+ //transform our covariance into view space\n\
41
+ //ensures orientation is correct\n\
42
+ mat3 Vrk_view = Rs * Vrk * transpose(Rs);\n\
43
+ \n\
44
+ mat3 cov = transpose(J) * Vrk_view * J;\n\
45
+ \n\
46
+ float diagonal1 = cov[0][0] + .3;\n\
47
+ float offDiagonal = cov[0][1];\n\
48
+ float diagonal2 = cov[1][1] + .3;\n\
49
+ \n\
50
+ float mid = 0.5 * (diagonal1 + diagonal2);\n\
51
+ float radius = length(vec2((diagonal1 - diagonal2) * 0.5, offDiagonal));\n\
52
+ float lambda1 = mid + radius;\n\
53
+ float lambda2 = max(mid - radius, 0.1);\n\
54
+ \n\
55
+ vec2 diagonalVector = normalize(vec2(offDiagonal, lambda1 - diagonal1));\n\
56
+ \n\
57
+ return vec4(\n\
58
+ min(sqrt(2.0 * lambda1), 1024.0) * diagonalVector,\n\
59
+ min(sqrt(2.0 * lambda2), 1024.0) * vec2(diagonalVector.y, -diagonalVector.x)\n\
60
+ );\n\
61
+ }\n\
62
+ \n\
63
+ highp vec4 discardVec = vec4(0.0, 0.0, 2.0, 1.0);\n\
64
+ \n\
65
+ void main() {\n\
66
+ uint texIdx = uint(a_splatIndex);\n\
67
+ ivec2 posCoord = ivec2((texIdx & 0x3ffu) << 1, texIdx >> 10);\n\
68
+ vec4 splatPosition = vec4( uintBitsToFloat(uvec4(texelFetch(u_splatAttributeTexture, posCoord, 0))) );\n\
69
+ \n\
70
+ vec4 splatViewPos = czm_modelView * vec4(splatPosition.xyz, 1.0);\n\
71
+ vec4 clipPosition = czm_projection * splatViewPos;\n\
72
+ \n\
73
+ float clip = 1.2 * clipPosition.w;\n\
74
+ if (clipPosition.z < -clip || clipPosition.x < -clip || clipPosition.x > clip ||\n\
75
+ clipPosition.y < -clip || clipPosition.y > clip) {\n\
76
+ gl_Position = vec4(0.0, 0.0, 2.0, 1.0);\n\
77
+ return;\n\
78
+ }\n\
79
+ \n\
80
+ ivec2 covCoord = ivec2(((texIdx & 0x3ffu) << 1) | 1u, texIdx >> 10);\n\
81
+ uvec4 covariance = uvec4(texelFetch(u_splatAttributeTexture, covCoord, 0));\n\
82
+ \n\
83
+ gl_Position = clipPosition;\n\
84
+ \n\
85
+ vec2 u1 = unpackHalf2x16(covariance.x) ;\n\
86
+ vec2 u2 = unpackHalf2x16(covariance.y);\n\
87
+ vec2 u3 = unpackHalf2x16(covariance.z);\n\
88
+ mat3 Vrk = mat3(u1.x, u1.y, u2.x, u1.y, u2.y, u3.x, u2.x, u3.x, u3.y);\n\
89
+ \n\
90
+ //we can still apply scale here even though cov3d is pre-computed\n\
91
+ Vrk *= u_splatScale;\n\
92
+ \n\
93
+ vec4 covVectors = calcCovVectors(splatViewPos.xyz, Vrk);\n\
94
+ \n\
95
+ if (dot(covVectors.xy, covVectors.xy) < 4.0 && dot(covVectors.zw, covVectors.zw) < 4.0) {\n\
96
+ gl_Position = discardVec;\n\
97
+ return;\n\
98
+ }\n\
99
+ \n\
100
+ vec2 corner = vec2((gl_VertexID << 1) & 2, gl_VertexID & 2) - 1.;\n\
101
+ \n\
102
+ gl_Position += vec4((corner.x * covVectors.xy + corner.y * covVectors.zw) / czm_viewport.zw * gl_Position.w, 0, 0);\n\
103
+ gl_Position.z = clamp(gl_Position.z, -abs(gl_Position.w), abs(gl_Position.w));\n\
104
+ \n\
105
+ v_vertPos = corner ;\n\
106
+ v_splatColor = vec4(covariance.w & 0xffu, (covariance.w >> 8) & 0xffu, (covariance.w >> 16) & 0xffu, (covariance.w >> 24) & 0xffu) / 255.0;\n\
107
+ \n\
108
+ v_splitDirection = u_splitDirection;\n\
109
+ }";
@@ -9,15 +9,22 @@ uniform mat4 u_transformPositionViewToUv;
9
9
 
10
10
  void intersectDepth(in vec2 screenCoord, in Ray ray, inout Intersections ix) {
11
11
  float logDepthOrDepth = czm_unpackDepth(texture(czm_globeDepthTexture, screenCoord));
12
+ float entry;
13
+ float exit;
12
14
  if (logDepthOrDepth != 0.0) {
13
15
  // Calculate how far the ray must travel before it hits the depth buffer.
14
16
  vec4 eyeCoordinateDepth = czm_screenToEyeCoordinates(screenCoord, logDepthOrDepth);
15
17
  eyeCoordinateDepth /= eyeCoordinateDepth.w;
16
18
  vec3 depthPositionUv = vec3(u_transformPositionViewToUv * eyeCoordinateDepth);
17
- float t = dot(depthPositionUv - ray.pos, ray.dir);
18
- setIntersectionPair(ix, DEPTH_INTERSECTION_INDEX, vec2(t, +INF_HIT));
19
+ entry = dot(depthPositionUv - ray.pos, ray.dir);
20
+ exit = +INF_HIT;
19
21
  } else {
20
22
  // There's no depth at this location.
21
- setIntersectionPair(ix, DEPTH_INTERSECTION_INDEX, vec2(NO_HIT));
23
+ entry = NO_HIT;
24
+ exit = NO_HIT;
22
25
  }
26
+ ix.distanceToDepthBuffer = entry;
27
+ #if defined(DEPTH_TEST)
28
+ setIntersectionPair(ix, DEPTH_INTERSECTION_INDEX, vec2(entry, exit));
29
+ #endif
23
30
  }
@@ -10,16 +10,23 @@ uniform mat4 u_transformPositionViewToUv;\n\
10
10
  \n\
11
11
  void intersectDepth(in vec2 screenCoord, in Ray ray, inout Intersections ix) {\n\
12
12
  float logDepthOrDepth = czm_unpackDepth(texture(czm_globeDepthTexture, screenCoord));\n\
13
+ float entry;\n\
14
+ float exit;\n\
13
15
  if (logDepthOrDepth != 0.0) {\n\
14
16
  // Calculate how far the ray must travel before it hits the depth buffer.\n\
15
17
  vec4 eyeCoordinateDepth = czm_screenToEyeCoordinates(screenCoord, logDepthOrDepth);\n\
16
18
  eyeCoordinateDepth /= eyeCoordinateDepth.w;\n\
17
19
  vec3 depthPositionUv = vec3(u_transformPositionViewToUv * eyeCoordinateDepth);\n\
18
- float t = dot(depthPositionUv - ray.pos, ray.dir);\n\
19
- setIntersectionPair(ix, DEPTH_INTERSECTION_INDEX, vec2(t, +INF_HIT));\n\
20
+ entry = dot(depthPositionUv - ray.pos, ray.dir);\n\
21
+ exit = +INF_HIT;\n\
20
22
  } else {\n\
21
23
  // There's no depth at this location.\n\
22
- setIntersectionPair(ix, DEPTH_INTERSECTION_INDEX, vec2(NO_HIT));\n\
24
+ entry = NO_HIT;\n\
25
+ exit = NO_HIT;\n\
23
26
  }\n\
27
+ ix.distanceToDepthBuffer = entry;\n\
28
+ #if defined(DEPTH_TEST)\n\
29
+ setIntersectionPair(ix, DEPTH_INTERSECTION_INDEX, vec2(entry, exit));\n\
30
+ #endif\n\
24
31
  }\n\
25
32
  ";
@@ -28,9 +28,7 @@ RayShapeIntersection intersectScene(in vec2 screenCoord, in Ray ray, out Interse
28
28
  #endif
29
29
 
30
30
  // Depth
31
- #if defined(DEPTH_TEST)
32
- intersectDepth(screenCoord, ray, ix);
33
- #endif
31
+ intersectDepth(screenCoord, ray, ix);
34
32
 
35
33
  // Find the first intersection that's in front of the ray
36
34
  #if (INTERSECTION_COUNT > 1)
@@ -29,9 +29,7 @@ RayShapeIntersection intersectScene(in vec2 screenCoord, in Ray ray, out Interse
29
29
  #endif\n\
30
30
  \n\
31
31
  // Depth\n\
32
- #if defined(DEPTH_TEST)\n\
33
- intersectDepth(screenCoord, ray, ix);\n\
34
- #endif\n\
32
+ intersectDepth(screenCoord, ray, ix);\n\
35
33
  \n\
36
34
  // Find the first intersection that's in front of the ray\n\
37
35
  #if (INTERSECTION_COUNT > 1)\n\
@@ -56,6 +56,7 @@ struct Intersections {
56
56
  // INTERSECTION_COUNT is the number of ray-*shape* (volume) intersections,
57
57
  // so we need twice as many to track ray-*surface* intersections
58
58
  vec4 intersections[INTERSECTION_COUNT * 2];
59
+ float distanceToDepthBuffer;
59
60
 
60
61
  #if (INTERSECTION_COUNT > 1)
61
62
  // Maintain state for future nextIntersection calls
@@ -57,6 +57,7 @@ struct Intersections {\n\
57
57
  // INTERSECTION_COUNT is the number of ray-*shape* (volume) intersections,\n\
58
58
  // so we need twice as many to track ray-*surface* intersections\n\
59
59
  vec4 intersections[INTERSECTION_COUNT * 2];\n\
60
+ float distanceToDepthBuffer;\n\
60
61
  \n\
61
62
  #if (INTERSECTION_COUNT > 1)\n\
62
63
  // Maintain state for future nextIntersection calls\n\
@@ -15,8 +15,10 @@
15
15
  #define ALPHA_ACCUM_MAX 0.98 // Must be > 0.0 and <= 1.0
16
16
  #endif
17
17
 
18
+ uniform mat4 u_transformPositionUvToView;
18
19
  uniform mat3 u_transformDirectionViewToLocal;
19
20
  uniform vec3 u_cameraPositionUv;
21
+ uniform vec3 u_cameraDirectionUv;
20
22
  uniform float u_stepSize;
21
23
 
22
24
  #if defined(PICKING)
@@ -111,26 +113,38 @@ int getSampleIndex(in SampleData sampleData) {
111
113
  return sampleIndex.x + u_inputDimensions.x * (sampleIndex.y + u_inputDimensions.y * sampleIndex.z);
112
114
  }
113
115
 
114
- void main()
115
- {
116
- vec4 fragCoord = gl_FragCoord;
117
- vec2 screenCoord = (fragCoord.xy - czm_viewport.xy) / czm_viewport.zw; // [0,1]
118
- vec3 eyeDirection = normalize(czm_windowToEyeCoordinates(fragCoord).xyz);
119
- vec3 viewDirWorld = normalize(czm_inverseViewRotation * eyeDirection); // normalize again just in case
120
- vec3 viewDirUv = normalize(u_transformDirectionViewToLocal * eyeDirection); // normalize again just in case
121
- vec3 viewPosUv = u_cameraPositionUv;
116
+ /**
117
+ * Compute the view ray at the current fragment, in the local UV coordinates of the shape.
118
+ */
119
+ Ray getViewRayUv() {
120
+ vec4 eyeCoordinates = czm_windowToEyeCoordinates(gl_FragCoord);
121
+ vec3 viewDirUv;
122
+ vec3 viewPosUv;
123
+ if (czm_orthographicIn3D == 1.0) {
124
+ eyeCoordinates.z = 0.0;
125
+ viewPosUv = (u_transformPositionViewToUv * eyeCoordinates).xyz;
126
+ viewDirUv = normalize(u_cameraDirectionUv);
127
+ } else {
128
+ viewPosUv = u_cameraPositionUv;
129
+ viewDirUv = normalize(u_transformDirectionViewToLocal * eyeCoordinates.xyz);
130
+ }
122
131
  #if defined(SHAPE_ELLIPSOID)
123
132
  // viewDirUv has been scaled to a space where the ellipsoid is a sphere.
124
133
  // Undo this scaling to get the raw direction.
125
134
  vec3 rawDir = viewDirUv * u_ellipsoidRadiiUv;
126
- Ray viewRayUv = Ray(viewPosUv, viewDirUv, rawDir);
135
+ return Ray(viewPosUv, viewDirUv, rawDir);
127
136
  #else
128
- Ray viewRayUv = Ray(viewPosUv, viewDirUv, viewDirUv);
137
+ return Ray(viewPosUv, viewDirUv, viewDirUv);
129
138
  #endif
139
+ }
140
+
141
+ void main()
142
+ {
143
+ Ray viewRayUv = getViewRayUv();
130
144
 
131
145
  Intersections ix;
146
+ vec2 screenCoord = (gl_FragCoord.xy - czm_viewport.xy) / czm_viewport.zw; // [0,1]
132
147
  RayShapeIntersection shapeIntersection = intersectScene(screenCoord, viewRayUv, ix);
133
-
134
148
  // Exit early if the scene was completely missed.
135
149
  if (shapeIntersection.entry.w == NO_HIT) {
136
150
  discard;
@@ -138,7 +152,7 @@ void main()
138
152
 
139
153
  float currentT = shapeIntersection.entry.w;
140
154
  float endT = shapeIntersection.exit.w;
141
- vec3 positionUv = viewPosUv + currentT * viewDirUv;
155
+ vec3 positionUv = viewRayUv.pos + currentT * viewRayUv.dir;
142
156
  PointJacobianT pointJacobian = convertUvToShapeUvSpaceDerivative(positionUv);
143
157
 
144
158
  // Traverse the tree from the start position
@@ -150,14 +164,15 @@ void main()
150
164
  #if defined(JITTER)
151
165
  float noise = hash(screenCoord); // [0,1]
152
166
  currentT += noise * step.w;
153
- positionUv += noise * step.w * viewDirUv;
167
+ positionUv += noise * step.w * viewRayUv.dir;
154
168
  #endif
155
169
 
156
170
  FragmentInput fragmentInput;
157
171
  #if defined(STATISTICS)
158
- setStatistics(fragmentInput.metadata.statistics);
172
+ setStatistics(fragmentInput.metadataStatistics);
159
173
  #endif
160
174
 
175
+ czm_modelMaterial materialOutput;
161
176
  vec4 colorAccum = vec4(0.0);
162
177
 
163
178
  for (int stepCount = 0; stepCount < STEP_COUNT_MAX; ++stepCount) {
@@ -166,19 +181,19 @@ void main()
166
181
 
167
182
  // Prepare the custom shader inputs
168
183
  copyPropertiesToMetadata(properties, fragmentInput.metadata);
169
- fragmentInput.voxel.positionUv = positionUv;
170
- fragmentInput.voxel.positionShapeUv = pointJacobian.point;
171
- fragmentInput.voxel.positionUvLocal = sampleDatas[0].tileUv;
172
- fragmentInput.voxel.viewDirUv = viewDirUv;
173
- fragmentInput.voxel.viewDirWorld = viewDirWorld;
174
- fragmentInput.voxel.surfaceNormal = step.xyz;
184
+
185
+ fragmentInput.attributes.positionEC = vec3(u_transformPositionUvToView * vec4(positionUv, 1.0));
186
+ fragmentInput.attributes.normalEC = normalize(czm_normal * step.xyz);
187
+
188
+ fragmentInput.voxel.viewDirUv = viewRayUv.dir;
189
+
175
190
  fragmentInput.voxel.travelDistance = step.w;
176
191
  fragmentInput.voxel.stepCount = stepCount;
177
192
  fragmentInput.voxel.tileIndex = sampleDatas[0].megatextureIndex;
178
193
  fragmentInput.voxel.sampleIndex = getSampleIndex(sampleDatas[0]);
194
+ fragmentInput.voxel.distanceToDepthBuffer = ix.distanceToDepthBuffer - currentT;
179
195
 
180
196
  // Run the custom shader
181
- czm_modelMaterial materialOutput;
182
197
  fragmentMain(fragmentInput, materialOutput);
183
198
 
184
199
  // Sanitize the custom shader output
@@ -203,8 +218,6 @@ void main()
203
218
 
204
219
  // Keep raymarching
205
220
  currentT += step.w;
206
- positionUv = viewPosUv + currentT * viewDirUv;
207
-
208
221
  // Check if there's more intersections.
209
222
  if (currentT > endT) {
210
223
  #if (INTERSECTION_COUNT == 1)
@@ -217,10 +230,10 @@ void main()
217
230
  // Found another intersection. Resume raymarching there
218
231
  currentT = shapeIntersection.entry.w;
219
232
  endT = shapeIntersection.exit.w;
220
- positionUv = viewPosUv + currentT * viewDirUv;
221
233
  }
222
234
  #endif
223
235
  }
236
+ positionUv = viewRayUv.pos + currentT * viewRayUv.dir;
224
237
 
225
238
  // Traverse the tree from the current ray position.
226
239
  // This is similar to traverseOctreeFromBeginning but is faster when the ray is in the same tile as the previous step.