@cesium/engine 6.1.1 → 7.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.
- package/Build/ThirdParty/Workers/z-worker-pako.js +568 -407
- package/Build/Workers/{chunk-FRG2Z7DE.js → chunk-2HJWSU7B.js} +4 -4
- package/Build/Workers/{chunk-ZTYE74E2.js → chunk-46UD5ABS.js} +4 -4
- package/Build/Workers/{chunk-VODWDCX6.js → chunk-4EBHOMFX.js} +18 -20
- package/Build/Workers/{chunk-N7TYCDTR.js → chunk-5HDYHG3F.js} +13 -13
- package/Build/Workers/{chunk-C53JYYKX.js → chunk-5M3U6ZMA.js} +1 -1
- package/Build/Workers/{chunk-GTEXWEAP.js → chunk-5WQ523AW.js} +5 -5
- package/Build/Workers/{chunk-SEFDWMCW.js → chunk-5YLJ77FF.js} +31 -21
- package/Build/Workers/{chunk-VNRUVNIK.js → chunk-6HZQPRUS.js} +1 -1
- package/Build/Workers/{chunk-PB7BIXHI.js → chunk-6VJVYK2V.js} +2 -2
- package/Build/Workers/{chunk-PHQVHDVI.js → chunk-72SANQJV.js} +325 -5
- package/Build/Workers/{chunk-D325WRAY.js → chunk-7XEAYGZK.js} +35 -11
- package/Build/Workers/{chunk-FGUP2QEP.js → chunk-AIPU2VSX.js} +6 -6
- package/Build/Workers/{chunk-QUXSQQEF.js → chunk-AR5DNBJ4.js} +6 -6
- package/Build/Workers/{chunk-ZVUAJKAL.js → chunk-BZP4T2JJ.js} +11 -13
- package/Build/Workers/{chunk-K6Q5IRBK.js → chunk-DTAIXKTO.js} +6 -6
- package/Build/Workers/{chunk-D4YHO4NZ.js → chunk-F6SE42BK.js} +133 -101
- package/Build/Workers/{chunk-QY2WY5XJ.js → chunk-FP6GYBFX.js} +11 -11
- package/Build/Workers/{chunk-Z6LPXA7S.js → chunk-GEJTYLCO.js} +5 -5
- package/Build/Workers/{chunk-VKTKOIYG.js → chunk-GV56Q4LU.js} +11 -11
- package/Build/Workers/{chunk-KUB2HQXR.js → chunk-IQBYFRVW.js} +8 -8
- package/Build/Workers/{chunk-235MRXLH.js → chunk-IX2JCCNM.js} +1 -1
- package/Build/Workers/{chunk-3FCUUN6M.js → chunk-JCNXK6EL.js} +11 -11
- package/Build/Workers/{chunk-364TQORK.js → chunk-JJ4VBOQ3.js} +5 -7
- package/Build/Workers/{chunk-66CXKODF.js → chunk-JXDC723O.js} +2 -2
- package/Build/Workers/{chunk-OTBRPBCC.js → chunk-JY5YEZFA.js} +9 -9
- package/Build/Workers/{chunk-LSGUCCKJ.js → chunk-L2ZN645J.js} +6 -6
- package/Build/Workers/{chunk-VLDDXYKI.js → chunk-LZ7JIV3K.js} +18 -18
- package/Build/Workers/{chunk-36ESDRIZ.js → chunk-LZGHD6NY.js} +16 -16
- package/Build/Workers/{chunk-PXLFBN2Q.js → chunk-MY3VNFGQ.js} +7 -7
- package/Build/Workers/{chunk-W7F5VTH6.js → chunk-NKPBIX7F.js} +1 -1
- package/Build/Workers/{chunk-XBZSOW3F.js → chunk-NY3K4IM3.js} +12 -12
- package/Build/Workers/{chunk-AI3KSNM6.js → chunk-ODW7WYM4.js} +2 -2
- package/Build/Workers/{chunk-6PWSSCRA.js → chunk-OVLG3FRS.js} +6 -6
- package/Build/Workers/{chunk-MOLGJDJV.js → chunk-PNBGBETF.js} +11 -11
- package/Build/Workers/{chunk-T73B27DG.js → chunk-PTQQUQC3.js} +13 -13
- package/Build/Workers/{chunk-RSWBNJPT.js → chunk-QZAD5O7I.js} +8 -304
- package/Build/Workers/{chunk-I6TVJ6T7.js → chunk-R5X4OQT4.js} +8 -8
- package/Build/Workers/{chunk-DTNN3ODA.js → chunk-RAEV7K66.js} +5 -5
- package/Build/Workers/{chunk-IZED7ODV.js → chunk-RV7ZYPFT.js} +4 -4
- package/Build/Workers/{chunk-7FEGZO3D.js → chunk-S4MAZ3SS.js} +2 -2
- package/Build/Workers/{chunk-J3U6Z5YQ.js → chunk-S6SKF6DT.js} +5 -5
- package/Build/Workers/{chunk-CHDJ66UM.js → chunk-U2VCRRQW.js} +6 -6
- package/Build/Workers/{chunk-R22RQAAM.js → chunk-UAEW6HKG.js} +13 -13
- package/Build/Workers/{chunk-S7IBK36I.js → chunk-UDO6BFSF.js} +14 -16
- package/Build/Workers/{chunk-YS4KPNLC.js → chunk-UGK3FCDY.js} +1 -1
- package/Build/Workers/{chunk-SJDXMQSP.js → chunk-VK3EJHWI.js} +2 -2
- package/Build/Workers/{chunk-HEROVJML.js → chunk-VRGFV2UO.js} +7 -7
- package/Build/Workers/{chunk-VOAZN4IP.js → chunk-WBQCVXR3.js} +4 -4
- package/Build/Workers/{chunk-HSW63JN4.js → chunk-WZU2YLWG.js} +3 -3
- package/Build/Workers/{chunk-4EYB62WJ.js → chunk-XWXM2O2R.js} +6 -6
- package/Build/Workers/{chunk-ZGMOBRTG.js → chunk-YUCVWAY6.js} +7 -7
- package/Build/Workers/{chunk-CLVEIRXT.js → chunk-ZK5JOS3D.js} +15 -17
- package/Build/Workers/{chunk-5NZTU5YL.js → chunk-ZUA2UUNV.js} +2 -2
- package/Build/Workers/combineGeometry.js +23 -23
- package/Build/Workers/createBoxGeometry.js +17 -17
- package/Build/Workers/createBoxOutlineGeometry.js +15 -15
- package/Build/Workers/createCircleGeometry.js +25 -25
- package/Build/Workers/createCircleOutlineGeometry.js +18 -18
- package/Build/Workers/createCoplanarPolygonGeometry.js +33 -34
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +30 -30
- package/Build/Workers/createCorridorGeometry.js +28 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +27 -28
- package/Build/Workers/createCylinderGeometry.js +19 -19
- package/Build/Workers/createCylinderOutlineGeometry.js +18 -19
- package/Build/Workers/createEllipseGeometry.js +25 -25
- package/Build/Workers/createEllipseOutlineGeometry.js +18 -18
- package/Build/Workers/createEllipsoidGeometry.js +18 -18
- package/Build/Workers/createEllipsoidOutlineGeometry.js +17 -17
- package/Build/Workers/createFrustumGeometry.js +17 -17
- package/Build/Workers/createFrustumOutlineGeometry.js +17 -17
- package/Build/Workers/createGeometry.js +23 -23
- package/Build/Workers/createGroundPolylineGeometry.js +22 -22
- package/Build/Workers/createPlaneGeometry.js +15 -15
- package/Build/Workers/createPlaneOutlineGeometry.js +14 -14
- package/Build/Workers/createPolygonGeometry.js +32 -167
- package/Build/Workers/createPolygonOutlineGeometry.js +29 -29
- package/Build/Workers/createPolylineGeometry.js +24 -24
- package/Build/Workers/createPolylineVolumeGeometry.js +32 -35
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -29
- package/Build/Workers/createRectangleGeometry.js +27 -27
- package/Build/Workers/createRectangleOutlineGeometry.js +21 -23
- package/Build/Workers/createSimplePolylineGeometry.js +22 -22
- package/Build/Workers/createSphereGeometry.js +18 -18
- package/Build/Workers/createSphereOutlineGeometry.js +17 -17
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
- package/Build/Workers/createVectorTileGeometries.js +23 -23
- package/Build/Workers/createVectorTilePoints.js +12 -12
- package/Build/Workers/createVectorTilePolygons.js +21 -21
- package/Build/Workers/createVectorTilePolylines.js +14 -14
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
- package/Build/Workers/createVerticesFromHeightmap.js +22 -22
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +19 -19
- package/Build/Workers/createWallGeometry.js +23 -23
- package/Build/Workers/createWallOutlineGeometry.js +22 -22
- package/Build/Workers/decodeDraco.js +11 -11
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +9 -9
- package/Build/Workers/transcodeKTX2.js +7 -7
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
- package/LICENSE.md +1 -1
- package/Source/Assets/approximateTerrainHeights.json +1 -1
- package/Source/Core/Ellipsoid.js +45 -0
- package/Source/Core/GregorianDate.js +85 -0
- package/Source/Core/HeadingPitchRange.js +2 -2
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/PolygonGeometry.js +0 -169
- package/Source/Core/Quaternion.js +6 -2
- package/Source/Core/RectangleOutlineGeometry.js +2 -4
- package/Source/Core/RequestScheduler.js +3 -9
- package/Source/Core/Resource.js +30 -69
- package/Source/Core/TerrainEncoding.js +2 -2
- package/Source/Core/Transforms.js +27 -18
- package/Source/Core/VerticalExaggeration.js +69 -0
- package/Source/Core/createWorldBathymetryAsync.js +45 -0
- package/Source/DataSources/EllipsoidGeometryUpdater.js +3 -4
- package/Source/DataSources/Entity.js +8 -5
- package/Source/DataSources/EntityCollection.js +1 -2
- package/Source/DataSources/GeometryUpdater.js +1 -2
- package/Source/DataSources/GroundGeometryUpdater.js +6 -3
- package/Source/DataSources/ModelVisualizer.js +19 -98
- package/Source/DataSources/PolygonGeometryUpdater.js +14 -2
- package/Source/DataSources/PolylineGeometryUpdater.js +9 -8
- package/Source/DataSources/TerrainOffsetProperty.js +15 -23
- package/Source/Renderer/AutomaticUniforms.js +173 -0
- package/Source/Renderer/UniformState.js +246 -1
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Atmosphere.js +127 -0
- package/Source/Scene/Billboard.js +29 -26
- package/Source/Scene/BillboardCollection.js +3 -3
- package/Source/Scene/Camera.js +1 -1
- package/Source/Scene/Cesium3DTile.js +123 -10
- package/Source/Scene/Cesium3DTileContent.js +14 -0
- package/Source/Scene/Cesium3DTileset.js +326 -45
- package/Source/Scene/Cesium3DTilesetTraversal.js +4 -0
- package/Source/Scene/Composite3DTileContent.js +42 -0
- package/Source/Scene/DynamicAtmosphereLightingType.js +56 -0
- package/Source/Scene/Empty3DTileContent.js +4 -0
- package/Source/Scene/Fog.js +1 -0
- package/Source/Scene/FrameState.js +13 -5
- package/Source/Scene/Geometry3DTileContent.js +4 -0
- package/Source/Scene/Globe.js +69 -21
- package/Source/Scene/GlobeSurfaceTile.js +4 -4
- package/Source/Scene/GlobeSurfaceTileProvider.js +24 -22
- package/Source/Scene/GltfLoader.js +15 -5
- package/Source/Scene/GroundPrimitive.js +5 -5
- package/Source/Scene/HeightReference.js +59 -2
- package/Source/Scene/ImageryLayer.js +3 -3
- package/Source/Scene/Implicit3DTileContent.js +4 -0
- package/Source/Scene/LabelCollection.js +2 -2
- package/Source/Scene/MapboxImageryProvider.js +2 -2
- package/Source/Scene/Megatexture.js +1 -1
- package/Source/Scene/Model/AtmospherePipelineStage.js +59 -0
- package/Source/Scene/Model/B3dmLoader.js +4 -0
- package/Source/Scene/Model/FeatureIdPipelineStage.js +25 -2
- package/Source/Scene/Model/I3dmLoader.js +4 -0
- package/Source/Scene/Model/InstancingPipelineStage.js +24 -6
- package/Source/Scene/Model/MetadataPipelineStage.js +31 -3
- package/Source/Scene/Model/Model.js +93 -32
- package/Source/Scene/Model/Model3DTileContent.js +31 -0
- package/Source/Scene/Model/ModelAnimationChannel.js +16 -15
- package/Source/Scene/Model/ModelRuntimePrimitive.js +6 -0
- package/Source/Scene/Model/ModelSceneGraph.js +6 -0
- package/Source/Scene/Model/VerticalExaggerationPipelineStage.js +60 -0
- package/Source/Scene/Model/pickModel.js +408 -0
- package/Source/Scene/Multiple3DTileContent.js +42 -0
- package/Source/Scene/QuadtreePrimitive.js +1 -1
- package/Source/Scene/Scene.js +226 -19
- package/Source/Scene/ScreenSpaceCameraController.js +14 -25
- package/Source/Scene/SkyAtmosphere.js +5 -6
- package/Source/Scene/Terrain.js +49 -0
- package/Source/Scene/TerrainFillMesh.js +2 -2
- package/Source/Scene/TileBoundingS2Cell.js +2 -2
- package/Source/Scene/TileOrientedBoundingBox.js +1 -1
- package/Source/Scene/Tileset3DTileContent.js +4 -0
- package/Source/Scene/Vector3DTileContent.js +4 -0
- package/Source/Scene/VoxelPrimitive.js +73 -2
- package/Source/Shaders/AtmosphereCommon.glsl +3 -11
- package/Source/Shaders/AtmosphereCommon.js +3 -11
- package/Source/Shaders/Builtin/CzmBuiltins.js +12 -0
- package/Source/Shaders/Builtin/Functions/applyHSBShift.glsl +32 -0
- package/Source/Shaders/Builtin/Functions/applyHSBShift.js +34 -0
- package/Source/Shaders/Builtin/Functions/approximateTanh.glsl +10 -0
- package/Source/Shaders/Builtin/Functions/approximateTanh.js +12 -0
- package/Source/Shaders/Builtin/Functions/computeAtmosphereColor.glsl +44 -0
- package/Source/Shaders/Builtin/Functions/computeAtmosphereColor.js +46 -0
- package/Source/Shaders/Builtin/Functions/computeGroundAtmosphereScattering.glsl +30 -0
- package/Source/Shaders/Builtin/Functions/computeGroundAtmosphereScattering.js +32 -0
- package/Source/Shaders/Builtin/Functions/computeScattering.glsl +150 -0
- package/Source/Shaders/Builtin/Functions/computeScattering.js +152 -0
- package/Source/Shaders/Builtin/Functions/getDynamicAtmosphereLightDirection.glsl +22 -0
- package/Source/Shaders/Builtin/Functions/getDynamicAtmosphereLightDirection.js +24 -0
- package/Source/Shaders/Builtin/Functions/translateRelativeToEye.glsl +5 -0
- package/Source/Shaders/Builtin/Functions/translateRelativeToEye.js +5 -0
- package/Source/Shaders/GlobeFS.glsl +16 -25
- package/Source/Shaders/GlobeFS.js +16 -25
- package/Source/Shaders/GlobeVS.glsl +4 -4
- package/Source/Shaders/GlobeVS.js +4 -4
- package/Source/Shaders/Model/AtmosphereStageFS.glsl +111 -0
- package/Source/Shaders/Model/AtmosphereStageFS.js +113 -0
- package/Source/Shaders/Model/AtmosphereStageVS.glsl +12 -0
- package/Source/Shaders/Model/AtmosphereStageVS.js +14 -0
- package/Source/Shaders/Model/GeometryStageFS.glsl +1 -1
- package/Source/Shaders/Model/GeometryStageFS.js +1 -1
- package/Source/Shaders/Model/GeometryStageVS.glsl +4 -4
- package/Source/Shaders/Model/GeometryStageVS.js +4 -4
- package/Source/Shaders/Model/ModelColorStageFS.glsl +1 -1
- package/Source/Shaders/Model/ModelColorStageFS.js +2 -1
- package/Source/Shaders/Model/ModelFS.glsl +4 -0
- package/Source/Shaders/Model/ModelFS.js +4 -0
- package/Source/Shaders/Model/ModelVS.glsl +13 -4
- package/Source/Shaders/Model/ModelVS.js +13 -4
- package/Source/Shaders/Model/VerticalExaggerationStageVS.glsl +39 -0
- package/Source/Shaders/Model/VerticalExaggerationStageVS.js +41 -0
- package/Source/Shaders/SkyAtmosphereCommon.glsl +3 -13
- package/Source/Shaders/SkyAtmosphereCommon.js +3 -13
- package/Source/Shaders/SkyAtmosphereFS.glsl +5 -10
- package/Source/Shaders/SkyAtmosphereFS.js +5 -10
- package/Source/Shaders/SkyAtmosphereVS.glsl +3 -2
- package/Source/Shaders/SkyAtmosphereVS.js +3 -2
- package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
- package/Source/ThirdParty/draco_decoder.wasm +0 -0
- package/index.d.ts +318 -83
- package/index.js +77 -62
- package/package.json +3 -3
- package/Build/Workers/chunk-7ONRI7T4.js +0 -55
- package/Source/Core/TerrainExaggeration.js +0 -49
|
@@ -131,6 +131,38 @@ function VoxelPrimitive(options) {
|
|
|
131
131
|
*/
|
|
132
132
|
this._maxBoundsOld = new Cartesian3();
|
|
133
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Minimum bounds with vertical exaggeration applied
|
|
136
|
+
*
|
|
137
|
+
* @type {Cartesian3}
|
|
138
|
+
* @private
|
|
139
|
+
*/
|
|
140
|
+
this._exaggeratedMinBounds = new Cartesian3();
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Used to detect if the shape is dirty.
|
|
144
|
+
*
|
|
145
|
+
* @type {Cartesian3}
|
|
146
|
+
* @private
|
|
147
|
+
*/
|
|
148
|
+
this._exaggeratedMinBoundsOld = new Cartesian3();
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Maximum bounds with vertical exaggeration applied
|
|
152
|
+
*
|
|
153
|
+
* @type {Cartesian3}
|
|
154
|
+
* @private
|
|
155
|
+
*/
|
|
156
|
+
this._exaggeratedMaxBounds = new Cartesian3();
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Used to detect if the shape is dirty.
|
|
160
|
+
*
|
|
161
|
+
* @type {Cartesian3}
|
|
162
|
+
* @private
|
|
163
|
+
*/
|
|
164
|
+
this._exaggeratedMaxBoundsOld = new Cartesian3();
|
|
165
|
+
|
|
134
166
|
/**
|
|
135
167
|
* This member is not known until the provider is ready.
|
|
136
168
|
*
|
|
@@ -442,6 +474,7 @@ function initialize(primitive, provider) {
|
|
|
442
474
|
// Create the shape object, and update it so it is valid for VoxelTraversal
|
|
443
475
|
const ShapeConstructor = VoxelShapeType.getShapeConstructor(shapeType);
|
|
444
476
|
primitive._shape = new ShapeConstructor();
|
|
477
|
+
updateVerticalExaggeration(primitive);
|
|
445
478
|
primitive._shapeVisible = updateShapeAndTransforms(
|
|
446
479
|
primitive,
|
|
447
480
|
primitive._shape,
|
|
@@ -964,6 +997,8 @@ VoxelPrimitive.prototype.update = function (frameState) {
|
|
|
964
997
|
return;
|
|
965
998
|
}
|
|
966
999
|
|
|
1000
|
+
updateVerticalExaggeration(this, frameState);
|
|
1001
|
+
|
|
967
1002
|
// Check if the shape is dirty before updating it. This needs to happen every
|
|
968
1003
|
// frame because the member variables can be modified externally via the
|
|
969
1004
|
// getters.
|
|
@@ -1107,6 +1142,32 @@ VoxelPrimitive.prototype.update = function (frameState) {
|
|
|
1107
1142
|
frameState.commandList.push(command);
|
|
1108
1143
|
};
|
|
1109
1144
|
|
|
1145
|
+
/**
|
|
1146
|
+
* Update the exaggerated bounds of a primitive to account for vertical exaggeration
|
|
1147
|
+
* Currently only applies to Ellipsoid shape type
|
|
1148
|
+
* @param {VoxelPrimitive} primitive
|
|
1149
|
+
* @param {FrameState} [frameState]
|
|
1150
|
+
* @private
|
|
1151
|
+
*/
|
|
1152
|
+
function updateVerticalExaggeration(primitive, frameState) {
|
|
1153
|
+
primitive._exaggeratedMinBounds = Cartesian3.clone(
|
|
1154
|
+
primitive._minBounds,
|
|
1155
|
+
primitive._exaggeratedMinBounds
|
|
1156
|
+
);
|
|
1157
|
+
primitive._exaggeratedMaxBounds = Cartesian3.clone(
|
|
1158
|
+
primitive._maxBounds,
|
|
1159
|
+
primitive._exaggeratedMaxBounds
|
|
1160
|
+
);
|
|
1161
|
+
if (defined(frameState) && primitive.shape === VoxelShapeType.ELLIPSOID) {
|
|
1162
|
+
const relativeHeight = frameState.verticalExaggerationRelativeHeight;
|
|
1163
|
+
const exaggeration = frameState.verticalExaggeration;
|
|
1164
|
+
primitive._exaggeratedMinBounds.z =
|
|
1165
|
+
(primitive._minBounds.z - relativeHeight) * exaggeration + relativeHeight;
|
|
1166
|
+
primitive._exaggeratedMaxBounds.z =
|
|
1167
|
+
(primitive._maxBounds.z - relativeHeight) * exaggeration + relativeHeight;
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1110
1171
|
/**
|
|
1111
1172
|
* Initialize primitive properties that are derived from the voxel provider
|
|
1112
1173
|
* @param {VoxelPrimitive} primitive
|
|
@@ -1203,6 +1264,16 @@ function checkTransformAndBounds(primitive, provider) {
|
|
|
1203
1264
|
updateBound(primitive, "_compoundModelMatrix", "_compoundModelMatrixOld") +
|
|
1204
1265
|
updateBound(primitive, "_minBounds", "_minBoundsOld") +
|
|
1205
1266
|
updateBound(primitive, "_maxBounds", "_maxBoundsOld") +
|
|
1267
|
+
updateBound(
|
|
1268
|
+
primitive,
|
|
1269
|
+
"_exaggeratedMinBounds",
|
|
1270
|
+
"_exaggeratedMinBoundsOld"
|
|
1271
|
+
) +
|
|
1272
|
+
updateBound(
|
|
1273
|
+
primitive,
|
|
1274
|
+
"_exaggeratedMaxBounds",
|
|
1275
|
+
"_exaggeratedMaxBoundsOld"
|
|
1276
|
+
) +
|
|
1206
1277
|
updateBound(primitive, "_minClippingBounds", "_minClippingBoundsOld") +
|
|
1207
1278
|
updateBound(primitive, "_maxClippingBounds", "_maxClippingBoundsOld");
|
|
1208
1279
|
return numChanges > 0;
|
|
@@ -1239,8 +1310,8 @@ function updateBound(primitive, newBoundKey, oldBoundKey) {
|
|
|
1239
1310
|
function updateShapeAndTransforms(primitive, shape, provider) {
|
|
1240
1311
|
const visible = shape.update(
|
|
1241
1312
|
primitive._compoundModelMatrix,
|
|
1242
|
-
primitive.
|
|
1243
|
-
primitive.
|
|
1313
|
+
primitive._exaggeratedMinBounds,
|
|
1314
|
+
primitive._exaggeratedMaxBounds,
|
|
1244
1315
|
primitive.minClippingBounds,
|
|
1245
1316
|
primitive.maxClippingBounds
|
|
1246
1317
|
);
|
|
@@ -11,14 +11,6 @@ const float ATMOSPHERE_THICKNESS = 111e3; // The thickness of the atmosphere in
|
|
|
11
11
|
const int PRIMARY_STEPS_MAX = 16; // Maximum number of times the ray from the camera to the world position (primary ray) is sampled.
|
|
12
12
|
const int LIGHT_STEPS_MAX = 4; // Maximum number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.
|
|
13
13
|
|
|
14
|
-
/**
|
|
15
|
-
* Rational approximation to tanh(x)
|
|
16
|
-
*/
|
|
17
|
-
float approximateTanh(float x) {
|
|
18
|
-
float x2 = x * x;
|
|
19
|
-
return max(-1.0, min(+1.0, x * (27.0 + x2) / (27.0 + 9.0 * x2)));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
14
|
/**
|
|
23
15
|
* This function computes the colors contributed by Rayliegh and Mie scattering on a given ray, as well as
|
|
24
16
|
* the transmittance value for the ray.
|
|
@@ -65,8 +57,8 @@ void computeScattering(
|
|
|
65
57
|
float x = 1e-7 * primaryRayAtmosphereIntersect.stop / length(primaryRayLength);
|
|
66
58
|
// Value close to 0.0: close to the horizon
|
|
67
59
|
// Value close to 1.0: above in the sky
|
|
68
|
-
float w_stop_gt_lprl = 0.5 * (1.0 +
|
|
69
|
-
|
|
60
|
+
float w_stop_gt_lprl = 0.5 * (1.0 + czm_approximateTanh(x));
|
|
61
|
+
|
|
70
62
|
// The ray should start from the first intersection with the outer atmopshere, or from the camera position, if it is inside the atmosphere.
|
|
71
63
|
float start_0 = primaryRayAtmosphereIntersect.start;
|
|
72
64
|
primaryRayAtmosphereIntersect.start = max(primaryRayAtmosphereIntersect.start, 0.0);
|
|
@@ -77,7 +69,7 @@ void computeScattering(
|
|
|
77
69
|
// (1) from outer space we have to use more ray steps to get a realistic rendering
|
|
78
70
|
// (2) within atmosphere we need fewer steps for faster rendering
|
|
79
71
|
float x_o_a = start_0 - ATMOSPHERE_THICKNESS; // ATMOSPHERE_THICKNESS used as an ad-hoc constant, no precise meaning here, only the order of magnitude matters
|
|
80
|
-
float w_inside_atmosphere = 1.0 - 0.5 * (1.0 +
|
|
72
|
+
float w_inside_atmosphere = 1.0 - 0.5 * (1.0 + czm_approximateTanh(x_o_a));
|
|
81
73
|
int PRIMARY_STEPS = PRIMARY_STEPS_MAX - int(w_inside_atmosphere * 12.0); // Number of times the ray from the camera to the world position (primary ray) is sampled.
|
|
82
74
|
int LIGHT_STEPS = LIGHT_STEPS_MAX - int(w_inside_atmosphere * 2.0); // Number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.
|
|
83
75
|
|
|
@@ -12,14 +12,6 @@ const float ATMOSPHERE_THICKNESS = 111e3; // The thickness of the atmosphere in
|
|
|
12
12
|
const int PRIMARY_STEPS_MAX = 16; // Maximum number of times the ray from the camera to the world position (primary ray) is sampled.\n\
|
|
13
13
|
const int LIGHT_STEPS_MAX = 4; // Maximum number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.\n\
|
|
14
14
|
\n\
|
|
15
|
-
/**\n\
|
|
16
|
-
* Rational approximation to tanh(x)\n\
|
|
17
|
-
*/\n\
|
|
18
|
-
float approximateTanh(float x) {\n\
|
|
19
|
-
float x2 = x * x;\n\
|
|
20
|
-
return max(-1.0, min(+1.0, x * (27.0 + x2) / (27.0 + 9.0 * x2)));\n\
|
|
21
|
-
}\n\
|
|
22
|
-
\n\
|
|
23
15
|
/**\n\
|
|
24
16
|
* This function computes the colors contributed by Rayliegh and Mie scattering on a given ray, as well as\n\
|
|
25
17
|
* the transmittance value for the ray.\n\
|
|
@@ -66,8 +58,8 @@ void computeScattering(\n\
|
|
|
66
58
|
float x = 1e-7 * primaryRayAtmosphereIntersect.stop / length(primaryRayLength);\n\
|
|
67
59
|
// Value close to 0.0: close to the horizon\n\
|
|
68
60
|
// Value close to 1.0: above in the sky\n\
|
|
69
|
-
float w_stop_gt_lprl = 0.5 * (1.0 +
|
|
70
|
-
|
|
61
|
+
float w_stop_gt_lprl = 0.5 * (1.0 + czm_approximateTanh(x));\n\
|
|
62
|
+
\n\
|
|
71
63
|
// The ray should start from the first intersection with the outer atmopshere, or from the camera position, if it is inside the atmosphere.\n\
|
|
72
64
|
float start_0 = primaryRayAtmosphereIntersect.start;\n\
|
|
73
65
|
primaryRayAtmosphereIntersect.start = max(primaryRayAtmosphereIntersect.start, 0.0);\n\
|
|
@@ -78,7 +70,7 @@ void computeScattering(\n\
|
|
|
78
70
|
// (1) from outer space we have to use more ray steps to get a realistic rendering\n\
|
|
79
71
|
// (2) within atmosphere we need fewer steps for faster rendering\n\
|
|
80
72
|
float x_o_a = start_0 - ATMOSPHERE_THICKNESS; // ATMOSPHERE_THICKNESS used as an ad-hoc constant, no precise meaning here, only the order of magnitude matters\n\
|
|
81
|
-
float w_inside_atmosphere = 1.0 - 0.5 * (1.0 +
|
|
73
|
+
float w_inside_atmosphere = 1.0 - 0.5 * (1.0 + czm_approximateTanh(x_o_a));\n\
|
|
82
74
|
int PRIMARY_STEPS = PRIMARY_STEPS_MAX - int(w_inside_atmosphere * 12.0); // Number of times the ray from the camera to the world position (primary ray) is sampled.\n\
|
|
83
75
|
int LIGHT_STEPS = LIGHT_STEPS_MAX - int(w_inside_atmosphere * 2.0); // Number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.\n\
|
|
84
76
|
\n\
|
|
@@ -55,7 +55,9 @@ import czm_XYZToRGB from './Functions/XYZToRGB.js'
|
|
|
55
55
|
import czm_acesTonemapping from './Functions/acesTonemapping.js'
|
|
56
56
|
import czm_alphaWeight from './Functions/alphaWeight.js'
|
|
57
57
|
import czm_antialias from './Functions/antialias.js'
|
|
58
|
+
import czm_applyHSBShift from './Functions/applyHSBShift.js'
|
|
58
59
|
import czm_approximateSphericalCoordinates from './Functions/approximateSphericalCoordinates.js'
|
|
60
|
+
import czm_approximateTanh from './Functions/approximateTanh.js'
|
|
59
61
|
import czm_backFacing from './Functions/backFacing.js'
|
|
60
62
|
import czm_branchFreeTernary from './Functions/branchFreeTernary.js'
|
|
61
63
|
import czm_cascadeColor from './Functions/cascadeColor.js'
|
|
@@ -63,7 +65,10 @@ import czm_cascadeDistance from './Functions/cascadeDistance.js'
|
|
|
63
65
|
import czm_cascadeMatrix from './Functions/cascadeMatrix.js'
|
|
64
66
|
import czm_cascadeWeights from './Functions/cascadeWeights.js'
|
|
65
67
|
import czm_columbusViewMorph from './Functions/columbusViewMorph.js'
|
|
68
|
+
import czm_computeAtmosphereColor from './Functions/computeAtmosphereColor.js'
|
|
69
|
+
import czm_computeGroundAtmosphereScattering from './Functions/computeGroundAtmosphereScattering.js'
|
|
66
70
|
import czm_computePosition from './Functions/computePosition.js'
|
|
71
|
+
import czm_computeScattering from './Functions/computeScattering.js'
|
|
67
72
|
import czm_cosineAndSine from './Functions/cosineAndSine.js'
|
|
68
73
|
import czm_decompressTextureCoordinates from './Functions/decompressTextureCoordinates.js'
|
|
69
74
|
import czm_defaultPbrMaterial from './Functions/defaultPbrMaterial.js'
|
|
@@ -79,6 +84,7 @@ import czm_fog from './Functions/fog.js'
|
|
|
79
84
|
import czm_gammaCorrect from './Functions/gammaCorrect.js'
|
|
80
85
|
import czm_geodeticSurfaceNormal from './Functions/geodeticSurfaceNormal.js'
|
|
81
86
|
import czm_getDefaultMaterial from './Functions/getDefaultMaterial.js'
|
|
87
|
+
import czm_getDynamicAtmosphereLightDirection from './Functions/getDynamicAtmosphereLightDirection.js'
|
|
82
88
|
import czm_getLambertDiffuse from './Functions/getLambertDiffuse.js'
|
|
83
89
|
import czm_getSpecular from './Functions/getSpecular.js'
|
|
84
90
|
import czm_getWaterNoise from './Functions/getWaterNoise.js'
|
|
@@ -188,7 +194,9 @@ export default {
|
|
|
188
194
|
czm_acesTonemapping : czm_acesTonemapping,
|
|
189
195
|
czm_alphaWeight : czm_alphaWeight,
|
|
190
196
|
czm_antialias : czm_antialias,
|
|
197
|
+
czm_applyHSBShift : czm_applyHSBShift,
|
|
191
198
|
czm_approximateSphericalCoordinates : czm_approximateSphericalCoordinates,
|
|
199
|
+
czm_approximateTanh : czm_approximateTanh,
|
|
192
200
|
czm_backFacing : czm_backFacing,
|
|
193
201
|
czm_branchFreeTernary : czm_branchFreeTernary,
|
|
194
202
|
czm_cascadeColor : czm_cascadeColor,
|
|
@@ -196,7 +204,10 @@ export default {
|
|
|
196
204
|
czm_cascadeMatrix : czm_cascadeMatrix,
|
|
197
205
|
czm_cascadeWeights : czm_cascadeWeights,
|
|
198
206
|
czm_columbusViewMorph : czm_columbusViewMorph,
|
|
207
|
+
czm_computeAtmosphereColor : czm_computeAtmosphereColor,
|
|
208
|
+
czm_computeGroundAtmosphereScattering : czm_computeGroundAtmosphereScattering,
|
|
199
209
|
czm_computePosition : czm_computePosition,
|
|
210
|
+
czm_computeScattering : czm_computeScattering,
|
|
200
211
|
czm_cosineAndSine : czm_cosineAndSine,
|
|
201
212
|
czm_decompressTextureCoordinates : czm_decompressTextureCoordinates,
|
|
202
213
|
czm_defaultPbrMaterial : czm_defaultPbrMaterial,
|
|
@@ -212,6 +223,7 @@ export default {
|
|
|
212
223
|
czm_gammaCorrect : czm_gammaCorrect,
|
|
213
224
|
czm_geodeticSurfaceNormal : czm_geodeticSurfaceNormal,
|
|
214
225
|
czm_getDefaultMaterial : czm_getDefaultMaterial,
|
|
226
|
+
czm_getDynamicAtmosphereLightDirection : czm_getDynamicAtmosphereLightDirection,
|
|
215
227
|
czm_getLambertDiffuse : czm_getLambertDiffuse,
|
|
216
228
|
czm_getSpecular : czm_getSpecular,
|
|
217
229
|
czm_getWaterNoise : czm_getWaterNoise,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apply a HSB color shift to an RGB color.
|
|
3
|
+
*
|
|
4
|
+
* @param {vec3} rgb The color in RGB space.
|
|
5
|
+
* @param {vec3} hsbShift The amount to shift each component. The xyz components correspond to hue, saturation, and brightness. Shifting the hue by +/- 1.0 corresponds to shifting the hue by a full cycle. Saturation and brightness are clamped between 0 and 1 after the adjustment
|
|
6
|
+
* @param {bool} ignoreBlackPixels If true, black pixels will be unchanged. This is necessary in some shaders such as atmosphere-related effects.
|
|
7
|
+
*
|
|
8
|
+
* @return {vec3} The RGB color after shifting in HSB space and clamping saturation and brightness to a valid range.
|
|
9
|
+
*/
|
|
10
|
+
vec3 czm_applyHSBShift(vec3 rgb, vec3 hsbShift, bool ignoreBlackPixels) {
|
|
11
|
+
// Convert rgb color to hsb
|
|
12
|
+
vec3 hsb = czm_RGBToHSB(rgb);
|
|
13
|
+
|
|
14
|
+
// Perform hsb shift
|
|
15
|
+
// Hue cycles around so no clamp is needed.
|
|
16
|
+
hsb.x += hsbShift.x; // hue
|
|
17
|
+
hsb.y = clamp(hsb.y + hsbShift.y, 0.0, 1.0); // saturation
|
|
18
|
+
|
|
19
|
+
// brightness
|
|
20
|
+
//
|
|
21
|
+
// Some shaders such as atmosphere-related effects need to leave black
|
|
22
|
+
// pixels unchanged
|
|
23
|
+
if (ignoreBlackPixels) {
|
|
24
|
+
hsb.z = hsb.z > czm_epsilon7 ? hsb.z + hsbShift.z : 0.0;
|
|
25
|
+
} else {
|
|
26
|
+
hsb.z = hsb.z + hsbShift.z;
|
|
27
|
+
}
|
|
28
|
+
hsb.z = clamp(hsb.z, 0.0, 1.0);
|
|
29
|
+
|
|
30
|
+
// Convert shifted hsb back to rgb
|
|
31
|
+
return czm_HSBToRGB(hsb);
|
|
32
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
+
export default "/**\n\
|
|
3
|
+
* Apply a HSB color shift to an RGB color.\n\
|
|
4
|
+
*\n\
|
|
5
|
+
* @param {vec3} rgb The color in RGB space.\n\
|
|
6
|
+
* @param {vec3} hsbShift The amount to shift each component. The xyz components correspond to hue, saturation, and brightness. Shifting the hue by +/- 1.0 corresponds to shifting the hue by a full cycle. Saturation and brightness are clamped between 0 and 1 after the adjustment\n\
|
|
7
|
+
* @param {bool} ignoreBlackPixels If true, black pixels will be unchanged. This is necessary in some shaders such as atmosphere-related effects.\n\
|
|
8
|
+
*\n\
|
|
9
|
+
* @return {vec3} The RGB color after shifting in HSB space and clamping saturation and brightness to a valid range.\n\
|
|
10
|
+
*/\n\
|
|
11
|
+
vec3 czm_applyHSBShift(vec3 rgb, vec3 hsbShift, bool ignoreBlackPixels) {\n\
|
|
12
|
+
// Convert rgb color to hsb\n\
|
|
13
|
+
vec3 hsb = czm_RGBToHSB(rgb);\n\
|
|
14
|
+
\n\
|
|
15
|
+
// Perform hsb shift\n\
|
|
16
|
+
// Hue cycles around so no clamp is needed.\n\
|
|
17
|
+
hsb.x += hsbShift.x; // hue\n\
|
|
18
|
+
hsb.y = clamp(hsb.y + hsbShift.y, 0.0, 1.0); // saturation\n\
|
|
19
|
+
\n\
|
|
20
|
+
// brightness\n\
|
|
21
|
+
//\n\
|
|
22
|
+
// Some shaders such as atmosphere-related effects need to leave black\n\
|
|
23
|
+
// pixels unchanged\n\
|
|
24
|
+
if (ignoreBlackPixels) {\n\
|
|
25
|
+
hsb.z = hsb.z > czm_epsilon7 ? hsb.z + hsbShift.z : 0.0;\n\
|
|
26
|
+
} else {\n\
|
|
27
|
+
hsb.z = hsb.z + hsbShift.z;\n\
|
|
28
|
+
}\n\
|
|
29
|
+
hsb.z = clamp(hsb.z, 0.0, 1.0);\n\
|
|
30
|
+
\n\
|
|
31
|
+
// Convert shifted hsb back to rgb\n\
|
|
32
|
+
return czm_HSBToRGB(hsb);\n\
|
|
33
|
+
}\n\
|
|
34
|
+
";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute a rational approximation to tanh(x)
|
|
3
|
+
*
|
|
4
|
+
* @param {float} x A real number input
|
|
5
|
+
* @returns {float} An approximation for tanh(x)
|
|
6
|
+
*/
|
|
7
|
+
float czm_approximateTanh(float x) {
|
|
8
|
+
float x2 = x * x;
|
|
9
|
+
return max(-1.0, min(1.0, x * (27.0 + x2) / (27.0 + 9.0 * x2)));
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
+
export default "/**\n\
|
|
3
|
+
* Compute a rational approximation to tanh(x)\n\
|
|
4
|
+
*\n\
|
|
5
|
+
* @param {float} x A real number input\n\
|
|
6
|
+
* @returns {float} An approximation for tanh(x)\n\
|
|
7
|
+
*/\n\
|
|
8
|
+
float czm_approximateTanh(float x) {\n\
|
|
9
|
+
float x2 = x * x;\n\
|
|
10
|
+
return max(-1.0, min(1.0, x * (27.0 + x2) / (27.0 + 9.0 * x2)));\n\
|
|
11
|
+
}\n\
|
|
12
|
+
";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute the atmosphere color, applying Rayleigh and Mie scattering. This
|
|
3
|
+
* builtin uses automatic uniforms so the atmophere settings are synced with the
|
|
4
|
+
* state of the Scene, even in other contexts like Model.
|
|
5
|
+
*
|
|
6
|
+
* @name czm_computeAtmosphereColor
|
|
7
|
+
* @glslFunction
|
|
8
|
+
*
|
|
9
|
+
* @param {vec3} positionWC Position of the fragment in world coords (low precision)
|
|
10
|
+
* @param {vec3} lightDirection Light direction from the sun or other light source.
|
|
11
|
+
* @param {vec3} rayleighColor The Rayleigh scattering color computed by a scattering function
|
|
12
|
+
* @param {vec3} mieColor The Mie scattering color computed by a scattering function
|
|
13
|
+
* @param {float} opacity The opacity computed by a scattering function.
|
|
14
|
+
*/
|
|
15
|
+
vec4 czm_computeAtmosphereColor(
|
|
16
|
+
vec3 positionWC,
|
|
17
|
+
vec3 lightDirection,
|
|
18
|
+
vec3 rayleighColor,
|
|
19
|
+
vec3 mieColor,
|
|
20
|
+
float opacity
|
|
21
|
+
) {
|
|
22
|
+
// Setup the primary ray: from the camera position to the vertex position.
|
|
23
|
+
vec3 cameraToPositionWC = positionWC - czm_viewerPositionWC;
|
|
24
|
+
vec3 cameraToPositionWCDirection = normalize(cameraToPositionWC);
|
|
25
|
+
|
|
26
|
+
float cosAngle = dot(cameraToPositionWCDirection, lightDirection);
|
|
27
|
+
float cosAngleSq = cosAngle * cosAngle;
|
|
28
|
+
|
|
29
|
+
float G = czm_atmosphereMieAnisotropy;
|
|
30
|
+
float GSq = G * G;
|
|
31
|
+
|
|
32
|
+
// The Rayleigh phase function.
|
|
33
|
+
float rayleighPhase = 3.0 / (50.2654824574) * (1.0 + cosAngleSq);
|
|
34
|
+
// The Mie phase function.
|
|
35
|
+
float miePhase = 3.0 / (25.1327412287) * ((1.0 - GSq) * (cosAngleSq + 1.0)) / (pow(1.0 + GSq - 2.0 * cosAngle * G, 1.5) * (2.0 + GSq));
|
|
36
|
+
|
|
37
|
+
// The final color is generated by combining the effects of the Rayleigh and Mie scattering.
|
|
38
|
+
vec3 rayleigh = rayleighPhase * rayleighColor;
|
|
39
|
+
vec3 mie = miePhase * mieColor;
|
|
40
|
+
|
|
41
|
+
vec3 color = (rayleigh + mie) * czm_atmosphereLightIntensity;
|
|
42
|
+
|
|
43
|
+
return vec4(color, opacity);
|
|
44
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
+
export default "/**\n\
|
|
3
|
+
* Compute the atmosphere color, applying Rayleigh and Mie scattering. This\n\
|
|
4
|
+
* builtin uses automatic uniforms so the atmophere settings are synced with the\n\
|
|
5
|
+
* state of the Scene, even in other contexts like Model.\n\
|
|
6
|
+
*\n\
|
|
7
|
+
* @name czm_computeAtmosphereColor\n\
|
|
8
|
+
* @glslFunction\n\
|
|
9
|
+
*\n\
|
|
10
|
+
* @param {vec3} positionWC Position of the fragment in world coords (low precision)\n\
|
|
11
|
+
* @param {vec3} lightDirection Light direction from the sun or other light source.\n\
|
|
12
|
+
* @param {vec3} rayleighColor The Rayleigh scattering color computed by a scattering function\n\
|
|
13
|
+
* @param {vec3} mieColor The Mie scattering color computed by a scattering function\n\
|
|
14
|
+
* @param {float} opacity The opacity computed by a scattering function.\n\
|
|
15
|
+
*/\n\
|
|
16
|
+
vec4 czm_computeAtmosphereColor(\n\
|
|
17
|
+
vec3 positionWC,\n\
|
|
18
|
+
vec3 lightDirection,\n\
|
|
19
|
+
vec3 rayleighColor,\n\
|
|
20
|
+
vec3 mieColor,\n\
|
|
21
|
+
float opacity\n\
|
|
22
|
+
) {\n\
|
|
23
|
+
// Setup the primary ray: from the camera position to the vertex position.\n\
|
|
24
|
+
vec3 cameraToPositionWC = positionWC - czm_viewerPositionWC;\n\
|
|
25
|
+
vec3 cameraToPositionWCDirection = normalize(cameraToPositionWC);\n\
|
|
26
|
+
\n\
|
|
27
|
+
float cosAngle = dot(cameraToPositionWCDirection, lightDirection);\n\
|
|
28
|
+
float cosAngleSq = cosAngle * cosAngle;\n\
|
|
29
|
+
\n\
|
|
30
|
+
float G = czm_atmosphereMieAnisotropy;\n\
|
|
31
|
+
float GSq = G * G;\n\
|
|
32
|
+
\n\
|
|
33
|
+
// The Rayleigh phase function.\n\
|
|
34
|
+
float rayleighPhase = 3.0 / (50.2654824574) * (1.0 + cosAngleSq);\n\
|
|
35
|
+
// The Mie phase function.\n\
|
|
36
|
+
float miePhase = 3.0 / (25.1327412287) * ((1.0 - GSq) * (cosAngleSq + 1.0)) / (pow(1.0 + GSq - 2.0 * cosAngle * G, 1.5) * (2.0 + GSq));\n\
|
|
37
|
+
\n\
|
|
38
|
+
// The final color is generated by combining the effects of the Rayleigh and Mie scattering.\n\
|
|
39
|
+
vec3 rayleigh = rayleighPhase * rayleighColor;\n\
|
|
40
|
+
vec3 mie = miePhase * mieColor;\n\
|
|
41
|
+
\n\
|
|
42
|
+
vec3 color = (rayleigh + mie) * czm_atmosphereLightIntensity;\n\
|
|
43
|
+
\n\
|
|
44
|
+
return vec4(color, opacity);\n\
|
|
45
|
+
}\n\
|
|
46
|
+
";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute atmosphere scattering for the ground atmosphere and fog. This method
|
|
3
|
+
* uses automatic uniforms so it is always synced with the scene settings.
|
|
4
|
+
*
|
|
5
|
+
* @name czm_computeGroundAtmosphereScattering
|
|
6
|
+
* @glslfunction
|
|
7
|
+
*
|
|
8
|
+
* @param {vec3} positionWC The position of the fragment in world coordinates.
|
|
9
|
+
* @param {vec3} lightDirection The direction of the light to calculate the scattering from.
|
|
10
|
+
* @param {vec3} rayleighColor The variable the Rayleigh scattering will be written to.
|
|
11
|
+
* @param {vec3} mieColor The variable the Mie scattering will be written to.
|
|
12
|
+
* @param {float} opacity The variable the transmittance will be written to.
|
|
13
|
+
*/
|
|
14
|
+
void czm_computeGroundAtmosphereScattering(vec3 positionWC, vec3 lightDirection, out vec3 rayleighColor, out vec3 mieColor, out float opacity) {
|
|
15
|
+
vec3 cameraToPositionWC = positionWC - czm_viewerPositionWC;
|
|
16
|
+
vec3 cameraToPositionWCDirection = normalize(cameraToPositionWC);
|
|
17
|
+
czm_ray primaryRay = czm_ray(czm_viewerPositionWC, cameraToPositionWCDirection);
|
|
18
|
+
|
|
19
|
+
float atmosphereInnerRadius = length(positionWC);
|
|
20
|
+
|
|
21
|
+
czm_computeScattering(
|
|
22
|
+
primaryRay,
|
|
23
|
+
length(cameraToPositionWC),
|
|
24
|
+
lightDirection,
|
|
25
|
+
atmosphereInnerRadius,
|
|
26
|
+
rayleighColor,
|
|
27
|
+
mieColor,
|
|
28
|
+
opacity
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
+
export default "/**\n\
|
|
3
|
+
* Compute atmosphere scattering for the ground atmosphere and fog. This method\n\
|
|
4
|
+
* uses automatic uniforms so it is always synced with the scene settings.\n\
|
|
5
|
+
*\n\
|
|
6
|
+
* @name czm_computeGroundAtmosphereScattering\n\
|
|
7
|
+
* @glslfunction\n\
|
|
8
|
+
*\n\
|
|
9
|
+
* @param {vec3} positionWC The position of the fragment in world coordinates.\n\
|
|
10
|
+
* @param {vec3} lightDirection The direction of the light to calculate the scattering from.\n\
|
|
11
|
+
* @param {vec3} rayleighColor The variable the Rayleigh scattering will be written to.\n\
|
|
12
|
+
* @param {vec3} mieColor The variable the Mie scattering will be written to.\n\
|
|
13
|
+
* @param {float} opacity The variable the transmittance will be written to.\n\
|
|
14
|
+
*/\n\
|
|
15
|
+
void czm_computeGroundAtmosphereScattering(vec3 positionWC, vec3 lightDirection, out vec3 rayleighColor, out vec3 mieColor, out float opacity) {\n\
|
|
16
|
+
vec3 cameraToPositionWC = positionWC - czm_viewerPositionWC;\n\
|
|
17
|
+
vec3 cameraToPositionWCDirection = normalize(cameraToPositionWC);\n\
|
|
18
|
+
czm_ray primaryRay = czm_ray(czm_viewerPositionWC, cameraToPositionWCDirection);\n\
|
|
19
|
+
\n\
|
|
20
|
+
float atmosphereInnerRadius = length(positionWC);\n\
|
|
21
|
+
\n\
|
|
22
|
+
czm_computeScattering(\n\
|
|
23
|
+
primaryRay,\n\
|
|
24
|
+
length(cameraToPositionWC),\n\
|
|
25
|
+
lightDirection,\n\
|
|
26
|
+
atmosphereInnerRadius,\n\
|
|
27
|
+
rayleighColor,\n\
|
|
28
|
+
mieColor,\n\
|
|
29
|
+
opacity\n\
|
|
30
|
+
);\n\
|
|
31
|
+
}\n\
|
|
32
|
+
";
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function computes the colors contributed by Rayliegh and Mie scattering on a given ray, as well as
|
|
3
|
+
* the transmittance value for the ray. This function uses automatic uniforms
|
|
4
|
+
* so the atmosphere settings are always synced with the current scene.
|
|
5
|
+
*
|
|
6
|
+
* @name czm_computeScattering
|
|
7
|
+
* @glslfunction
|
|
8
|
+
*
|
|
9
|
+
* @param {czm_ray} primaryRay The ray from the camera to the position.
|
|
10
|
+
* @param {float} primaryRayLength The length of the primary ray.
|
|
11
|
+
* @param {vec3} lightDirection The direction of the light to calculate the scattering from.
|
|
12
|
+
* @param {vec3} rayleighColor The variable the Rayleigh scattering will be written to.
|
|
13
|
+
* @param {vec3} mieColor The variable the Mie scattering will be written to.
|
|
14
|
+
* @param {float} opacity The variable the transmittance will be written to.
|
|
15
|
+
*/
|
|
16
|
+
void czm_computeScattering(
|
|
17
|
+
czm_ray primaryRay,
|
|
18
|
+
float primaryRayLength,
|
|
19
|
+
vec3 lightDirection,
|
|
20
|
+
float atmosphereInnerRadius,
|
|
21
|
+
out vec3 rayleighColor,
|
|
22
|
+
out vec3 mieColor,
|
|
23
|
+
out float opacity
|
|
24
|
+
) {
|
|
25
|
+
const float ATMOSPHERE_THICKNESS = 111e3; // The thickness of the atmosphere in meters.
|
|
26
|
+
const int PRIMARY_STEPS_MAX = 16; // Maximum number of times the ray from the camera to the world position (primary ray) is sampled.
|
|
27
|
+
const int LIGHT_STEPS_MAX = 4; // Maximum number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.
|
|
28
|
+
|
|
29
|
+
// Initialize the default scattering amounts to 0.
|
|
30
|
+
rayleighColor = vec3(0.0);
|
|
31
|
+
mieColor = vec3(0.0);
|
|
32
|
+
opacity = 0.0;
|
|
33
|
+
|
|
34
|
+
float atmosphereOuterRadius = atmosphereInnerRadius + ATMOSPHERE_THICKNESS;
|
|
35
|
+
|
|
36
|
+
vec3 origin = vec3(0.0);
|
|
37
|
+
|
|
38
|
+
// Calculate intersection from the camera to the outer ring of the atmosphere.
|
|
39
|
+
czm_raySegment primaryRayAtmosphereIntersect = czm_raySphereIntersectionInterval(primaryRay, origin, atmosphereOuterRadius);
|
|
40
|
+
|
|
41
|
+
// Return empty colors if no intersection with the atmosphere geometry.
|
|
42
|
+
if (primaryRayAtmosphereIntersect == czm_emptyRaySegment) {
|
|
43
|
+
rayleighColor = vec3(1.0, 0.0, 1.0);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// To deal with smaller values of PRIMARY_STEPS (e.g. 4)
|
|
48
|
+
// we implement a split strategy: sky or horizon.
|
|
49
|
+
// For performance reasons, instead of a if/else branch
|
|
50
|
+
// a soft choice is implemented through a weight 0.0 <= w_stop_gt_lprl <= 1.0
|
|
51
|
+
float x = 1e-7 * primaryRayAtmosphereIntersect.stop / length(primaryRayLength);
|
|
52
|
+
// Value close to 0.0: close to the horizon
|
|
53
|
+
// Value close to 1.0: above in the sky
|
|
54
|
+
float w_stop_gt_lprl = 0.5 * (1.0 + czm_approximateTanh(x));
|
|
55
|
+
|
|
56
|
+
// The ray should start from the first intersection with the outer atmopshere, or from the camera position, if it is inside the atmosphere.
|
|
57
|
+
float start_0 = primaryRayAtmosphereIntersect.start;
|
|
58
|
+
primaryRayAtmosphereIntersect.start = max(primaryRayAtmosphereIntersect.start, 0.0);
|
|
59
|
+
// The ray should end at the exit from the atmosphere or at the distance to the vertex, whichever is smaller.
|
|
60
|
+
primaryRayAtmosphereIntersect.stop = min(primaryRayAtmosphereIntersect.stop, length(primaryRayLength));
|
|
61
|
+
|
|
62
|
+
// For the number of ray steps, distinguish inside or outside atmosphere (outer space)
|
|
63
|
+
// (1) from outer space we have to use more ray steps to get a realistic rendering
|
|
64
|
+
// (2) within atmosphere we need fewer steps for faster rendering
|
|
65
|
+
float x_o_a = start_0 - ATMOSPHERE_THICKNESS; // ATMOSPHERE_THICKNESS used as an ad-hoc constant, no precise meaning here, only the order of magnitude matters
|
|
66
|
+
float w_inside_atmosphere = 1.0 - 0.5 * (1.0 + czm_approximateTanh(x_o_a));
|
|
67
|
+
int PRIMARY_STEPS = PRIMARY_STEPS_MAX - int(w_inside_atmosphere * 12.0); // Number of times the ray from the camera to the world position (primary ray) is sampled.
|
|
68
|
+
int LIGHT_STEPS = LIGHT_STEPS_MAX - int(w_inside_atmosphere * 2.0); // Number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.
|
|
69
|
+
|
|
70
|
+
// Setup for sampling positions along the ray - starting from the intersection with the outer ring of the atmosphere.
|
|
71
|
+
float rayPositionLength = primaryRayAtmosphereIntersect.start;
|
|
72
|
+
// (1) Outside the atmosphere: constant rayStepLength
|
|
73
|
+
// (2) Inside atmosphere: variable rayStepLength to compensate the rough rendering of the smaller number of ray steps
|
|
74
|
+
float totalRayLength = primaryRayAtmosphereIntersect.stop - rayPositionLength;
|
|
75
|
+
float rayStepLengthIncrease = w_inside_atmosphere * ((1.0 - w_stop_gt_lprl) * totalRayLength / (float(PRIMARY_STEPS * (PRIMARY_STEPS + 1)) / 2.0));
|
|
76
|
+
float rayStepLength = max(1.0 - w_inside_atmosphere, w_stop_gt_lprl) * totalRayLength / max(7.0 * w_inside_atmosphere, float(PRIMARY_STEPS));
|
|
77
|
+
|
|
78
|
+
vec3 rayleighAccumulation = vec3(0.0);
|
|
79
|
+
vec3 mieAccumulation = vec3(0.0);
|
|
80
|
+
vec2 opticalDepth = vec2(0.0);
|
|
81
|
+
vec2 heightScale = vec2(czm_atmosphereRayleighScaleHeight, czm_atmosphereMieScaleHeight);
|
|
82
|
+
|
|
83
|
+
// Sample positions on the primary ray.
|
|
84
|
+
for (int i = 0; i < PRIMARY_STEPS_MAX; ++i) {
|
|
85
|
+
|
|
86
|
+
// The loop should be: for (int i = 0; i < PRIMARY_STEPS; ++i) {...} but WebGL1 cannot
|
|
87
|
+
// loop with non-constant condition, so it has to break early instead
|
|
88
|
+
if (i >= PRIMARY_STEPS) {
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Calculate sample position along viewpoint ray.
|
|
93
|
+
vec3 samplePosition = primaryRay.origin + primaryRay.direction * (rayPositionLength + rayStepLength);
|
|
94
|
+
|
|
95
|
+
// Calculate height of sample position above ellipsoid.
|
|
96
|
+
float sampleHeight = length(samplePosition) - atmosphereInnerRadius;
|
|
97
|
+
|
|
98
|
+
// Calculate and accumulate density of particles at the sample position.
|
|
99
|
+
vec2 sampleDensity = exp(-sampleHeight / heightScale) * rayStepLength;
|
|
100
|
+
opticalDepth += sampleDensity;
|
|
101
|
+
|
|
102
|
+
// Generate ray from the sample position segment to the light source, up to the outer ring of the atmosphere.
|
|
103
|
+
czm_ray lightRay = czm_ray(samplePosition, lightDirection);
|
|
104
|
+
czm_raySegment lightRayAtmosphereIntersect = czm_raySphereIntersectionInterval(lightRay, origin, atmosphereOuterRadius);
|
|
105
|
+
|
|
106
|
+
float lightStepLength = lightRayAtmosphereIntersect.stop / float(LIGHT_STEPS);
|
|
107
|
+
float lightPositionLength = 0.0;
|
|
108
|
+
|
|
109
|
+
vec2 lightOpticalDepth = vec2(0.0);
|
|
110
|
+
|
|
111
|
+
// Sample positions along the light ray, to accumulate incidence of light on the latest sample segment.
|
|
112
|
+
for (int j = 0; j < LIGHT_STEPS_MAX; ++j) {
|
|
113
|
+
|
|
114
|
+
// The loop should be: for (int j = 0; i < LIGHT_STEPS; ++j) {...} but WebGL1 cannot
|
|
115
|
+
// loop with non-constant condition, so it has to break early instead
|
|
116
|
+
if (j >= LIGHT_STEPS) {
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Calculate sample position along light ray.
|
|
121
|
+
vec3 lightPosition = samplePosition + lightDirection * (lightPositionLength + lightStepLength * 0.5);
|
|
122
|
+
|
|
123
|
+
// Calculate height of the light sample position above ellipsoid.
|
|
124
|
+
float lightHeight = length(lightPosition) - atmosphereInnerRadius;
|
|
125
|
+
|
|
126
|
+
// Calculate density of photons at the light sample position.
|
|
127
|
+
lightOpticalDepth += exp(-lightHeight / heightScale) * lightStepLength;
|
|
128
|
+
|
|
129
|
+
// Increment distance on light ray.
|
|
130
|
+
lightPositionLength += lightStepLength;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Compute attenuation via the primary ray and the light ray.
|
|
134
|
+
vec3 attenuation = exp(-((czm_atmosphereMieCoefficient * (opticalDepth.y + lightOpticalDepth.y)) + (czm_atmosphereRayleighCoefficient * (opticalDepth.x + lightOpticalDepth.x))));
|
|
135
|
+
|
|
136
|
+
// Accumulate the scattering.
|
|
137
|
+
rayleighAccumulation += sampleDensity.x * attenuation;
|
|
138
|
+
mieAccumulation += sampleDensity.y * attenuation;
|
|
139
|
+
|
|
140
|
+
// Increment distance on primary ray.
|
|
141
|
+
rayPositionLength += (rayStepLength += rayStepLengthIncrease);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Compute the scattering amount.
|
|
145
|
+
rayleighColor = czm_atmosphereRayleighCoefficient * rayleighAccumulation;
|
|
146
|
+
mieColor = czm_atmosphereMieCoefficient * mieAccumulation;
|
|
147
|
+
|
|
148
|
+
// Compute the transmittance i.e. how much light is passing through the atmosphere.
|
|
149
|
+
opacity = length(exp(-((czm_atmosphereMieCoefficient * opticalDepth.y) + (czm_atmosphereRayleighCoefficient * opticalDepth.x))));
|
|
150
|
+
}
|