@cesium/engine 17.0.0 → 18.0.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 (150) hide show
  1. package/Build/ThirdParty/Workers/z-worker-pako.js +1 -1
  2. package/Build/Workers/{chunk-4TIR5UPL.js → chunk-2AXPWBJG.js} +1 -1
  3. package/Build/Workers/{chunk-CAKU6ZPR.js → chunk-2CAYUY2B.js} +8 -8
  4. package/Build/Workers/{chunk-PS3OKVOQ.js → chunk-2NKHPWDY.js} +12 -12
  5. package/Build/Workers/{chunk-VXAKU6EV.js → chunk-2QNKQVUT.js} +5 -5
  6. package/Build/Workers/{chunk-ZTBZMRQT.js → chunk-3RKVDGRF.js} +8 -8
  7. package/Build/Workers/{chunk-J2HTPGC7.js → chunk-4DSTDGY3.js} +2 -2
  8. package/Build/Workers/{chunk-P2N5IDWU.js → chunk-4MIY63FM.js} +13 -13
  9. package/Build/Workers/{chunk-XYGBWBD5.js → chunk-5OL6XFNS.js} +1 -1
  10. package/Build/Workers/{chunk-E7SMO47Q.js → chunk-5WVF4BK7.js} +5 -5
  11. package/Build/Workers/{chunk-SQKTLDSD.js → chunk-AEGAQ6FD.js} +12 -12
  12. package/Build/Workers/{chunk-4BGKMM7J.js → chunk-CES6DHHV.js} +1 -1
  13. package/Build/Workers/{chunk-MAIKDIBS.js → chunk-DINSLSJD.js} +6 -6
  14. package/Build/Workers/{chunk-G6JUXZUO.js → chunk-EHB2OCQX.js} +4 -4
  15. package/Build/Workers/{chunk-SSLK4U3V.js → chunk-EXEZHW3P.js} +4 -4
  16. package/Build/Workers/{chunk-236N6BJN.js → chunk-F4ZAKN4V.js} +2 -2
  17. package/Build/Workers/{chunk-HBNWBMAM.js → chunk-FPYBD2P5.js} +1 -1
  18. package/Build/Workers/{chunk-5PC577K7.js → chunk-GAUF4F5A.js} +16 -16
  19. package/Build/Workers/{chunk-YE6MDFDA.js → chunk-GM55YFOB.js} +14 -14
  20. package/Build/Workers/{chunk-HGEGZ67N.js → chunk-GS55WTRX.js} +6 -6
  21. package/Build/Workers/{chunk-LPGOAMYH.js → chunk-HQE7KSR4.js} +2 -2
  22. package/Build/Workers/{chunk-IFIS4CVK.js → chunk-HS76VTVY.js} +2 -2
  23. package/Build/Workers/{chunk-7IIMO7ZZ.js → chunk-I3BAKR4S.js} +16 -16
  24. package/Build/Workers/{chunk-PM4Q36WX.js → chunk-IWGMVQGG.js} +9 -9
  25. package/Build/Workers/{chunk-UFV3YUIN.js → chunk-IWZK2AIH.js} +5 -5
  26. package/Build/Workers/{chunk-QJTIOB2Z.js → chunk-J4MAVE6J.js} +6 -6
  27. package/Build/Workers/{chunk-RX65FA7X.js → chunk-JF4IYQYC.js} +7 -7
  28. package/Build/Workers/{chunk-7PHT4JHA.js → chunk-KGXTCGX3.js} +12 -12
  29. package/Build/Workers/{chunk-K5JTWJPE.js → chunk-KNA65INJ.js} +4 -4
  30. package/Build/Workers/{chunk-CBFJVM6I.js → chunk-LIPZUYNR.js} +11 -11
  31. package/Build/Workers/{chunk-C5DCX2YQ.js → chunk-LWJWWCZ4.js} +6 -6
  32. package/Build/Workers/{chunk-KE45DUDH.js → chunk-LZFUG3GO.js} +10 -10
  33. package/Build/Workers/{chunk-P57PR3WM.js → chunk-MFGVMUN3.js} +5 -5
  34. package/Build/Workers/{chunk-QUFN3GEO.js → chunk-NR7KSD56.js} +3 -3
  35. package/Build/Workers/{chunk-MS5NWDHH.js → chunk-NVJ5JRIM.js} +2 -2
  36. package/Build/Workers/{chunk-CQMXZF4A.js → chunk-NWSAYFZG.js} +6 -6
  37. package/Build/Workers/{chunk-5YEFZMMM.js → chunk-OATG6PKE.js} +12 -12
  38. package/Build/Workers/{chunk-UX5JWAC7.js → chunk-OIHAAHBK.js} +10 -10
  39. package/Build/Workers/{chunk-DRMXU674.js → chunk-QN7JEOQV.js} +5 -5
  40. package/Build/Workers/{chunk-77MDEA47.js → chunk-QUSP3NWA.js} +5 -5
  41. package/Build/Workers/{chunk-GO3RZX2R.js → chunk-RWFYLWSF.js} +9 -9
  42. package/Build/Workers/{chunk-UZ6KXWCA.js → chunk-SIOVJ4L5.js} +4 -4
  43. package/Build/Workers/{chunk-OBHLT34A.js → chunk-T6B6H3GR.js} +7 -7
  44. package/Build/Workers/{chunk-IKDQX7DY.js → chunk-UK33ZN4K.js} +4 -4
  45. package/Build/Workers/{chunk-2BJXFXD7.js → chunk-VGJSKEIB.js} +4 -4
  46. package/Build/Workers/{chunk-5RPUEFSA.js → chunk-W6CPO62M.js} +6 -6
  47. package/Build/Workers/{chunk-37PA7GZW.js → chunk-WGHUCZMX.js} +7 -7
  48. package/Build/Workers/{chunk-UC7KH56Y.js → chunk-WTFZHPUW.js} +5 -5
  49. package/Build/Workers/{chunk-NZSBSY5K.js → chunk-WYCR5DWQ.js} +2 -2
  50. package/Build/Workers/{chunk-WP3IJYLC.js → chunk-YV37YFUM.js} +9 -9
  51. package/Build/Workers/{chunk-LVGYWPEX.js → chunk-ZADJ6FRX.js} +4 -4
  52. package/Build/Workers/{chunk-CC2WKHIW.js → chunk-ZIP27IX6.js} +6 -6
  53. package/Build/Workers/combineGeometry.js +21 -21
  54. package/Build/Workers/createBoxGeometry.js +15 -15
  55. package/Build/Workers/createBoxOutlineGeometry.js +13 -13
  56. package/Build/Workers/createCircleGeometry.js +23 -23
  57. package/Build/Workers/createCircleOutlineGeometry.js +16 -16
  58. package/Build/Workers/createCoplanarPolygonGeometry.js +30 -30
  59. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +28 -28
  60. package/Build/Workers/createCorridorGeometry.js +26 -26
  61. package/Build/Workers/createCorridorOutlineGeometry.js +25 -25
  62. package/Build/Workers/createCylinderGeometry.js +17 -17
  63. package/Build/Workers/createCylinderOutlineGeometry.js +15 -15
  64. package/Build/Workers/createEllipseGeometry.js +23 -23
  65. package/Build/Workers/createEllipseOutlineGeometry.js +16 -16
  66. package/Build/Workers/createEllipsoidGeometry.js +16 -16
  67. package/Build/Workers/createEllipsoidOutlineGeometry.js +15 -15
  68. package/Build/Workers/createFrustumGeometry.js +15 -15
  69. package/Build/Workers/createFrustumOutlineGeometry.js +15 -15
  70. package/Build/Workers/createGeometry.js +21 -21
  71. package/Build/Workers/createGroundPolylineGeometry.js +19 -19
  72. package/Build/Workers/createPlaneGeometry.js +13 -13
  73. package/Build/Workers/createPlaneOutlineGeometry.js +12 -12
  74. package/Build/Workers/createPolygonGeometry.js +29 -29
  75. package/Build/Workers/createPolygonOutlineGeometry.js +27 -27
  76. package/Build/Workers/createPolylineGeometry.js +22 -22
  77. package/Build/Workers/createPolylineVolumeGeometry.js +28 -28
  78. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +24 -24
  79. package/Build/Workers/createRectangleGeometry.js +24 -24
  80. package/Build/Workers/createRectangleOutlineGeometry.js +17 -17
  81. package/Build/Workers/createSimplePolylineGeometry.js +20 -20
  82. package/Build/Workers/createSphereGeometry.js +16 -16
  83. package/Build/Workers/createSphereOutlineGeometry.js +15 -15
  84. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  85. package/Build/Workers/createVectorTileClampedPolylines.js +12 -12
  86. package/Build/Workers/createVectorTileGeometries.js +21 -21
  87. package/Build/Workers/createVectorTilePoints.js +11 -11
  88. package/Build/Workers/createVectorTilePolygons.js +19 -19
  89. package/Build/Workers/createVectorTilePolylines.js +12 -12
  90. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +19 -19
  91. package/Build/Workers/createVerticesFromHeightmap.js +19 -19
  92. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +16 -16
  93. package/Build/Workers/createWallGeometry.js +21 -21
  94. package/Build/Workers/createWallOutlineGeometry.js +20 -20
  95. package/Build/Workers/decodeDraco.js +10 -10
  96. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  97. package/Build/Workers/decodeI3S.js +9 -9
  98. package/Build/Workers/transcodeKTX2.js +25 -6
  99. package/Build/Workers/transferTypedArrayTest.js +1 -1
  100. package/Build/Workers/upsampleQuantizedTerrainMesh.js +19 -19
  101. package/Source/Core/Ion.js +1 -1
  102. package/Source/Core/PixelFormat.js +36 -0
  103. package/Source/Renderer/Texture3D.js +568 -0
  104. package/Source/Renderer/createUniform.js +1 -0
  105. package/Source/Renderer/createUniformArray.js +1 -0
  106. package/Source/Scene/ArcGisMapService.js +1 -1
  107. package/Source/Scene/Cesium3DTileset.js +138 -0
  108. package/Source/Scene/GlobeSurfaceShaderSet.js +4 -5
  109. package/Source/Scene/ImageryLayer.js +19 -4
  110. package/Source/Scene/ImageryLayerCollection.js +3 -2
  111. package/Source/Scene/Model/CartesianRectangle.js +108 -0
  112. package/Source/Scene/Model/ImageryConfiguration.js +25 -0
  113. package/Source/Scene/Model/ImageryCoverage.js +488 -0
  114. package/Source/Scene/Model/ImageryFlags.js +31 -0
  115. package/Source/Scene/Model/ImageryInput.js +60 -0
  116. package/Source/Scene/Model/ImageryPipelineStage.js +1040 -0
  117. package/Source/Scene/Model/MappedPositions.js +84 -0
  118. package/Source/Scene/Model/Model.js +38 -0
  119. package/Source/Scene/Model/ModelImagery.js +403 -0
  120. package/Source/Scene/Model/ModelImageryMapping.js +489 -0
  121. package/Source/Scene/Model/ModelPrimitiveImagery.js +972 -0
  122. package/Source/Scene/Model/ModelReader.js +810 -0
  123. package/Source/Scene/Model/ModelRenderResources.js +13 -0
  124. package/Source/Scene/Model/ModelRuntimePrimitive.js +19 -0
  125. package/Source/Scene/Model/ModelSceneGraph.js +133 -27
  126. package/Source/Scene/Model/NodeRenderResources.js +10 -0
  127. package/Source/Scene/ModelComponents.js +10 -0
  128. package/Source/Scene/VoxelPrimitive.js +22 -37
  129. package/Source/Scene/VoxelRenderResources.js +1 -1
  130. package/Source/Scene/processVoxelProperties.js +41 -100
  131. package/Source/Shaders/Builtin/Functions/windowToEyeCoordinates.glsl +0 -1
  132. package/Source/Shaders/Builtin/Functions/windowToEyeCoordinates.js +0 -1
  133. package/Source/Shaders/GlobeFS.glsl +22 -0
  134. package/Source/Shaders/GlobeFS.js +22 -0
  135. package/Source/Shaders/Model/MaterialStageFS.glsl +4 -0
  136. package/Source/Shaders/Model/MaterialStageFS.js +4 -0
  137. package/Source/Shaders/Model/ModelVS.glsl +4 -0
  138. package/Source/Shaders/Model/ModelVS.js +4 -0
  139. package/Source/Shaders/Voxels/IntersectDepth.glsl +10 -3
  140. package/Source/Shaders/Voxels/IntersectDepth.js +10 -3
  141. package/Source/Shaders/Voxels/Intersection.glsl +1 -3
  142. package/Source/Shaders/Voxels/Intersection.js +1 -3
  143. package/Source/Shaders/Voxels/IntersectionUtils.glsl +1 -0
  144. package/Source/Shaders/Voxels/IntersectionUtils.js +1 -0
  145. package/Source/Shaders/Voxels/VoxelFS.glsl +37 -24
  146. package/Source/Shaders/Voxels/VoxelFS.js +37 -24
  147. package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
  148. package/index.d.ts +50 -2
  149. package/index.js +100 -88
  150. package/package.json +3 -3
@@ -38,7 +38,7 @@ function processVoxelProperties(renderResources, primitive) {
38
38
  // PropertyStatistics structs
39
39
  for (let i = 0; i < attributeLength; i++) {
40
40
  const name = names[i];
41
- const type = types[i];
41
+ const glslType = getGlslType(types[i]);
42
42
  const propertyStatisticsStructId = `PropertyStatistics_${name}`;
43
43
  const propertyStatisticsStructName = `PropertyStatistics_${name}`;
44
44
  shaderBuilder.addStruct(
@@ -46,18 +46,17 @@ function processVoxelProperties(renderResources, primitive) {
46
46
  propertyStatisticsStructName,
47
47
  ShaderDestination.FRAGMENT,
48
48
  );
49
- const glslType = getGlslType(type);
50
49
  shaderBuilder.addStructField(propertyStatisticsStructId, glslType, "min");
51
50
  shaderBuilder.addStructField(propertyStatisticsStructId, glslType, "max");
52
51
  }
53
52
 
54
- // Statistics struct
55
- const statisticsStructId = "Statistics";
56
- const statisticsStructName = "Statistics";
57
- const statisticsFieldName = "statistics";
53
+ // MetadataStatistics struct
54
+ const metadataStatisticsStructId = "MetadataStatistics";
55
+ const metadataStatisticsStructName = "MetadataStatistics";
56
+ const metadataStatisticsFieldName = "metadataStatistics";
58
57
  shaderBuilder.addStruct(
59
- statisticsStructId,
60
- statisticsStructName,
58
+ metadataStatisticsStructId,
59
+ metadataStatisticsStructName,
61
60
  ShaderDestination.FRAGMENT,
62
61
  );
63
62
  for (let i = 0; i < attributeLength; i++) {
@@ -65,7 +64,7 @@ function processVoxelProperties(renderResources, primitive) {
65
64
  const propertyStructName = `PropertyStatistics_${name}`;
66
65
  const propertyFieldName = name;
67
66
  shaderBuilder.addStructField(
68
- statisticsStructId,
67
+ metadataStatisticsStructId,
69
68
  propertyStructName,
70
69
  propertyFieldName,
71
70
  );
@@ -80,51 +79,22 @@ function processVoxelProperties(renderResources, primitive) {
80
79
  metadataStructName,
81
80
  ShaderDestination.FRAGMENT,
82
81
  );
83
- shaderBuilder.addStructField(
84
- metadataStructId,
85
- statisticsStructName,
86
- statisticsFieldName,
87
- );
88
82
  for (let i = 0; i < attributeLength; i++) {
89
- const name = names[i];
90
- const type = types[i];
91
- const glslType = getGlslType(type);
92
- shaderBuilder.addStructField(metadataStructId, glslType, name);
83
+ const glslType = getGlslType(types[i]);
84
+ shaderBuilder.addStructField(metadataStructId, glslType, names[i]);
93
85
  }
94
86
 
95
- // VoxelProperty structs
96
- for (let i = 0; i < attributeLength; i++) {
97
- const name = names[i];
98
- const type = types[i];
99
- const glslType = getGlslPartialDerivativeType(type);
100
- const voxelPropertyStructId = `VoxelProperty_${name}`;
101
- const voxelPropertyStructName = `VoxelProperty_${name}`;
102
- shaderBuilder.addStruct(
103
- voxelPropertyStructId,
104
- voxelPropertyStructName,
105
- ShaderDestination.FRAGMENT,
106
- );
107
- shaderBuilder.addStructField(
108
- voxelPropertyStructId,
109
- glslType,
110
- "partialDerivativeLocal",
111
- );
112
- shaderBuilder.addStructField(
113
- voxelPropertyStructId,
114
- glslType,
115
- "partialDerivativeWorld",
116
- );
117
- shaderBuilder.addStructField(
118
- voxelPropertyStructId,
119
- glslType,
120
- "partialDerivativeView",
121
- );
122
- shaderBuilder.addStructField(
123
- voxelPropertyStructId,
124
- glslType,
125
- "partialDerivativeValid",
126
- );
127
- }
87
+ // Attributes struct
88
+ const attributesStructId = "Attributes";
89
+ const attributesStructName = "Attributes";
90
+ const attributesFieldName = "attributes";
91
+ shaderBuilder.addStruct(
92
+ attributesStructId,
93
+ attributesStructName,
94
+ ShaderDestination.FRAGMENT,
95
+ );
96
+ shaderBuilder.addStructField(attributesStructId, "vec3", "positionEC");
97
+ shaderBuilder.addStructField(attributesStructId, "vec3", "normalEC");
128
98
 
129
99
  // Voxel struct
130
100
  const voxelStructId = "Voxel";
@@ -135,22 +105,12 @@ function processVoxelProperties(renderResources, primitive) {
135
105
  voxelStructName,
136
106
  ShaderDestination.FRAGMENT,
137
107
  );
138
- for (let i = 0; i < attributeLength; i++) {
139
- const name = names[i];
140
- const voxelPropertyStructName = `VoxelProperty_${name}`;
141
- shaderBuilder.addStructField(voxelStructId, voxelPropertyStructName, name);
142
- }
143
- shaderBuilder.addStructField(voxelStructId, "vec3", "positionEC");
144
- shaderBuilder.addStructField(voxelStructId, "vec3", "positionUv");
145
- shaderBuilder.addStructField(voxelStructId, "vec3", "positionShapeUv");
146
- shaderBuilder.addStructField(voxelStructId, "vec3", "positionUvLocal");
147
108
  shaderBuilder.addStructField(voxelStructId, "vec3", "viewDirUv");
148
- shaderBuilder.addStructField(voxelStructId, "vec3", "viewDirWorld");
149
- shaderBuilder.addStructField(voxelStructId, "vec3", "surfaceNormal");
150
109
  shaderBuilder.addStructField(voxelStructId, "float", "travelDistance");
151
110
  shaderBuilder.addStructField(voxelStructId, "int", "stepCount");
152
111
  shaderBuilder.addStructField(voxelStructId, "int", "tileIndex");
153
112
  shaderBuilder.addStructField(voxelStructId, "int", "sampleIndex");
113
+ shaderBuilder.addStructField(voxelStructId, "float", "distanceToDepthBuffer");
154
114
 
155
115
  // FragmentInput struct
156
116
  const fragmentInputStructId = "FragmentInput";
@@ -160,11 +120,21 @@ function processVoxelProperties(renderResources, primitive) {
160
120
  fragmentInputStructName,
161
121
  ShaderDestination.FRAGMENT,
162
122
  );
123
+ shaderBuilder.addStructField(
124
+ fragmentInputStructId,
125
+ metadataStatisticsStructName,
126
+ metadataStatisticsFieldName,
127
+ );
163
128
  shaderBuilder.addStructField(
164
129
  fragmentInputStructId,
165
130
  metadataStructName,
166
131
  metadataFieldName,
167
132
  );
133
+ shaderBuilder.addStructField(
134
+ fragmentInputStructId,
135
+ attributesStructName,
136
+ attributesFieldName,
137
+ );
168
138
  shaderBuilder.addStructField(
169
139
  fragmentInputStructId,
170
140
  voxelStructName,
@@ -181,10 +151,8 @@ function processVoxelProperties(renderResources, primitive) {
181
151
  ShaderDestination.FRAGMENT,
182
152
  );
183
153
  for (let i = 0; i < attributeLength; i++) {
184
- const name = names[i];
185
- const type = types[i];
186
- const glslType = getGlslType(type);
187
- shaderBuilder.addStructField(propertiesStructId, glslType, name);
154
+ const glslType = getGlslType(types[i]);
155
+ shaderBuilder.addStructField(propertiesStructId, glslType, names[i]);
188
156
  }
189
157
 
190
158
  // Fragment shader functions
@@ -201,12 +169,9 @@ function processVoxelProperties(renderResources, primitive) {
201
169
  `${propertiesStructName} ${propertiesFieldName};`,
202
170
  ]);
203
171
  for (let i = 0; i < attributeLength; i++) {
204
- const name = names[i];
205
- const type = types[i];
206
- const componentType = componentTypes[i];
207
- const glslType = getGlslType(type, componentType);
172
+ const glslType = getGlslType(types[i], componentTypes[i]);
208
173
  shaderBuilder.addFunctionLines(functionId, [
209
- `${propertiesFieldName}.${name} = ${glslType}(0.0);`,
174
+ `${propertiesFieldName}.${names[i]} = ${glslType}(0.0);`,
210
175
  ]);
211
176
  }
212
177
  shaderBuilder.addFunctionLines(functionId, [
@@ -248,9 +213,8 @@ function processVoxelProperties(renderResources, primitive) {
248
213
  `${propertiesStructName} scaledProperties = ${propertiesFieldName};`,
249
214
  ]);
250
215
  for (let i = 0; i < attributeLength; i++) {
251
- const name = names[i];
252
216
  shaderBuilder.addFunctionLines(functionId, [
253
- `scaledProperties.${name} *= scale;`,
217
+ `scaledProperties.${names[i]} *= scale;`,
254
218
  ]);
255
219
  }
256
220
  shaderBuilder.addFunctionLines(functionId, [`return scaledProperties;`]);
@@ -299,7 +263,7 @@ function processVoxelProperties(renderResources, primitive) {
299
263
  const functionId = "setStatistics";
300
264
  shaderBuilder.addFunction(
301
265
  functionId,
302
- `void setStatistics(inout ${statisticsStructName} ${statisticsFieldName})`,
266
+ `void setStatistics(inout ${metadataStatisticsStructName} ${metadataStatisticsFieldName})`,
303
267
  ShaderDestination.FRAGMENT,
304
268
  );
305
269
  for (let i = 0; i < attributeLength; i++) {
@@ -314,10 +278,10 @@ function processVoxelProperties(renderResources, primitive) {
314
278
  continue;
315
279
  }
316
280
  shaderBuilder.addFunctionLines(functionId, [
317
- `${statisticsFieldName}.${name}.min${glslField} = ${getGlslNumberAsFloat(
281
+ `${metadataStatisticsFieldName}.${name}.min${glslField} = ${getGlslNumberAsFloat(
318
282
  minimumValue,
319
283
  )};`,
320
- `${statisticsFieldName}.${name}.max${glslField} = ${getGlslNumberAsFloat(
284
+ `${metadataStatisticsFieldName}.${name}.max${glslField} = ${getGlslNumberAsFloat(
321
285
  maximumValue,
322
286
  )};`,
323
287
  ]);
@@ -337,12 +301,11 @@ function processVoxelProperties(renderResources, primitive) {
337
301
  `${propertiesStructName} ${propertiesFieldName};`,
338
302
  ]);
339
303
  for (let i = 0; i < attributeLength; i++) {
340
- const name = names[i];
341
304
  const type = types[i];
342
305
  const componentType = componentTypes[i];
343
306
  const glslTextureSwizzle = getGlslTextureSwizzle(type, componentType);
344
307
  shaderBuilder.addFunctionLines(functionId, [
345
- `properties.${name} = texture(u_megatextureTextures[${i}], texcoord)${glslTextureSwizzle};`,
308
+ `properties.${names[i]} = texture(u_megatextureTextures[${i}], texcoord)${glslTextureSwizzle};`,
346
309
  ]);
347
310
  }
348
311
  shaderBuilder.addFunctionLines(functionId, [
@@ -395,28 +358,6 @@ function getGlslTextureSwizzle(type) {
395
358
  }
396
359
  }
397
360
 
398
- /**
399
- * Gets the GLSL type of the partial derivative of {@link MetadataType}.
400
- *
401
- * @function
402
- *
403
- * @param {MetadataType} type The {@link MetadataType}.
404
- * @returns {string} The GLSL type.
405
- *
406
- * @private
407
- */
408
- function getGlslPartialDerivativeType(type) {
409
- if (type === MetadataType.SCALAR) {
410
- return "vec3";
411
- } else if (type === MetadataType.VEC2) {
412
- return "mat2";
413
- } else if (type === MetadataType.VEC3) {
414
- return "mat3";
415
- } else if (type === MetadataType.VEC4) {
416
- return "mat4";
417
- }
418
- }
419
-
420
361
  /**
421
362
  * GLSL needs to have `.0` at the end of whole number floats or else it's
422
363
  * treated like an integer.
@@ -76,7 +76,6 @@ vec4 czm_screenToEyeCoordinates(vec2 screenCoordinateXY, float depthOrLogDepth)
76
76
  vec4 screenCoord = vec4(screenCoordinateXY, far * (1.0 - near / depthFromCamera) / (far - near), 1.0);
77
77
  vec4 eyeCoordinate = czm_screenToEyeCoordinates(screenCoord);
78
78
  eyeCoordinate.w = 1.0 / depthFromCamera; // Better precision
79
- return eyeCoordinate;
80
79
  #else
81
80
  vec4 screenCoord = vec4(screenCoordinateXY, depthOrLogDepth, 1.0);
82
81
  vec4 eyeCoordinate = czm_screenToEyeCoordinates(screenCoord);
@@ -77,7 +77,6 @@ vec4 czm_screenToEyeCoordinates(vec2 screenCoordinateXY, float depthOrLogDepth)\
77
77
  vec4 screenCoord = vec4(screenCoordinateXY, far * (1.0 - near / depthFromCamera) / (far - near), 1.0);\n\
78
78
  vec4 eyeCoordinate = czm_screenToEyeCoordinates(screenCoord);\n\
79
79
  eyeCoordinate.w = 1.0 / depthFromCamera; // Better precision\n\
80
- return eyeCoordinate;\n\
81
80
  #else\n\
82
81
  vec4 screenCoord = vec4(screenCoordinateXY, depthOrLogDepth, 1.0);\n\
83
82
  vec4 eyeCoordinate = czm_screenToEyeCoordinates(screenCoord);\n\
@@ -87,25 +87,47 @@ flat in int v_regionIndex;
87
87
  uniform float u_minimumBrightness;
88
88
  #endif
89
89
 
90
+ // Based on colorCorrect
91
+ // The colorCorrect flag can only be true when tileProvider.hue/saturation/brightnessShift
92
+ // are nonzero AND when (applyFog || showGroundAtmosphere) in the tile provider
93
+ // - The tileProvider.hue/saturation/brightnessShift are just passed through
94
+ // from the Globe hue/saturation/brightness, like atmosphereBrightnessShift
95
+ // - The applyFog depends on enableFog, and some tile distance from the viewer
96
+ // - The showGroundAtmosphere is a flag that is passed through from the Globe,
97
+ // and is true by default when the ellipsoid is WGS84
90
98
  #ifdef COLOR_CORRECT
91
99
  uniform vec3 u_hsbShift; // Hue, saturation, brightness
92
100
  #endif
93
101
 
102
+ // Based on highlightFillTile
103
+ // This is set for terrain tiles when they are "fill" tiles, and
104
+ // the terrainProvider.fillHighlightColor was set to a value with
105
+ // nonzero alpha
94
106
  #ifdef HIGHLIGHT_FILL_TILE
95
107
  uniform vec4 u_fillHighlightColor;
96
108
  #endif
97
109
 
110
+ // Based on translucent
111
+ // This is set depending on the GlobeTranslucencyState
98
112
  #ifdef TRANSLUCENT
99
113
  uniform vec4 u_frontFaceAlphaByDistance;
100
114
  uniform vec4 u_backFaceAlphaByDistance;
101
115
  uniform vec4 u_translucencyRectangle;
102
116
  #endif
103
117
 
118
+ // Based on showUndergroundColor
119
+ // This is set when GlobeSurfaceTileProvider.isUndergroundVisible
120
+ // returns true, AND the tileProvider.undergroundColor had a value with
121
+ // nonzero alpha, and the tileProvider.undergroundColorAlphaByDistance
122
+ // was in the right range
104
123
  #ifdef UNDERGROUND_COLOR
105
124
  uniform vec4 u_undergroundColor;
106
125
  uniform vec4 u_undergroundColorAlphaByDistance;
107
126
  #endif
108
127
 
128
+ // Based on enableLighting && hasVertexNormals
129
+ // The enableLighting flag is passed in directly from the Globe.
130
+ // The hasVertexNormals flag is from the tileProvider
109
131
  #ifdef ENABLE_VERTEX_LIGHTING
110
132
  uniform float u_lambertDiffuseMultiplier;
111
133
  uniform float u_vertexShadowDarkness;
@@ -88,25 +88,47 @@ flat in int v_regionIndex;\n\
88
88
  uniform float u_minimumBrightness;\n\
89
89
  #endif\n\
90
90
  \n\
91
+ // Based on colorCorrect\n\
92
+ // The colorCorrect flag can only be true when tileProvider.hue/saturation/brightnessShift \n\
93
+ // are nonzero AND when (applyFog || showGroundAtmosphere) in the tile provider\n\
94
+ // - The tileProvider.hue/saturation/brightnessShift are just passed through\n\
95
+ // from the Globe hue/saturation/brightness, like atmosphereBrightnessShift\n\
96
+ // - The applyFog depends on enableFog, and some tile distance from the viewer\n\
97
+ // - The showGroundAtmosphere is a flag that is passed through from the Globe,\n\
98
+ // and is true by default when the ellipsoid is WGS84\n\
91
99
  #ifdef COLOR_CORRECT\n\
92
100
  uniform vec3 u_hsbShift; // Hue, saturation, brightness\n\
93
101
  #endif\n\
94
102
  \n\
103
+ // Based on highlightFillTile\n\
104
+ // This is set for terrain tiles when they are \"fill\" tiles, and\n\
105
+ // the terrainProvider.fillHighlightColor was set to a value with\n\
106
+ // nonzero alpha\n\
95
107
  #ifdef HIGHLIGHT_FILL_TILE\n\
96
108
  uniform vec4 u_fillHighlightColor;\n\
97
109
  #endif\n\
98
110
  \n\
111
+ // Based on translucent\n\
112
+ // This is set depending on the GlobeTranslucencyState\n\
99
113
  #ifdef TRANSLUCENT\n\
100
114
  uniform vec4 u_frontFaceAlphaByDistance;\n\
101
115
  uniform vec4 u_backFaceAlphaByDistance;\n\
102
116
  uniform vec4 u_translucencyRectangle;\n\
103
117
  #endif\n\
104
118
  \n\
119
+ // Based on showUndergroundColor\n\
120
+ // This is set when GlobeSurfaceTileProvider.isUndergroundVisible \n\
121
+ // returns true, AND the tileProvider.undergroundColor had a value with \n\
122
+ // nonzero alpha, and the tileProvider.undergroundColorAlphaByDistance\n\
123
+ // was in the right range\n\
105
124
  #ifdef UNDERGROUND_COLOR\n\
106
125
  uniform vec4 u_undergroundColor;\n\
107
126
  uniform vec4 u_undergroundColorAlphaByDistance;\n\
108
127
  #endif\n\
109
128
  \n\
129
+ // Based on enableLighting && hasVertexNormals\n\
130
+ // The enableLighting flag is passed in directly from the Globe.\n\
131
+ // The hasVertexNormals flag is from the tileProvider\n\
110
132
  #ifdef ENABLE_VERTEX_LIGHTING\n\
111
133
  uniform float u_lambertDiffuseMultiplier;\n\
112
134
  uniform float u_vertexShadowDarkness;\n\
@@ -444,6 +444,10 @@ void materialStage(inout czm_modelMaterial material, ProcessedAttributes attribu
444
444
  baseColorWithAlpha = u_baseColorFactor;
445
445
  #endif
446
446
 
447
+ #ifdef HAS_IMAGERY
448
+ baseColorWithAlpha = blendBaseColorWithImagery(baseColorWithAlpha);
449
+ #endif // HAS_IMAGERY
450
+
447
451
  #ifdef HAS_POINT_CLOUD_COLOR_STYLE
448
452
  baseColorWithAlpha = v_pointCloudColor;
449
453
  #elif defined(HAS_COLOR_0)
@@ -444,6 +444,10 @@ void materialStage(inout czm_modelMaterial material, ProcessedAttributes attribu
444
444
  #elif defined(HAS_BASE_COLOR_FACTOR)\n\
445
445
  baseColorWithAlpha = u_baseColorFactor;\n\
446
446
  #endif\n\
447
+ \n\
448
+ #ifdef HAS_IMAGERY\n\
449
+ baseColorWithAlpha = blendBaseColorWithImagery(baseColorWithAlpha);\n\
450
+ #endif // HAS_IMAGERY\n\
447
451
  \n\
448
452
  #ifdef HAS_POINT_CLOUD_COLOR_STYLE\n\
449
453
  baseColorWithAlpha = v_pointCloudColor;\n\
@@ -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
@@ -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\
@@ -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.