@cesium/engine 6.2.0 → 8.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-RH4N2ONY.js → chunk-23UFSGND.js} +7 -7
- package/Build/Workers/{chunk-HPP4JLNH.js → chunk-2A75IWRS.js} +7 -7
- package/Build/Workers/{chunk-5IRLXUTA.js → chunk-2FRVPMCS.js} +10 -10
- package/Build/Workers/{chunk-ZQRZBHYI.js → chunk-2FWRMUTY.js} +4 -4
- package/Build/Workers/{chunk-Z2SIPUKB.js → chunk-2UPKWTMJ.js} +6 -6
- package/Build/Workers/{chunk-434ZTTFX.js → chunk-34FXV7D7.js} +2 -2
- package/Build/Workers/{chunk-MW3CJYLX.js → chunk-3VAZEH7M.js} +2 -2
- package/Build/Workers/{chunk-HUPNRBWW.js → chunk-4DO5W5XZ.js} +6 -6
- package/Build/Workers/{chunk-PIXK6KHB.js → chunk-4H7PY4U5.js} +2 -2
- package/Build/Workers/{chunk-BP467WX3.js → chunk-5QULIR53.js} +4 -4
- package/Build/Workers/{chunk-R3HUGXBH.js → chunk-7TC63SJW.js} +8 -8
- package/Build/Workers/{chunk-SQVTYRZY.js → chunk-7ZFGPDJA.js} +4 -4
- package/Build/Workers/{chunk-TIXXVKUY.js → chunk-A5DWLWCY.js} +10 -10
- package/Build/Workers/{chunk-CWJQGBWT.js → chunk-BBWDMCVU.js} +1 -1
- package/Build/Workers/{chunk-4KP73B43.js → chunk-BG4UCVXN.js} +3 -3
- package/Build/Workers/{chunk-Y4OJ4B23.js → chunk-BIKA3NRA.js} +5 -5
- package/Build/Workers/{chunk-DR5XZ6K5.js → chunk-BROJAZRZ.js} +13 -13
- package/Build/Workers/{chunk-FWGNCYP6.js → chunk-DDUQAJ4P.js} +7 -7
- package/Build/Workers/{chunk-QRBRVGZC.js → chunk-EERJKOAF.js} +4 -4
- package/Build/Workers/{chunk-52VSIKEA.js → chunk-EG6PTBY2.js} +15 -15
- package/Build/Workers/{chunk-O43GWBSF.js → chunk-EHWHNOEX.js} +1 -1
- package/Build/Workers/{chunk-MN34FIF5.js → chunk-F3YA3Y2Z.js} +1 -1
- package/Build/Workers/{chunk-GF5TNNKP.js → chunk-F4HFJMGM.js} +6 -6
- package/Build/Workers/{chunk-HOT2SNXP.js → chunk-FJKNFAKQ.js} +133 -553
- package/Build/Workers/{chunk-TMPVBFJQ.js → chunk-FNIRWHJB.js} +10 -10
- package/Build/Workers/{chunk-DMCSY5BU.js → chunk-FZRIVR7Y.js} +5 -5
- package/Build/Workers/{chunk-Z4JUBRHP.js → chunk-G43QFN4Q.js} +6 -6
- package/Build/Workers/{chunk-HPH5HSFE.js → chunk-GATZHF3K.js} +2 -2
- package/Build/Workers/{chunk-CSIZ3BGT.js → chunk-GRC2ZTAF.js} +14 -14
- package/Build/Workers/{chunk-NE4JNU6H.js → chunk-HU6N6EXB.js} +10 -10
- package/Build/Workers/{chunk-GVL5I7TC.js → chunk-I46ZRR5W.js} +17 -17
- package/Build/Workers/{chunk-5GDBZTHX.js → chunk-JURN7NPV.js} +17 -17
- package/Build/Workers/{chunk-H5DUXHCV.js → chunk-KKCR2YOP.js} +11 -11
- package/Build/Workers/{chunk-LX6XV4DK.js → chunk-LPR3YNP2.js} +5 -5
- package/Build/Workers/{chunk-HFKSAB5K.js → chunk-M7ERACJJ.js} +13 -13
- package/Build/Workers/{chunk-BUZDZBUH.js → chunk-MDWEGWPA.js} +10 -10
- package/Build/Workers/{chunk-LGJUI2CE.js → chunk-OGXZVPPM.js} +9 -5
- package/Build/Workers/{chunk-PZ2WJWUG.js → chunk-PGSJK77E.js} +6 -6
- package/Build/Workers/{chunk-ARPTYYKS.js → chunk-PPH7OFP3.js} +5 -5
- package/Build/Workers/{chunk-R4OZKBXH.js → chunk-SH5USDPI.js} +6 -6
- package/Build/Workers/{chunk-SV7DDPAC.js → chunk-SOWMRMWA.js} +1 -1
- package/Build/Workers/{chunk-RIDPF7PO.js → chunk-STW2DGFI.js} +2 -2
- package/Build/Workers/{chunk-CDGHUKQ4.js → chunk-T3XIFPYR.js} +13 -13
- package/Build/Workers/chunk-TTUZP4BO.js +501 -0
- package/Build/Workers/{chunk-QTZQZY2C.js → chunk-UEXTBDBE.js} +34 -10
- package/Build/Workers/{chunk-XUTVA4K5.js → chunk-VOXYEYJT.js} +11 -11
- package/Build/Workers/{chunk-AXFRNOVC.js → chunk-X4356LRH.js} +12 -12
- package/Build/Workers/{chunk-5HLGKKG3.js → chunk-XGI5BXZY.js} +2 -2
- package/Build/Workers/{chunk-SNN7WOC2.js → chunk-Y2ME2IJV.js} +13 -13
- package/Build/Workers/{chunk-LGL4P5KL.js → chunk-Y5UQJLYE.js} +6 -6
- package/Build/Workers/{chunk-3PW6ZBN4.js → chunk-YJEBABKH.js} +7 -7
- package/Build/Workers/{chunk-YBKFS53K.js → chunk-YWTJ2B4B.js} +1 -1
- package/Build/Workers/{chunk-5SK36PU4.js → chunk-Z3TIFFGF.js} +7 -7
- package/Build/Workers/{chunk-JGG36SQV.js → chunk-ZT7KWISZ.js} +4 -4
- package/Build/Workers/combineGeometry.js +24 -23
- package/Build/Workers/createBoxGeometry.js +18 -17
- package/Build/Workers/createBoxOutlineGeometry.js +16 -15
- package/Build/Workers/createCircleGeometry.js +26 -25
- package/Build/Workers/createCircleOutlineGeometry.js +19 -18
- package/Build/Workers/createCoplanarPolygonGeometry.js +33 -32
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -30
- package/Build/Workers/createCorridorGeometry.js +29 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
- package/Build/Workers/createCylinderGeometry.js +20 -19
- package/Build/Workers/createCylinderOutlineGeometry.js +18 -17
- package/Build/Workers/createEllipseGeometry.js +26 -25
- package/Build/Workers/createEllipseOutlineGeometry.js +19 -18
- package/Build/Workers/createEllipsoidGeometry.js +19 -18
- package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -17
- package/Build/Workers/createFrustumGeometry.js +18 -17
- package/Build/Workers/createFrustumOutlineGeometry.js +18 -17
- package/Build/Workers/createGeometry.js +54 -33
- package/Build/Workers/createGroundPolylineGeometry.js +22 -21
- package/Build/Workers/createPlaneGeometry.js +16 -15
- package/Build/Workers/createPlaneOutlineGeometry.js +15 -14
- package/Build/Workers/createPolygonGeometry.js +32 -166
- package/Build/Workers/createPolygonOutlineGeometry.js +30 -29
- package/Build/Workers/createPolylineGeometry.js +25 -24
- package/Build/Workers/createPolylineVolumeGeometry.js +32 -33
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
- package/Build/Workers/createRectangleGeometry.js +27 -26
- package/Build/Workers/createRectangleOutlineGeometry.js +20 -19
- package/Build/Workers/createSimplePolylineGeometry.js +23 -22
- package/Build/Workers/createSphereGeometry.js +19 -18
- package/Build/Workers/createSphereOutlineGeometry.js +18 -17
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
- package/Build/Workers/createVectorTileGeometries.js +24 -23
- package/Build/Workers/createVectorTilePoints.js +12 -12
- package/Build/Workers/createVectorTilePolygons.js +22 -21
- package/Build/Workers/createVectorTilePolylines.js +14 -14
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -21
- package/Build/Workers/createVerticesFromHeightmap.js +22 -21
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +19 -18
- package/Build/Workers/createWallGeometry.js +24 -23
- package/Build/Workers/createWallOutlineGeometry.js +23 -22
- package/Build/Workers/decodeDraco.js +11 -11
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +601 -92
- package/Build/Workers/transcodeKTX2.js +7 -7
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -21
- package/LICENSE.md +1 -1
- package/Source/Assets/approximateTerrainHeights.json +1 -1
- package/Source/Core/Ellipsoid.js +6 -0
- package/Source/Core/GregorianDate.js +85 -0
- package/Source/Core/HeadingPitchRange.js +2 -2
- package/Source/Core/IntersectionTests.js +6 -3
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/PixelFormat.js +5 -0
- package/Source/Core/PolygonGeometry.js +0 -169
- package/Source/Core/Resource.js +30 -69
- package/Source/Core/Transforms.js +30 -18
- package/Source/Core/createWorldBathymetryAsync.js +45 -0
- package/Source/Core/srgbToLinear.js +32 -0
- package/Source/DataSources/CzmlDataSource.js +51 -23
- package/Source/DataSources/DataSourceDisplay.js +27 -0
- package/Source/DataSources/EllipsoidGeometryUpdater.js +3 -4
- package/Source/DataSources/Entity.js +28 -7
- package/Source/DataSources/EntityCollection.js +1 -2
- package/Source/DataSources/GeometryUpdater.js +1 -2
- package/Source/DataSources/GeometryUpdaterSet.js +114 -0
- package/Source/DataSources/GeometryVisualizer.js +19 -83
- 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 +121 -1
- package/Source/Renderer/Context.js +10 -0
- package/Source/Renderer/ContextLimits.js +2 -0
- package/Source/Renderer/UniformState.js +127 -0
- package/Source/Renderer/demodernizeShader.js +4 -1
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Atmosphere.js +127 -0
- package/Source/Scene/Axis.js +12 -7
- package/Source/Scene/Billboard.js +29 -26
- package/Source/Scene/BillboardCollection.js +3 -3
- package/Source/Scene/Camera.js +47 -5
- package/Source/Scene/Cesium3DTile.js +1 -0
- package/Source/Scene/Cesium3DTileContent.js +14 -0
- package/Source/Scene/Cesium3DTileset.js +364 -45
- package/Source/Scene/Cesium3DTilesetBaseTraversal.js +2 -4
- 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 +14 -1
- package/Source/Scene/Geometry3DTileContent.js +4 -0
- package/Source/Scene/Globe.js +3 -2
- package/Source/Scene/GlobeSurfaceTileProvider.js +3 -1
- package/Source/Scene/GlobeTranslucencyState.js +1 -1
- package/Source/Scene/GltfLoader.js +15 -5
- package/Source/Scene/GltfPipeline/updateVersion.js +69 -68
- package/Source/Scene/HeightReference.js +59 -2
- package/Source/Scene/I3SDataProvider.js +270 -53
- package/Source/Scene/I3SDecoder.js +8 -1
- package/Source/Scene/I3SFeature.js +2 -5
- package/Source/Scene/I3SField.js +136 -31
- package/Source/Scene/I3SGeometry.js +70 -2
- package/Source/Scene/I3SLayer.js +55 -10
- package/Source/Scene/I3SNode.js +175 -18
- package/Source/Scene/I3SStatistics.js +94 -0
- package/Source/Scene/I3SSublayer.js +176 -0
- package/Source/Scene/I3SSymbology.js +337 -0
- package/Source/Scene/Implicit3DTileContent.js +4 -0
- package/Source/Scene/KeyframeNode.js +1 -1
- package/Source/Scene/LabelCollection.js +2 -2
- 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 +82 -32
- package/Source/Scene/Model/Model3DTileContent.js +31 -0
- package/Source/Scene/Model/ModelAnimationChannel.js +16 -15
- package/Source/Scene/Model/ModelSceneGraph.js +6 -0
- package/Source/Scene/Model/pickModel.js +426 -0
- package/Source/Scene/Multiple3DTileContent.js +42 -0
- package/Source/Scene/PickFramebuffer.js +37 -2
- package/Source/Scene/Picking.js +113 -39
- package/Source/Scene/Primitive.js +6 -2
- package/Source/Scene/QuadtreePrimitive.js +1 -1
- package/Source/Scene/Scene.js +312 -46
- package/Source/Scene/ScreenSpaceCameraController.js +23 -13
- package/Source/Scene/SensorVolumePortionToDisplay.js +69 -0
- package/Source/Scene/SkyAtmosphere.js +5 -6
- package/Source/Scene/SpatialNode.js +12 -19
- package/Source/Scene/StructuralMetadata.js +1 -1
- package/Source/Scene/Terrain.js +49 -0
- package/Source/Scene/TileBoundingS2Cell.js +2 -2
- package/Source/Scene/Tileset3DTileContent.js +4 -0
- package/Source/Scene/Vector3DTileContent.js +4 -0
- package/Source/Scene/VoxelBoxShape.js +76 -0
- package/Source/Scene/VoxelCell.js +273 -0
- package/Source/Scene/VoxelCylinderShape.js +114 -43
- package/Source/Scene/VoxelEllipsoidShape.js +158 -116
- package/Source/Scene/VoxelPrimitive.js +3 -1
- package/Source/Scene/VoxelRenderResources.js +3 -0
- package/Source/Scene/VoxelShape.js +13 -0
- package/Source/Scene/VoxelTraversal.js +76 -54
- package/Source/Scene/buildVoxelDrawCommands.js +23 -0
- package/Source/Scene/createGooglePhotorealistic3DTileset.js +1 -0
- package/Source/Scene/processVoxelProperties.js +2 -0
- 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 +1 -1
- package/Source/Shaders/GlobeVS.js +1 -1
- 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 +9 -4
- package/Source/Shaders/Model/ModelVS.js +9 -4
- 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/Shaders/Voxels/IntersectCylinder.glsl +14 -111
- package/Source/Shaders/Voxels/IntersectCylinder.js +14 -111
- package/Source/Shaders/Voxels/IntersectEllipsoid.glsl +32 -113
- package/Source/Shaders/Voxels/IntersectEllipsoid.js +32 -113
- package/Source/Shaders/Voxels/IntersectLongitude.glsl +102 -0
- package/Source/Shaders/Voxels/IntersectLongitude.js +104 -0
- package/Source/Shaders/Voxels/VoxelFS.glsl +39 -1
- package/Source/Shaders/Voxels/VoxelFS.js +39 -1
- package/Source/Shaders/Voxels/convertUvToCylinder.glsl +19 -37
- package/Source/Shaders/Voxels/convertUvToCylinder.js +19 -37
- package/Source/Shaders/Voxels/convertUvToEllipsoid.glsl +24 -44
- package/Source/Shaders/Voxels/convertUvToEllipsoid.js +24 -44
- package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
- package/Source/ThirdParty/draco_decoder.wasm +0 -0
- package/Source/Workers/createGeometry.js +40 -11
- package/Source/Workers/decodeI3S.js +720 -94
- package/index.d.ts +574 -71
- package/index.js +217 -196
- package/package.json +3 -3
- package/Build/Workers/chunk-ATB2I7OS.js +0 -55
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
+
export default "/**\n\
|
|
3
|
+
* This function computes the colors contributed by Rayliegh and Mie scattering on a given ray, as well as\n\
|
|
4
|
+
* the transmittance value for the ray. This function uses automatic uniforms\n\
|
|
5
|
+
* so the atmosphere settings are always synced with the current scene.\n\
|
|
6
|
+
*\n\
|
|
7
|
+
* @name czm_computeScattering\n\
|
|
8
|
+
* @glslfunction\n\
|
|
9
|
+
*\n\
|
|
10
|
+
* @param {czm_ray} primaryRay The ray from the camera to the position.\n\
|
|
11
|
+
* @param {float} primaryRayLength The length of the primary ray.\n\
|
|
12
|
+
* @param {vec3} lightDirection The direction of the light to calculate the scattering from.\n\
|
|
13
|
+
* @param {vec3} rayleighColor The variable the Rayleigh scattering will be written to.\n\
|
|
14
|
+
* @param {vec3} mieColor The variable the Mie scattering will be written to.\n\
|
|
15
|
+
* @param {float} opacity The variable the transmittance will be written to.\n\
|
|
16
|
+
*/\n\
|
|
17
|
+
void czm_computeScattering(\n\
|
|
18
|
+
czm_ray primaryRay,\n\
|
|
19
|
+
float primaryRayLength,\n\
|
|
20
|
+
vec3 lightDirection,\n\
|
|
21
|
+
float atmosphereInnerRadius,\n\
|
|
22
|
+
out vec3 rayleighColor,\n\
|
|
23
|
+
out vec3 mieColor,\n\
|
|
24
|
+
out float opacity\n\
|
|
25
|
+
) {\n\
|
|
26
|
+
const float ATMOSPHERE_THICKNESS = 111e3; // The thickness of the atmosphere in meters.\n\
|
|
27
|
+
const int PRIMARY_STEPS_MAX = 16; // Maximum number of times the ray from the camera to the world position (primary ray) is sampled.\n\
|
|
28
|
+
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\
|
|
29
|
+
\n\
|
|
30
|
+
// Initialize the default scattering amounts to 0.\n\
|
|
31
|
+
rayleighColor = vec3(0.0);\n\
|
|
32
|
+
mieColor = vec3(0.0);\n\
|
|
33
|
+
opacity = 0.0;\n\
|
|
34
|
+
\n\
|
|
35
|
+
float atmosphereOuterRadius = atmosphereInnerRadius + ATMOSPHERE_THICKNESS;\n\
|
|
36
|
+
\n\
|
|
37
|
+
vec3 origin = vec3(0.0);\n\
|
|
38
|
+
\n\
|
|
39
|
+
// Calculate intersection from the camera to the outer ring of the atmosphere.\n\
|
|
40
|
+
czm_raySegment primaryRayAtmosphereIntersect = czm_raySphereIntersectionInterval(primaryRay, origin, atmosphereOuterRadius);\n\
|
|
41
|
+
\n\
|
|
42
|
+
// Return empty colors if no intersection with the atmosphere geometry.\n\
|
|
43
|
+
if (primaryRayAtmosphereIntersect == czm_emptyRaySegment) {\n\
|
|
44
|
+
rayleighColor = vec3(1.0, 0.0, 1.0);\n\
|
|
45
|
+
return;\n\
|
|
46
|
+
}\n\
|
|
47
|
+
\n\
|
|
48
|
+
// To deal with smaller values of PRIMARY_STEPS (e.g. 4)\n\
|
|
49
|
+
// we implement a split strategy: sky or horizon.\n\
|
|
50
|
+
// For performance reasons, instead of a if/else branch\n\
|
|
51
|
+
// a soft choice is implemented through a weight 0.0 <= w_stop_gt_lprl <= 1.0\n\
|
|
52
|
+
float x = 1e-7 * primaryRayAtmosphereIntersect.stop / length(primaryRayLength);\n\
|
|
53
|
+
// Value close to 0.0: close to the horizon\n\
|
|
54
|
+
// Value close to 1.0: above in the sky\n\
|
|
55
|
+
float w_stop_gt_lprl = 0.5 * (1.0 + czm_approximateTanh(x));\n\
|
|
56
|
+
\n\
|
|
57
|
+
// The ray should start from the first intersection with the outer atmopshere, or from the camera position, if it is inside the atmosphere.\n\
|
|
58
|
+
float start_0 = primaryRayAtmosphereIntersect.start;\n\
|
|
59
|
+
primaryRayAtmosphereIntersect.start = max(primaryRayAtmosphereIntersect.start, 0.0);\n\
|
|
60
|
+
// The ray should end at the exit from the atmosphere or at the distance to the vertex, whichever is smaller.\n\
|
|
61
|
+
primaryRayAtmosphereIntersect.stop = min(primaryRayAtmosphereIntersect.stop, length(primaryRayLength));\n\
|
|
62
|
+
\n\
|
|
63
|
+
// For the number of ray steps, distinguish inside or outside atmosphere (outer space)\n\
|
|
64
|
+
// (1) from outer space we have to use more ray steps to get a realistic rendering\n\
|
|
65
|
+
// (2) within atmosphere we need fewer steps for faster rendering\n\
|
|
66
|
+
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\
|
|
67
|
+
float w_inside_atmosphere = 1.0 - 0.5 * (1.0 + czm_approximateTanh(x_o_a));\n\
|
|
68
|
+
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\
|
|
69
|
+
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\
|
|
70
|
+
\n\
|
|
71
|
+
// Setup for sampling positions along the ray - starting from the intersection with the outer ring of the atmosphere.\n\
|
|
72
|
+
float rayPositionLength = primaryRayAtmosphereIntersect.start;\n\
|
|
73
|
+
// (1) Outside the atmosphere: constant rayStepLength\n\
|
|
74
|
+
// (2) Inside atmosphere: variable rayStepLength to compensate the rough rendering of the smaller number of ray steps\n\
|
|
75
|
+
float totalRayLength = primaryRayAtmosphereIntersect.stop - rayPositionLength;\n\
|
|
76
|
+
float rayStepLengthIncrease = w_inside_atmosphere * ((1.0 - w_stop_gt_lprl) * totalRayLength / (float(PRIMARY_STEPS * (PRIMARY_STEPS + 1)) / 2.0));\n\
|
|
77
|
+
float rayStepLength = max(1.0 - w_inside_atmosphere, w_stop_gt_lprl) * totalRayLength / max(7.0 * w_inside_atmosphere, float(PRIMARY_STEPS));\n\
|
|
78
|
+
\n\
|
|
79
|
+
vec3 rayleighAccumulation = vec3(0.0);\n\
|
|
80
|
+
vec3 mieAccumulation = vec3(0.0);\n\
|
|
81
|
+
vec2 opticalDepth = vec2(0.0);\n\
|
|
82
|
+
vec2 heightScale = vec2(czm_atmosphereRayleighScaleHeight, czm_atmosphereMieScaleHeight);\n\
|
|
83
|
+
\n\
|
|
84
|
+
// Sample positions on the primary ray.\n\
|
|
85
|
+
for (int i = 0; i < PRIMARY_STEPS_MAX; ++i) {\n\
|
|
86
|
+
\n\
|
|
87
|
+
// The loop should be: for (int i = 0; i < PRIMARY_STEPS; ++i) {...} but WebGL1 cannot\n\
|
|
88
|
+
// loop with non-constant condition, so it has to break early instead\n\
|
|
89
|
+
if (i >= PRIMARY_STEPS) {\n\
|
|
90
|
+
break;\n\
|
|
91
|
+
}\n\
|
|
92
|
+
\n\
|
|
93
|
+
// Calculate sample position along viewpoint ray.\n\
|
|
94
|
+
vec3 samplePosition = primaryRay.origin + primaryRay.direction * (rayPositionLength + rayStepLength);\n\
|
|
95
|
+
\n\
|
|
96
|
+
// Calculate height of sample position above ellipsoid.\n\
|
|
97
|
+
float sampleHeight = length(samplePosition) - atmosphereInnerRadius;\n\
|
|
98
|
+
\n\
|
|
99
|
+
// Calculate and accumulate density of particles at the sample position.\n\
|
|
100
|
+
vec2 sampleDensity = exp(-sampleHeight / heightScale) * rayStepLength;\n\
|
|
101
|
+
opticalDepth += sampleDensity;\n\
|
|
102
|
+
\n\
|
|
103
|
+
// Generate ray from the sample position segment to the light source, up to the outer ring of the atmosphere.\n\
|
|
104
|
+
czm_ray lightRay = czm_ray(samplePosition, lightDirection);\n\
|
|
105
|
+
czm_raySegment lightRayAtmosphereIntersect = czm_raySphereIntersectionInterval(lightRay, origin, atmosphereOuterRadius);\n\
|
|
106
|
+
\n\
|
|
107
|
+
float lightStepLength = lightRayAtmosphereIntersect.stop / float(LIGHT_STEPS);\n\
|
|
108
|
+
float lightPositionLength = 0.0;\n\
|
|
109
|
+
\n\
|
|
110
|
+
vec2 lightOpticalDepth = vec2(0.0);\n\
|
|
111
|
+
\n\
|
|
112
|
+
// Sample positions along the light ray, to accumulate incidence of light on the latest sample segment.\n\
|
|
113
|
+
for (int j = 0; j < LIGHT_STEPS_MAX; ++j) {\n\
|
|
114
|
+
\n\
|
|
115
|
+
// The loop should be: for (int j = 0; i < LIGHT_STEPS; ++j) {...} but WebGL1 cannot\n\
|
|
116
|
+
// loop with non-constant condition, so it has to break early instead\n\
|
|
117
|
+
if (j >= LIGHT_STEPS) {\n\
|
|
118
|
+
break;\n\
|
|
119
|
+
}\n\
|
|
120
|
+
\n\
|
|
121
|
+
// Calculate sample position along light ray.\n\
|
|
122
|
+
vec3 lightPosition = samplePosition + lightDirection * (lightPositionLength + lightStepLength * 0.5);\n\
|
|
123
|
+
\n\
|
|
124
|
+
// Calculate height of the light sample position above ellipsoid.\n\
|
|
125
|
+
float lightHeight = length(lightPosition) - atmosphereInnerRadius;\n\
|
|
126
|
+
\n\
|
|
127
|
+
// Calculate density of photons at the light sample position.\n\
|
|
128
|
+
lightOpticalDepth += exp(-lightHeight / heightScale) * lightStepLength;\n\
|
|
129
|
+
\n\
|
|
130
|
+
// Increment distance on light ray.\n\
|
|
131
|
+
lightPositionLength += lightStepLength;\n\
|
|
132
|
+
}\n\
|
|
133
|
+
\n\
|
|
134
|
+
// Compute attenuation via the primary ray and the light ray.\n\
|
|
135
|
+
vec3 attenuation = exp(-((czm_atmosphereMieCoefficient * (opticalDepth.y + lightOpticalDepth.y)) + (czm_atmosphereRayleighCoefficient * (opticalDepth.x + lightOpticalDepth.x))));\n\
|
|
136
|
+
\n\
|
|
137
|
+
// Accumulate the scattering.\n\
|
|
138
|
+
rayleighAccumulation += sampleDensity.x * attenuation;\n\
|
|
139
|
+
mieAccumulation += sampleDensity.y * attenuation;\n\
|
|
140
|
+
\n\
|
|
141
|
+
// Increment distance on primary ray.\n\
|
|
142
|
+
rayPositionLength += (rayStepLength += rayStepLengthIncrease);\n\
|
|
143
|
+
}\n\
|
|
144
|
+
\n\
|
|
145
|
+
// Compute the scattering amount.\n\
|
|
146
|
+
rayleighColor = czm_atmosphereRayleighCoefficient * rayleighAccumulation;\n\
|
|
147
|
+
mieColor = czm_atmosphereMieCoefficient * mieAccumulation;\n\
|
|
148
|
+
\n\
|
|
149
|
+
// Compute the transmittance i.e. how much light is passing through the atmosphere.\n\
|
|
150
|
+
opacity = length(exp(-((czm_atmosphereMieCoefficient * opticalDepth.y) + (czm_atmosphereRayleighCoefficient * opticalDepth.x))));\n\
|
|
151
|
+
}\n\
|
|
152
|
+
";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Select which direction vector to use for dynamic atmosphere lighting based on an enum value
|
|
3
|
+
*
|
|
4
|
+
* @name czm_getDynamicAtmosphereLightDirection
|
|
5
|
+
* @glslfunction
|
|
6
|
+
* @see DynamicAtmosphereLightingType.js
|
|
7
|
+
*
|
|
8
|
+
* @param {vec3} positionWC the position of the vertex/fragment in world coordinates. This is normalized and returned when dynamic lighting is turned off.
|
|
9
|
+
* @param {float} lightEnum The enum value for selecting between light sources.
|
|
10
|
+
* @return {vec3} The normalized light direction vector. Depending on the enum value, it is either positionWC, czm_lightDirectionWC or czm_sunDirectionWC
|
|
11
|
+
*/
|
|
12
|
+
vec3 czm_getDynamicAtmosphereLightDirection(vec3 positionWC, float lightEnum) {
|
|
13
|
+
const float NONE = 0.0;
|
|
14
|
+
const float SCENE_LIGHT = 1.0;
|
|
15
|
+
const float SUNLIGHT = 2.0;
|
|
16
|
+
|
|
17
|
+
vec3 lightDirection =
|
|
18
|
+
positionWC * float(lightEnum == NONE) +
|
|
19
|
+
czm_lightDirectionWC * float(lightEnum == SCENE_LIGHT) +
|
|
20
|
+
czm_sunDirectionWC * float(lightEnum == SUNLIGHT);
|
|
21
|
+
return normalize(lightDirection);
|
|
22
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
+
export default "/**\n\
|
|
3
|
+
* Select which direction vector to use for dynamic atmosphere lighting based on an enum value\n\
|
|
4
|
+
*\n\
|
|
5
|
+
* @name czm_getDynamicAtmosphereLightDirection\n\
|
|
6
|
+
* @glslfunction\n\
|
|
7
|
+
* @see DynamicAtmosphereLightingType.js\n\
|
|
8
|
+
*\n\
|
|
9
|
+
* @param {vec3} positionWC the position of the vertex/fragment in world coordinates. This is normalized and returned when dynamic lighting is turned off.\n\
|
|
10
|
+
* @param {float} lightEnum The enum value for selecting between light sources.\n\
|
|
11
|
+
* @return {vec3} The normalized light direction vector. Depending on the enum value, it is either positionWC, czm_lightDirectionWC or czm_sunDirectionWC\n\
|
|
12
|
+
*/\n\
|
|
13
|
+
vec3 czm_getDynamicAtmosphereLightDirection(vec3 positionWC, float lightEnum) {\n\
|
|
14
|
+
const float NONE = 0.0;\n\
|
|
15
|
+
const float SCENE_LIGHT = 1.0;\n\
|
|
16
|
+
const float SUNLIGHT = 2.0;\n\
|
|
17
|
+
\n\
|
|
18
|
+
vec3 lightDirection =\n\
|
|
19
|
+
positionWC * float(lightEnum == NONE) +\n\
|
|
20
|
+
czm_lightDirectionWC * float(lightEnum == SCENE_LIGHT) +\n\
|
|
21
|
+
czm_sunDirectionWC * float(lightEnum == SUNLIGHT);\n\
|
|
22
|
+
return normalize(lightDirection);\n\
|
|
23
|
+
}\n\
|
|
24
|
+
";
|
|
@@ -34,6 +34,11 @@
|
|
|
34
34
|
vec4 czm_translateRelativeToEye(vec3 high, vec3 low)
|
|
35
35
|
{
|
|
36
36
|
vec3 highDifference = high - czm_encodedCameraPositionMCHigh;
|
|
37
|
+
// This check handles the case when NaN values have gotten into `highDifference`.
|
|
38
|
+
// Such a thing could happen on devices running iOS.
|
|
39
|
+
if (length(highDifference) == 0.0) {
|
|
40
|
+
highDifference = vec3(0);
|
|
41
|
+
}
|
|
37
42
|
vec3 lowDifference = low - czm_encodedCameraPositionMCLow;
|
|
38
43
|
|
|
39
44
|
return vec4(highDifference + lowDifference, 1.0);
|
|
@@ -35,6 +35,11 @@ export default "/**\n\
|
|
|
35
35
|
vec4 czm_translateRelativeToEye(vec3 high, vec3 low)\n\
|
|
36
36
|
{\n\
|
|
37
37
|
vec3 highDifference = high - czm_encodedCameraPositionMCHigh;\n\
|
|
38
|
+
// This check handles the case when NaN values have gotten into `highDifference`.\n\
|
|
39
|
+
// Such a thing could happen on devices running iOS.\n\
|
|
40
|
+
if (length(highDifference) == 0.0) { \n\
|
|
41
|
+
highDifference = vec3(0); \n\
|
|
42
|
+
}\n\
|
|
38
43
|
vec3 lowDifference = low - czm_encodedCameraPositionMCLow;\n\
|
|
39
44
|
\n\
|
|
40
45
|
return vec4(highDifference + lowDifference, 1.0);\n\
|
|
@@ -268,20 +268,6 @@ vec4 sampleAndBlend(
|
|
|
268
268
|
return vec4(outColor, max(outAlpha, 0.0));
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
vec3 colorCorrect(vec3 rgb) {
|
|
272
|
-
#ifdef COLOR_CORRECT
|
|
273
|
-
// Convert rgb color to hsb
|
|
274
|
-
vec3 hsb = czm_RGBToHSB(rgb);
|
|
275
|
-
// Perform hsb shift
|
|
276
|
-
hsb.x += u_hsbShift.x; // hue
|
|
277
|
-
hsb.y = clamp(hsb.y + u_hsbShift.y, 0.0, 1.0); // saturation
|
|
278
|
-
hsb.z = hsb.z > czm_epsilon7 ? hsb.z + u_hsbShift.z : 0.0; // brightness
|
|
279
|
-
// Convert shifted hsb back to rgb
|
|
280
|
-
rgb = czm_HSBToRGB(hsb);
|
|
281
|
-
#endif
|
|
282
|
-
return rgb;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
271
|
vec4 computeDayColor(vec4 initialColor, vec3 textureCoordinates, float nightBlend);
|
|
286
272
|
vec4 computeWaterColor(vec3 positionEyeCoordinates, vec2 textureCoordinates, mat3 enuToEye, vec4 imageryColor, float specularMapValue, float fade);
|
|
287
273
|
|
|
@@ -396,7 +382,7 @@ void main()
|
|
|
396
382
|
materialInput.st = v_textureCoordinates.st;
|
|
397
383
|
materialInput.normalEC = normalize(v_normalEC);
|
|
398
384
|
materialInput.positionToEyeEC = -v_positionEC;
|
|
399
|
-
materialInput.tangentToEyeMatrix = czm_eastNorthUpToEyeCoordinates(v_positionMC, normalize(v_normalEC));
|
|
385
|
+
materialInput.tangentToEyeMatrix = czm_eastNorthUpToEyeCoordinates(v_positionMC, normalize(v_normalEC));
|
|
400
386
|
materialInput.slope = v_slope;
|
|
401
387
|
materialInput.height = v_height;
|
|
402
388
|
materialInput.aspect = v_aspect;
|
|
@@ -442,7 +428,7 @@ void main()
|
|
|
442
428
|
{
|
|
443
429
|
bool dynamicLighting = false;
|
|
444
430
|
#if defined(DYNAMIC_ATMOSPHERE_LIGHTING) && (defined(ENABLE_DAYNIGHT_SHADING) || defined(ENABLE_VERTEX_LIGHTING))
|
|
445
|
-
dynamicLighting = true;
|
|
431
|
+
dynamicLighting = true;
|
|
446
432
|
#endif
|
|
447
433
|
|
|
448
434
|
vec3 rayleighColor;
|
|
@@ -472,30 +458,35 @@ void main()
|
|
|
472
458
|
opacity = v_atmosphereOpacity;
|
|
473
459
|
#endif
|
|
474
460
|
|
|
475
|
-
|
|
476
|
-
|
|
461
|
+
#ifdef COLOR_CORRECT
|
|
462
|
+
const bool ignoreBlackPixels = true;
|
|
463
|
+
rayleighColor = czm_applyHSBShift(rayleighColor, u_hsbShift, ignoreBlackPixels);
|
|
464
|
+
mieColor = czm_applyHSBShift(mieColor, u_hsbShift, ignoreBlackPixels);
|
|
465
|
+
#endif
|
|
477
466
|
|
|
478
467
|
vec4 groundAtmosphereColor = computeAtmosphereColor(positionWC, lightDirection, rayleighColor, mieColor, opacity);
|
|
479
468
|
|
|
480
469
|
// Fog is applied to tiles selected for fog, close to the Earth.
|
|
481
470
|
#ifdef FOG
|
|
482
471
|
vec3 fogColor = groundAtmosphereColor.rgb;
|
|
483
|
-
|
|
472
|
+
|
|
484
473
|
// If there is lighting, apply that to the fog.
|
|
485
474
|
#if defined(DYNAMIC_ATMOSPHERE_LIGHTING) && (defined(ENABLE_VERTEX_LIGHTING) || defined(ENABLE_DAYNIGHT_SHADING))
|
|
486
475
|
float darken = clamp(dot(normalize(czm_viewerPositionWC), atmosphereLightDirection), u_minimumBrightness, 1.0);
|
|
487
|
-
fogColor *= darken;
|
|
476
|
+
fogColor *= darken;
|
|
488
477
|
#endif
|
|
489
478
|
|
|
490
479
|
#ifndef HDR
|
|
491
480
|
fogColor.rgb = czm_acesTonemapping(fogColor.rgb);
|
|
492
481
|
fogColor.rgb = czm_inverseGamma(fogColor.rgb);
|
|
493
482
|
#endif
|
|
494
|
-
|
|
483
|
+
|
|
495
484
|
const float modifier = 0.15;
|
|
496
485
|
finalColor = vec4(czm_fog(v_distance, finalColor.rgb, fogColor.rgb, modifier), finalColor.a);
|
|
497
486
|
|
|
498
487
|
#else
|
|
488
|
+
// Apply ground atmosphere. This happens when the camera is far away from the earth.
|
|
489
|
+
|
|
499
490
|
// The transmittance is based on optical depth i.e. the length of segment of the ray inside the atmosphere.
|
|
500
491
|
// This value is larger near the "circumference", as it is further away from the camera. We use it to
|
|
501
492
|
// brighten up that area of the ground atmosphere.
|
|
@@ -507,20 +498,20 @@ void main()
|
|
|
507
498
|
#if defined(DYNAMIC_ATMOSPHERE_LIGHTING) && (defined(ENABLE_VERTEX_LIGHTING) || defined(ENABLE_DAYNIGHT_SHADING))
|
|
508
499
|
float fadeInDist = u_nightFadeDistance.x;
|
|
509
500
|
float fadeOutDist = u_nightFadeDistance.y;
|
|
510
|
-
|
|
501
|
+
|
|
511
502
|
float sunlitAtmosphereIntensity = clamp((cameraDist - fadeOutDist) / (fadeInDist - fadeOutDist), 0.05, 1.0);
|
|
512
503
|
float darken = clamp(dot(normalize(positionWC), atmosphereLightDirection), 0.0, 1.0);
|
|
513
504
|
vec3 darkenendGroundAtmosphereColor = mix(groundAtmosphereColor.rgb, finalAtmosphereColor.rgb, darken);
|
|
514
505
|
|
|
515
506
|
finalAtmosphereColor = mix(darkenendGroundAtmosphereColor, finalAtmosphereColor, sunlitAtmosphereIntensity);
|
|
516
507
|
#endif
|
|
517
|
-
|
|
508
|
+
|
|
518
509
|
#ifndef HDR
|
|
519
510
|
finalAtmosphereColor.rgb = vec3(1.0) - exp(-fExposure * finalAtmosphereColor.rgb);
|
|
520
511
|
#else
|
|
521
512
|
finalAtmosphereColor.rgb = czm_saturation(finalAtmosphereColor.rgb, 1.6);
|
|
522
513
|
#endif
|
|
523
|
-
|
|
514
|
+
|
|
524
515
|
finalColor.rgb = mix(finalColor.rgb, finalAtmosphereColor.rgb, fade);
|
|
525
516
|
#endif
|
|
526
517
|
}
|
|
@@ -544,7 +535,7 @@ void main()
|
|
|
544
535
|
finalColor.a *= interpolateByDistance(alphaByDistance, v_distance);
|
|
545
536
|
}
|
|
546
537
|
#endif
|
|
547
|
-
|
|
538
|
+
|
|
548
539
|
out_FragColor = finalColor;
|
|
549
540
|
}
|
|
550
541
|
|
|
@@ -269,20 +269,6 @@ vec4 sampleAndBlend(\n\
|
|
|
269
269
|
return vec4(outColor, max(outAlpha, 0.0));\n\
|
|
270
270
|
}\n\
|
|
271
271
|
\n\
|
|
272
|
-
vec3 colorCorrect(vec3 rgb) {\n\
|
|
273
|
-
#ifdef COLOR_CORRECT\n\
|
|
274
|
-
// Convert rgb color to hsb\n\
|
|
275
|
-
vec3 hsb = czm_RGBToHSB(rgb);\n\
|
|
276
|
-
// Perform hsb shift\n\
|
|
277
|
-
hsb.x += u_hsbShift.x; // hue\n\
|
|
278
|
-
hsb.y = clamp(hsb.y + u_hsbShift.y, 0.0, 1.0); // saturation\n\
|
|
279
|
-
hsb.z = hsb.z > czm_epsilon7 ? hsb.z + u_hsbShift.z : 0.0; // brightness\n\
|
|
280
|
-
// Convert shifted hsb back to rgb\n\
|
|
281
|
-
rgb = czm_HSBToRGB(hsb);\n\
|
|
282
|
-
#endif\n\
|
|
283
|
-
return rgb;\n\
|
|
284
|
-
}\n\
|
|
285
|
-
\n\
|
|
286
272
|
vec4 computeDayColor(vec4 initialColor, vec3 textureCoordinates, float nightBlend);\n\
|
|
287
273
|
vec4 computeWaterColor(vec3 positionEyeCoordinates, vec2 textureCoordinates, mat3 enuToEye, vec4 imageryColor, float specularMapValue, float fade);\n\
|
|
288
274
|
\n\
|
|
@@ -397,7 +383,7 @@ void main()\n\
|
|
|
397
383
|
materialInput.st = v_textureCoordinates.st;\n\
|
|
398
384
|
materialInput.normalEC = normalize(v_normalEC);\n\
|
|
399
385
|
materialInput.positionToEyeEC = -v_positionEC;\n\
|
|
400
|
-
materialInput.tangentToEyeMatrix = czm_eastNorthUpToEyeCoordinates(v_positionMC, normalize(v_normalEC))
|
|
386
|
+
materialInput.tangentToEyeMatrix = czm_eastNorthUpToEyeCoordinates(v_positionMC, normalize(v_normalEC));\n\
|
|
401
387
|
materialInput.slope = v_slope;\n\
|
|
402
388
|
materialInput.height = v_height;\n\
|
|
403
389
|
materialInput.aspect = v_aspect;\n\
|
|
@@ -443,7 +429,7 @@ void main()\n\
|
|
|
443
429
|
{\n\
|
|
444
430
|
bool dynamicLighting = false;\n\
|
|
445
431
|
#if defined(DYNAMIC_ATMOSPHERE_LIGHTING) && (defined(ENABLE_DAYNIGHT_SHADING) || defined(ENABLE_VERTEX_LIGHTING))\n\
|
|
446
|
-
dynamicLighting = true
|
|
432
|
+
dynamicLighting = true;\n\
|
|
447
433
|
#endif\n\
|
|
448
434
|
\n\
|
|
449
435
|
vec3 rayleighColor;\n\
|
|
@@ -473,30 +459,35 @@ void main()\n\
|
|
|
473
459
|
opacity = v_atmosphereOpacity;\n\
|
|
474
460
|
#endif\n\
|
|
475
461
|
\n\
|
|
476
|
-
|
|
477
|
-
|
|
462
|
+
#ifdef COLOR_CORRECT\n\
|
|
463
|
+
const bool ignoreBlackPixels = true;\n\
|
|
464
|
+
rayleighColor = czm_applyHSBShift(rayleighColor, u_hsbShift, ignoreBlackPixels);\n\
|
|
465
|
+
mieColor = czm_applyHSBShift(mieColor, u_hsbShift, ignoreBlackPixels);\n\
|
|
466
|
+
#endif\n\
|
|
478
467
|
\n\
|
|
479
468
|
vec4 groundAtmosphereColor = computeAtmosphereColor(positionWC, lightDirection, rayleighColor, mieColor, opacity);\n\
|
|
480
469
|
\n\
|
|
481
470
|
// Fog is applied to tiles selected for fog, close to the Earth.\n\
|
|
482
471
|
#ifdef FOG\n\
|
|
483
472
|
vec3 fogColor = groundAtmosphereColor.rgb;\n\
|
|
484
|
-
|
|
473
|
+
\n\
|
|
485
474
|
// If there is lighting, apply that to the fog.\n\
|
|
486
475
|
#if defined(DYNAMIC_ATMOSPHERE_LIGHTING) && (defined(ENABLE_VERTEX_LIGHTING) || defined(ENABLE_DAYNIGHT_SHADING))\n\
|
|
487
476
|
float darken = clamp(dot(normalize(czm_viewerPositionWC), atmosphereLightDirection), u_minimumBrightness, 1.0);\n\
|
|
488
|
-
fogColor *= darken
|
|
477
|
+
fogColor *= darken;\n\
|
|
489
478
|
#endif\n\
|
|
490
479
|
\n\
|
|
491
480
|
#ifndef HDR\n\
|
|
492
481
|
fogColor.rgb = czm_acesTonemapping(fogColor.rgb);\n\
|
|
493
482
|
fogColor.rgb = czm_inverseGamma(fogColor.rgb);\n\
|
|
494
483
|
#endif\n\
|
|
495
|
-
|
|
484
|
+
\n\
|
|
496
485
|
const float modifier = 0.15;\n\
|
|
497
486
|
finalColor = vec4(czm_fog(v_distance, finalColor.rgb, fogColor.rgb, modifier), finalColor.a);\n\
|
|
498
487
|
\n\
|
|
499
488
|
#else\n\
|
|
489
|
+
// Apply ground atmosphere. This happens when the camera is far away from the earth.\n\
|
|
490
|
+
\n\
|
|
500
491
|
// The transmittance is based on optical depth i.e. the length of segment of the ray inside the atmosphere.\n\
|
|
501
492
|
// This value is larger near the \"circumference\", as it is further away from the camera. We use it to\n\
|
|
502
493
|
// brighten up that area of the ground atmosphere.\n\
|
|
@@ -508,20 +499,20 @@ void main()\n\
|
|
|
508
499
|
#if defined(DYNAMIC_ATMOSPHERE_LIGHTING) && (defined(ENABLE_VERTEX_LIGHTING) || defined(ENABLE_DAYNIGHT_SHADING))\n\
|
|
509
500
|
float fadeInDist = u_nightFadeDistance.x;\n\
|
|
510
501
|
float fadeOutDist = u_nightFadeDistance.y;\n\
|
|
511
|
-
|
|
502
|
+
\n\
|
|
512
503
|
float sunlitAtmosphereIntensity = clamp((cameraDist - fadeOutDist) / (fadeInDist - fadeOutDist), 0.05, 1.0);\n\
|
|
513
504
|
float darken = clamp(dot(normalize(positionWC), atmosphereLightDirection), 0.0, 1.0);\n\
|
|
514
505
|
vec3 darkenendGroundAtmosphereColor = mix(groundAtmosphereColor.rgb, finalAtmosphereColor.rgb, darken);\n\
|
|
515
506
|
\n\
|
|
516
507
|
finalAtmosphereColor = mix(darkenendGroundAtmosphereColor, finalAtmosphereColor, sunlitAtmosphereIntensity);\n\
|
|
517
508
|
#endif\n\
|
|
518
|
-
|
|
509
|
+
\n\
|
|
519
510
|
#ifndef HDR\n\
|
|
520
511
|
finalAtmosphereColor.rgb = vec3(1.0) - exp(-fExposure * finalAtmosphereColor.rgb);\n\
|
|
521
512
|
#else\n\
|
|
522
513
|
finalAtmosphereColor.rgb = czm_saturation(finalAtmosphereColor.rgb, 1.6);\n\
|
|
523
514
|
#endif\n\
|
|
524
|
-
|
|
515
|
+
\n\
|
|
525
516
|
finalColor.rgb = mix(finalColor.rgb, finalAtmosphereColor.rgb, fade);\n\
|
|
526
517
|
#endif\n\
|
|
527
518
|
}\n\
|
|
@@ -545,7 +536,7 @@ void main()\n\
|
|
|
545
536
|
finalColor.a *= interpolateByDistance(alphaByDistance, v_distance);\n\
|
|
546
537
|
}\n\
|
|
547
538
|
#endif\n\
|
|
548
|
-
|
|
539
|
+
\n\
|
|
549
540
|
out_FragColor = finalColor;\n\
|
|
550
541
|
}\n\
|
|
551
542
|
\n\
|
|
@@ -128,7 +128,7 @@ void main()
|
|
|
128
128
|
height = height * (u_minMaxHeight.y - u_minMaxHeight.x) + u_minMaxHeight.x;
|
|
129
129
|
position = (u_scaleAndBias * vec4(position, 1.0)).xyz;
|
|
130
130
|
|
|
131
|
-
#if (defined(ENABLE_VERTEX_LIGHTING) || defined(GENERATE_POSITION_AND_NORMAL)) && defined(INCLUDE_WEB_MERCATOR_Y)
|
|
131
|
+
#if (defined(ENABLE_VERTEX_LIGHTING) || defined(GENERATE_POSITION_AND_NORMAL)) && defined(INCLUDE_WEB_MERCATOR_Y) || defined(APPLY_MATERIAL)
|
|
132
132
|
float webMercatorT = czm_decompressTextureCoordinates(compressed0.w).x;
|
|
133
133
|
float encodedNormal = compressed1;
|
|
134
134
|
#elif defined(INCLUDE_WEB_MERCATOR_Y)
|
|
@@ -129,7 +129,7 @@ void main()\n\
|
|
|
129
129
|
height = height * (u_minMaxHeight.y - u_minMaxHeight.x) + u_minMaxHeight.x;\n\
|
|
130
130
|
position = (u_scaleAndBias * vec4(position, 1.0)).xyz;\n\
|
|
131
131
|
\n\
|
|
132
|
-
#if (defined(ENABLE_VERTEX_LIGHTING) || defined(GENERATE_POSITION_AND_NORMAL)) && defined(INCLUDE_WEB_MERCATOR_Y)\n\
|
|
132
|
+
#if (defined(ENABLE_VERTEX_LIGHTING) || defined(GENERATE_POSITION_AND_NORMAL)) && defined(INCLUDE_WEB_MERCATOR_Y) || defined(APPLY_MATERIAL)\n\
|
|
133
133
|
float webMercatorT = czm_decompressTextureCoordinates(compressed0.w).x;\n\
|
|
134
134
|
float encodedNormal = compressed1;\n\
|
|
135
135
|
#elif defined(INCLUDE_WEB_MERCATOR_Y)\n\
|