@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,111 @@
|
|
|
1
|
+
// robust iterative solution without trig functions
|
|
2
|
+
// https://github.com/0xfaded/ellipse_demo/issues/1
|
|
3
|
+
// https://stackoverflow.com/questions/22959698/distance-from-given-point-to-given-ellipse
|
|
4
|
+
//
|
|
5
|
+
// This version uses only a single iteration for best performance. For fog
|
|
6
|
+
// rendering, the difference is negligible.
|
|
7
|
+
vec2 nearestPointOnEllipseFast(vec2 pos, vec2 radii) {
|
|
8
|
+
vec2 p = abs(pos);
|
|
9
|
+
vec2 inverseRadii = 1.0 / radii;
|
|
10
|
+
vec2 evoluteScale = (radii.x * radii.x - radii.y * radii.y) * vec2(1.0, -1.0) * inverseRadii;
|
|
11
|
+
|
|
12
|
+
// We describe the ellipse parametrically: v = radii * vec2(cos(t), sin(t))
|
|
13
|
+
// but store the cos and sin of t in a vec2 for efficiency.
|
|
14
|
+
// Initial guess: t = cos(pi/4)
|
|
15
|
+
vec2 tTrigs = vec2(0.70710678118);
|
|
16
|
+
vec2 v = radii * tTrigs;
|
|
17
|
+
|
|
18
|
+
// Find the evolute of the ellipse (center of curvature) at v.
|
|
19
|
+
vec2 evolute = evoluteScale * tTrigs * tTrigs * tTrigs;
|
|
20
|
+
// Find the (approximate) intersection of p - evolute with the ellipsoid.
|
|
21
|
+
vec2 q = normalize(p - evolute) * length(v - evolute);
|
|
22
|
+
// Update the estimate of t.
|
|
23
|
+
tTrigs = (q + evolute) * inverseRadii;
|
|
24
|
+
tTrigs = normalize(clamp(tTrigs, 0.0, 1.0));
|
|
25
|
+
v = radii * tTrigs;
|
|
26
|
+
|
|
27
|
+
return v * sign(pos);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
vec3 computeEllipsoidPositionWC(vec3 positionMC) {
|
|
31
|
+
// Get the world-space position and project onto a meridian plane of
|
|
32
|
+
// the ellipsoid
|
|
33
|
+
vec3 positionWC = (czm_model * vec4(positionMC, 1.0)).xyz;
|
|
34
|
+
|
|
35
|
+
vec2 positionEllipse = vec2(length(positionWC.xy), positionWC.z);
|
|
36
|
+
vec2 nearestPoint = nearestPointOnEllipseFast(positionEllipse, czm_ellipsoidRadii.xz);
|
|
37
|
+
|
|
38
|
+
// Reconstruct a 3D point in world space
|
|
39
|
+
return vec3(nearestPoint.x * normalize(positionWC.xy), nearestPoint.y);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
void applyFog(inout vec4 color, vec4 groundAtmosphereColor, vec3 lightDirection, float distanceToCamera) {
|
|
43
|
+
|
|
44
|
+
vec3 fogColor = groundAtmosphereColor.rgb;
|
|
45
|
+
|
|
46
|
+
// If there is dynamic lighting, apply that to the fog.
|
|
47
|
+
const float NONE = 0.0;
|
|
48
|
+
if (czm_atmosphereDynamicLighting != NONE) {
|
|
49
|
+
float darken = clamp(dot(normalize(czm_viewerPositionWC), lightDirection), czm_fogMinimumBrightness, 1.0);
|
|
50
|
+
fogColor *= darken;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Tonemap if HDR rendering is disabled
|
|
54
|
+
#ifndef HDR
|
|
55
|
+
fogColor.rgb = czm_acesTonemapping(fogColor.rgb);
|
|
56
|
+
fogColor.rgb = czm_inverseGamma(fogColor.rgb);
|
|
57
|
+
#endif
|
|
58
|
+
|
|
59
|
+
// Matches the constant in GlobeFS.glsl. This makes the fog falloff
|
|
60
|
+
// more gradual.
|
|
61
|
+
const float fogModifier = 0.15;
|
|
62
|
+
vec3 withFog = czm_fog(distanceToCamera, color.rgb, fogColor, fogModifier);
|
|
63
|
+
color = vec4(withFog, color.a);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
void atmosphereStage(inout vec4 color, in ProcessedAttributes attributes) {
|
|
67
|
+
vec3 rayleighColor;
|
|
68
|
+
vec3 mieColor;
|
|
69
|
+
float opacity;
|
|
70
|
+
|
|
71
|
+
vec3 positionWC;
|
|
72
|
+
vec3 lightDirection;
|
|
73
|
+
|
|
74
|
+
// When the camera is in space, compute the position per-fragment for
|
|
75
|
+
// more accurate ground atmosphere. All other cases will use
|
|
76
|
+
//
|
|
77
|
+
// The if condition will be added in https://github.com/CesiumGS/cesium/issues/11717
|
|
78
|
+
if (false) {
|
|
79
|
+
positionWC = computeEllipsoidPositionWC(attributes.positionMC);
|
|
80
|
+
lightDirection = czm_getDynamicAtmosphereLightDirection(positionWC, czm_atmosphereDynamicLighting);
|
|
81
|
+
|
|
82
|
+
// The fog color is derived from the ground atmosphere color
|
|
83
|
+
czm_computeGroundAtmosphereScattering(
|
|
84
|
+
positionWC,
|
|
85
|
+
lightDirection,
|
|
86
|
+
rayleighColor,
|
|
87
|
+
mieColor,
|
|
88
|
+
opacity
|
|
89
|
+
);
|
|
90
|
+
} else {
|
|
91
|
+
positionWC = attributes.positionWC;
|
|
92
|
+
lightDirection = czm_getDynamicAtmosphereLightDirection(positionWC, czm_atmosphereDynamicLighting);
|
|
93
|
+
rayleighColor = v_atmosphereRayleighColor;
|
|
94
|
+
mieColor = v_atmosphereMieColor;
|
|
95
|
+
opacity = v_atmosphereOpacity;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
//color correct rayleigh and mie colors
|
|
99
|
+
const bool ignoreBlackPixels = true;
|
|
100
|
+
rayleighColor = czm_applyHSBShift(rayleighColor, czm_atmosphereHsbShift, ignoreBlackPixels);
|
|
101
|
+
mieColor = czm_applyHSBShift(mieColor, czm_atmosphereHsbShift, ignoreBlackPixels);
|
|
102
|
+
|
|
103
|
+
vec4 groundAtmosphereColor = czm_computeAtmosphereColor(positionWC, lightDirection, rayleighColor, mieColor, opacity);
|
|
104
|
+
|
|
105
|
+
if (u_isInFog) {
|
|
106
|
+
float distanceToCamera = length(attributes.positionEC);
|
|
107
|
+
applyFog(color, groundAtmosphereColor, lightDirection, distanceToCamera);
|
|
108
|
+
} else {
|
|
109
|
+
// Ground atmosphere
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
+
export default "// robust iterative solution without trig functions\n\
|
|
3
|
+
// https://github.com/0xfaded/ellipse_demo/issues/1\n\
|
|
4
|
+
// https://stackoverflow.com/questions/22959698/distance-from-given-point-to-given-ellipse\n\
|
|
5
|
+
//\n\
|
|
6
|
+
// This version uses only a single iteration for best performance. For fog\n\
|
|
7
|
+
// rendering, the difference is negligible.\n\
|
|
8
|
+
vec2 nearestPointOnEllipseFast(vec2 pos, vec2 radii) {\n\
|
|
9
|
+
vec2 p = abs(pos);\n\
|
|
10
|
+
vec2 inverseRadii = 1.0 / radii;\n\
|
|
11
|
+
vec2 evoluteScale = (radii.x * radii.x - radii.y * radii.y) * vec2(1.0, -1.0) * inverseRadii;\n\
|
|
12
|
+
\n\
|
|
13
|
+
// We describe the ellipse parametrically: v = radii * vec2(cos(t), sin(t))\n\
|
|
14
|
+
// but store the cos and sin of t in a vec2 for efficiency.\n\
|
|
15
|
+
// Initial guess: t = cos(pi/4)\n\
|
|
16
|
+
vec2 tTrigs = vec2(0.70710678118);\n\
|
|
17
|
+
vec2 v = radii * tTrigs;\n\
|
|
18
|
+
\n\
|
|
19
|
+
// Find the evolute of the ellipse (center of curvature) at v.\n\
|
|
20
|
+
vec2 evolute = evoluteScale * tTrigs * tTrigs * tTrigs;\n\
|
|
21
|
+
// Find the (approximate) intersection of p - evolute with the ellipsoid.\n\
|
|
22
|
+
vec2 q = normalize(p - evolute) * length(v - evolute);\n\
|
|
23
|
+
// Update the estimate of t.\n\
|
|
24
|
+
tTrigs = (q + evolute) * inverseRadii;\n\
|
|
25
|
+
tTrigs = normalize(clamp(tTrigs, 0.0, 1.0));\n\
|
|
26
|
+
v = radii * tTrigs;\n\
|
|
27
|
+
\n\
|
|
28
|
+
return v * sign(pos);\n\
|
|
29
|
+
}\n\
|
|
30
|
+
\n\
|
|
31
|
+
vec3 computeEllipsoidPositionWC(vec3 positionMC) {\n\
|
|
32
|
+
// Get the world-space position and project onto a meridian plane of\n\
|
|
33
|
+
// the ellipsoid\n\
|
|
34
|
+
vec3 positionWC = (czm_model * vec4(positionMC, 1.0)).xyz;\n\
|
|
35
|
+
\n\
|
|
36
|
+
vec2 positionEllipse = vec2(length(positionWC.xy), positionWC.z);\n\
|
|
37
|
+
vec2 nearestPoint = nearestPointOnEllipseFast(positionEllipse, czm_ellipsoidRadii.xz);\n\
|
|
38
|
+
\n\
|
|
39
|
+
// Reconstruct a 3D point in world space\n\
|
|
40
|
+
return vec3(nearestPoint.x * normalize(positionWC.xy), nearestPoint.y);\n\
|
|
41
|
+
}\n\
|
|
42
|
+
\n\
|
|
43
|
+
void applyFog(inout vec4 color, vec4 groundAtmosphereColor, vec3 lightDirection, float distanceToCamera) {\n\
|
|
44
|
+
\n\
|
|
45
|
+
vec3 fogColor = groundAtmosphereColor.rgb;\n\
|
|
46
|
+
\n\
|
|
47
|
+
// If there is dynamic lighting, apply that to the fog.\n\
|
|
48
|
+
const float NONE = 0.0;\n\
|
|
49
|
+
if (czm_atmosphereDynamicLighting != NONE) {\n\
|
|
50
|
+
float darken = clamp(dot(normalize(czm_viewerPositionWC), lightDirection), czm_fogMinimumBrightness, 1.0);\n\
|
|
51
|
+
fogColor *= darken;\n\
|
|
52
|
+
}\n\
|
|
53
|
+
\n\
|
|
54
|
+
// Tonemap if HDR rendering is disabled\n\
|
|
55
|
+
#ifndef HDR\n\
|
|
56
|
+
fogColor.rgb = czm_acesTonemapping(fogColor.rgb);\n\
|
|
57
|
+
fogColor.rgb = czm_inverseGamma(fogColor.rgb);\n\
|
|
58
|
+
#endif\n\
|
|
59
|
+
\n\
|
|
60
|
+
// Matches the constant in GlobeFS.glsl. This makes the fog falloff\n\
|
|
61
|
+
// more gradual.\n\
|
|
62
|
+
const float fogModifier = 0.15;\n\
|
|
63
|
+
vec3 withFog = czm_fog(distanceToCamera, color.rgb, fogColor, fogModifier);\n\
|
|
64
|
+
color = vec4(withFog, color.a);\n\
|
|
65
|
+
}\n\
|
|
66
|
+
\n\
|
|
67
|
+
void atmosphereStage(inout vec4 color, in ProcessedAttributes attributes) {\n\
|
|
68
|
+
vec3 rayleighColor;\n\
|
|
69
|
+
vec3 mieColor;\n\
|
|
70
|
+
float opacity;\n\
|
|
71
|
+
\n\
|
|
72
|
+
vec3 positionWC;\n\
|
|
73
|
+
vec3 lightDirection;\n\
|
|
74
|
+
\n\
|
|
75
|
+
// When the camera is in space, compute the position per-fragment for\n\
|
|
76
|
+
// more accurate ground atmosphere. All other cases will use\n\
|
|
77
|
+
//\n\
|
|
78
|
+
// The if condition will be added in https://github.com/CesiumGS/cesium/issues/11717\n\
|
|
79
|
+
if (false) {\n\
|
|
80
|
+
positionWC = computeEllipsoidPositionWC(attributes.positionMC);\n\
|
|
81
|
+
lightDirection = czm_getDynamicAtmosphereLightDirection(positionWC, czm_atmosphereDynamicLighting);\n\
|
|
82
|
+
\n\
|
|
83
|
+
// The fog color is derived from the ground atmosphere color\n\
|
|
84
|
+
czm_computeGroundAtmosphereScattering(\n\
|
|
85
|
+
positionWC,\n\
|
|
86
|
+
lightDirection,\n\
|
|
87
|
+
rayleighColor,\n\
|
|
88
|
+
mieColor,\n\
|
|
89
|
+
opacity\n\
|
|
90
|
+
);\n\
|
|
91
|
+
} else {\n\
|
|
92
|
+
positionWC = attributes.positionWC;\n\
|
|
93
|
+
lightDirection = czm_getDynamicAtmosphereLightDirection(positionWC, czm_atmosphereDynamicLighting);\n\
|
|
94
|
+
rayleighColor = v_atmosphereRayleighColor;\n\
|
|
95
|
+
mieColor = v_atmosphereMieColor;\n\
|
|
96
|
+
opacity = v_atmosphereOpacity;\n\
|
|
97
|
+
}\n\
|
|
98
|
+
\n\
|
|
99
|
+
//color correct rayleigh and mie colors\n\
|
|
100
|
+
const bool ignoreBlackPixels = true;\n\
|
|
101
|
+
rayleighColor = czm_applyHSBShift(rayleighColor, czm_atmosphereHsbShift, ignoreBlackPixels);\n\
|
|
102
|
+
mieColor = czm_applyHSBShift(mieColor, czm_atmosphereHsbShift, ignoreBlackPixels);\n\
|
|
103
|
+
\n\
|
|
104
|
+
vec4 groundAtmosphereColor = czm_computeAtmosphereColor(positionWC, lightDirection, rayleighColor, mieColor, opacity);\n\
|
|
105
|
+
\n\
|
|
106
|
+
if (u_isInFog) {\n\
|
|
107
|
+
float distanceToCamera = length(attributes.positionEC);\n\
|
|
108
|
+
applyFog(color, groundAtmosphereColor, lightDirection, distanceToCamera);\n\
|
|
109
|
+
} else {\n\
|
|
110
|
+
// Ground atmosphere\n\
|
|
111
|
+
}\n\
|
|
112
|
+
}\n\
|
|
113
|
+
";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
void atmosphereStage(ProcessedAttributes attributes) {
|
|
2
|
+
vec3 lightDirection = czm_getDynamicAtmosphereLightDirection(v_positionWC, czm_atmosphereDynamicLighting);
|
|
3
|
+
|
|
4
|
+
czm_computeGroundAtmosphereScattering(
|
|
5
|
+
// This assumes the geometry stage came before this.
|
|
6
|
+
v_positionWC,
|
|
7
|
+
lightDirection,
|
|
8
|
+
v_atmosphereRayleighColor,
|
|
9
|
+
v_atmosphereMieColor,
|
|
10
|
+
v_atmosphereOpacity
|
|
11
|
+
);
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
+
export default "void atmosphereStage(ProcessedAttributes attributes) {\n\
|
|
3
|
+
vec3 lightDirection = czm_getDynamicAtmosphereLightDirection(v_positionWC, czm_atmosphereDynamicLighting);\n\
|
|
4
|
+
\n\
|
|
5
|
+
czm_computeGroundAtmosphereScattering(\n\
|
|
6
|
+
// This assumes the geometry stage came before this.\n\
|
|
7
|
+
v_positionWC,\n\
|
|
8
|
+
lightDirection,\n\
|
|
9
|
+
v_atmosphereRayleighColor,\n\
|
|
10
|
+
v_atmosphereMieColor,\n\
|
|
11
|
+
v_atmosphereOpacity\n\
|
|
12
|
+
);\n\
|
|
13
|
+
}\n\
|
|
14
|
+
";
|
|
@@ -3,7 +3,7 @@ void geometryStage(out ProcessedAttributes attributes)
|
|
|
3
3
|
attributes.positionMC = v_positionMC;
|
|
4
4
|
attributes.positionEC = v_positionEC;
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
#if defined(COMPUTE_POSITION_WC_CUSTOM_SHADER) || defined(COMPUTE_POSITION_WC_STYLE) || defined(COMPUTE_POSITION_WC_ATMOSPHERE)
|
|
7
7
|
attributes.positionWC = v_positionWC;
|
|
8
8
|
#endif
|
|
9
9
|
|
|
@@ -4,7 +4,7 @@ export default "void geometryStage(out ProcessedAttributes attributes)\n\
|
|
|
4
4
|
attributes.positionMC = v_positionMC;\n\
|
|
5
5
|
attributes.positionEC = v_positionEC;\n\
|
|
6
6
|
\n\
|
|
7
|
-
#
|
|
7
|
+
#if defined(COMPUTE_POSITION_WC_CUSTOM_SHADER) || defined(COMPUTE_POSITION_WC_STYLE) || defined(COMPUTE_POSITION_WC_ATMOSPHERE)\n\
|
|
8
8
|
attributes.positionWC = v_positionWC;\n\
|
|
9
9
|
#endif\n\
|
|
10
10
|
\n\
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
vec4 geometryStage(inout ProcessedAttributes attributes, mat4 modelView, mat3 normal)
|
|
1
|
+
vec4 geometryStage(inout ProcessedAttributes attributes, mat4 modelView, mat3 normal)
|
|
2
2
|
{
|
|
3
3
|
vec4 computedPosition;
|
|
4
4
|
|
|
@@ -16,7 +16,7 @@ vec4 geometryStage(inout ProcessedAttributes attributes, mat4 modelView, mat3 no
|
|
|
16
16
|
#endif
|
|
17
17
|
|
|
18
18
|
// Sometimes the custom shader and/or style needs this
|
|
19
|
-
#if defined(COMPUTE_POSITION_WC_CUSTOM_SHADER) || defined(COMPUTE_POSITION_WC_STYLE)
|
|
19
|
+
#if defined(COMPUTE_POSITION_WC_CUSTOM_SHADER) || defined(COMPUTE_POSITION_WC_STYLE) || defined(COMPUTE_POSITION_WC_ATMOSPHERE)
|
|
20
20
|
// Note that this is a 32-bit position which may result in jitter on small
|
|
21
21
|
// scales.
|
|
22
22
|
v_positionWC = (czm_model * vec4(positionMC, 1.0)).xyz;
|
|
@@ -27,7 +27,7 @@ vec4 geometryStage(inout ProcessedAttributes attributes, mat4 modelView, mat3 no
|
|
|
27
27
|
#endif
|
|
28
28
|
|
|
29
29
|
#ifdef HAS_TANGENTS
|
|
30
|
-
v_tangentEC = normalize(normal * attributes.tangentMC);
|
|
30
|
+
v_tangentEC = normalize(normal * attributes.tangentMC);
|
|
31
31
|
#endif
|
|
32
32
|
|
|
33
33
|
#ifdef HAS_BITANGENTS
|
|
@@ -37,6 +37,6 @@ vec4 geometryStage(inout ProcessedAttributes attributes, mat4 modelView, mat3 no
|
|
|
37
37
|
// All other varyings need to be dynamically generated in
|
|
38
38
|
// GeometryPipelineStage
|
|
39
39
|
setDynamicVaryings(attributes);
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
return computedPosition;
|
|
42
42
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
-
export default "vec4 geometryStage(inout ProcessedAttributes attributes, mat4 modelView, mat3 normal)
|
|
2
|
+
export default "vec4 geometryStage(inout ProcessedAttributes attributes, mat4 modelView, mat3 normal)\n\
|
|
3
3
|
{\n\
|
|
4
4
|
vec4 computedPosition;\n\
|
|
5
5
|
\n\
|
|
@@ -17,7 +17,7 @@ export default "vec4 geometryStage(inout ProcessedAttributes attributes, mat4 mo
|
|
|
17
17
|
#endif\n\
|
|
18
18
|
\n\
|
|
19
19
|
// Sometimes the custom shader and/or style needs this\n\
|
|
20
|
-
#if defined(COMPUTE_POSITION_WC_CUSTOM_SHADER) || defined(COMPUTE_POSITION_WC_STYLE)\n\
|
|
20
|
+
#if defined(COMPUTE_POSITION_WC_CUSTOM_SHADER) || defined(COMPUTE_POSITION_WC_STYLE) || defined(COMPUTE_POSITION_WC_ATMOSPHERE)\n\
|
|
21
21
|
// Note that this is a 32-bit position which may result in jitter on small\n\
|
|
22
22
|
// scales.\n\
|
|
23
23
|
v_positionWC = (czm_model * vec4(positionMC, 1.0)).xyz;\n\
|
|
@@ -28,7 +28,7 @@ export default "vec4 geometryStage(inout ProcessedAttributes attributes, mat4 mo
|
|
|
28
28
|
#endif\n\
|
|
29
29
|
\n\
|
|
30
30
|
#ifdef HAS_TANGENTS\n\
|
|
31
|
-
v_tangentEC = normalize(normal * attributes.tangentMC)
|
|
31
|
+
v_tangentEC = normalize(normal * attributes.tangentMC);\n\
|
|
32
32
|
#endif\n\
|
|
33
33
|
\n\
|
|
34
34
|
#ifdef HAS_BITANGENTS\n\
|
|
@@ -38,7 +38,7 @@ export default "vec4 geometryStage(inout ProcessedAttributes attributes, mat4 mo
|
|
|
38
38
|
// All other varyings need to be dynamically generated in\n\
|
|
39
39
|
// GeometryPipelineStage\n\
|
|
40
40
|
setDynamicVaryings(attributes);\n\
|
|
41
|
-
|
|
41
|
+
\n\
|
|
42
42
|
return computedPosition;\n\
|
|
43
43
|
}\n\
|
|
44
44
|
";
|
|
@@ -7,7 +7,7 @@ czm_modelVertexOutput defaultVertexOutput(vec3 positionMC) {
|
|
|
7
7
|
return vsOutput;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
void main()
|
|
10
|
+
void main()
|
|
11
11
|
{
|
|
12
12
|
// Initialize the attributes struct with all
|
|
13
13
|
// attributes except quantized ones.
|
|
@@ -66,14 +66,14 @@ void main()
|
|
|
66
66
|
// Update the position for this instance in place
|
|
67
67
|
#ifdef HAS_INSTANCING
|
|
68
68
|
|
|
69
|
-
// The legacy instance stage is used when rendering i3dm models that
|
|
69
|
+
// The legacy instance stage is used when rendering i3dm models that
|
|
70
70
|
// encode instances transforms in world space, as opposed to glTF models
|
|
71
71
|
// that use EXT_mesh_gpu_instancing, where instance transforms are encoded
|
|
72
72
|
// in object space.
|
|
73
73
|
#ifdef USE_LEGACY_INSTANCING
|
|
74
74
|
mat4 instanceModelView;
|
|
75
75
|
mat3 instanceModelViewInverseTranspose;
|
|
76
|
-
|
|
76
|
+
|
|
77
77
|
legacyInstancingStage(attributes, instanceModelView, instanceModelViewInverseTranspose);
|
|
78
78
|
|
|
79
79
|
modelView = instanceModelView;
|
|
@@ -104,7 +104,12 @@ void main()
|
|
|
104
104
|
|
|
105
105
|
// Compute the final position in each coordinate system needed.
|
|
106
106
|
// This returns the value that will be assigned to gl_Position.
|
|
107
|
-
vec4 positionClip = geometryStage(attributes, modelView, normal);
|
|
107
|
+
vec4 positionClip = geometryStage(attributes, modelView, normal);
|
|
108
|
+
|
|
109
|
+
// This must go after the geometry stage as it needs v_positionWC
|
|
110
|
+
#ifdef HAS_ATMOSPHERE
|
|
111
|
+
atmosphereStage(attributes);
|
|
112
|
+
#endif
|
|
108
113
|
|
|
109
114
|
#ifdef HAS_SILHOUETTE
|
|
110
115
|
silhouetteStage(attributes, positionClip);
|
|
@@ -8,7 +8,7 @@ czm_modelVertexOutput defaultVertexOutput(vec3 positionMC) {\n\
|
|
|
8
8
|
return vsOutput;\n\
|
|
9
9
|
}\n\
|
|
10
10
|
\n\
|
|
11
|
-
void main()
|
|
11
|
+
void main()\n\
|
|
12
12
|
{\n\
|
|
13
13
|
// Initialize the attributes struct with all\n\
|
|
14
14
|
// attributes except quantized ones.\n\
|
|
@@ -67,14 +67,14 @@ void main() \n\
|
|
|
67
67
|
// Update the position for this instance in place\n\
|
|
68
68
|
#ifdef HAS_INSTANCING\n\
|
|
69
69
|
\n\
|
|
70
|
-
// The legacy instance stage is used when rendering i3dm models that
|
|
70
|
+
// The legacy instance stage is used when rendering i3dm models that\n\
|
|
71
71
|
// encode instances transforms in world space, as opposed to glTF models\n\
|
|
72
72
|
// that use EXT_mesh_gpu_instancing, where instance transforms are encoded\n\
|
|
73
73
|
// in object space.\n\
|
|
74
74
|
#ifdef USE_LEGACY_INSTANCING\n\
|
|
75
75
|
mat4 instanceModelView;\n\
|
|
76
76
|
mat3 instanceModelViewInverseTranspose;\n\
|
|
77
|
-
|
|
77
|
+
\n\
|
|
78
78
|
legacyInstancingStage(attributes, instanceModelView, instanceModelViewInverseTranspose);\n\
|
|
79
79
|
\n\
|
|
80
80
|
modelView = instanceModelView;\n\
|
|
@@ -105,7 +105,12 @@ void main() \n\
|
|
|
105
105
|
\n\
|
|
106
106
|
// Compute the final position in each coordinate system needed.\n\
|
|
107
107
|
// This returns the value that will be assigned to gl_Position.\n\
|
|
108
|
-
vec4 positionClip = geometryStage(attributes, modelView, normal)
|
|
108
|
+
vec4 positionClip = geometryStage(attributes, modelView, normal);\n\
|
|
109
|
+
\n\
|
|
110
|
+
// This must go after the geometry stage as it needs v_positionWC\n\
|
|
111
|
+
#ifdef HAS_ATMOSPHERE\n\
|
|
112
|
+
atmosphereStage(attributes);\n\
|
|
113
|
+
#endif\n\
|
|
109
114
|
\n\
|
|
110
115
|
#ifdef HAS_SILHOUETTE\n\
|
|
111
116
|
silhouetteStage(attributes, positionClip);\n\
|
|
@@ -8,16 +8,6 @@ float interpolateByDistance(vec4 nearFarScalar, float distance)
|
|
|
8
8
|
return mix(startValue, endValue, t);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
vec3 getLightDirection(vec3 positionWC)
|
|
12
|
-
{
|
|
13
|
-
float lightEnum = u_radiiAndDynamicAtmosphereColor.z;
|
|
14
|
-
vec3 lightDirection =
|
|
15
|
-
positionWC * float(lightEnum == 0.0) +
|
|
16
|
-
czm_lightDirectionWC * float(lightEnum == 1.0) +
|
|
17
|
-
czm_sunDirectionWC * float(lightEnum == 2.0);
|
|
18
|
-
return normalize(lightDirection);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
11
|
void computeAtmosphereScattering(vec3 positionWC, vec3 lightDirection, out vec3 rayleighColor, out vec3 mieColor, out float opacity, out float underTranslucentGlobe)
|
|
22
12
|
{
|
|
23
13
|
float ellipsoidRadiiDifference = czm_ellipsoidRadii.x - czm_ellipsoidRadii.z;
|
|
@@ -28,7 +18,7 @@ void computeAtmosphereScattering(vec3 positionWC, vec3 lightDirection, out vec3
|
|
|
28
18
|
float distanceAdjustModifier = ellipsoidRadiiDifference / 2.0;
|
|
29
19
|
float distanceAdjust = distanceAdjustModifier * clamp((czm_eyeHeight - distanceAdjustMin) / (distanceAdjustMax - distanceAdjustMin), 0.0, 1.0);
|
|
30
20
|
|
|
31
|
-
// Since atmosphere scattering assumes the atmosphere is a spherical shell, we compute an inner radius of the atmosphere best fit
|
|
21
|
+
// Since atmosphere scattering assumes the atmosphere is a spherical shell, we compute an inner radius of the atmosphere best fit
|
|
32
22
|
// for the position on the ellipsoid.
|
|
33
23
|
float radiusAdjust = (ellipsoidRadiiDifference / 4.0) + distanceAdjust;
|
|
34
24
|
float atmosphereInnerRadius = (length(czm_viewerPositionWC) - czm_eyeHeight) - radiusAdjust;
|
|
@@ -46,7 +36,7 @@ void computeAtmosphereScattering(vec3 positionWC, vec3 lightDirection, out vec3
|
|
|
46
36
|
// Check for intersection with the inner radius of the atmopshere.
|
|
47
37
|
czm_raySegment primaryRayEarthIntersect = czm_raySphereIntersectionInterval(primaryRay, vec3(0.0), atmosphereInnerRadius + radiusAdjust);
|
|
48
38
|
if (primaryRayEarthIntersect.start > 0.0 && primaryRayEarthIntersect.stop > 0.0) {
|
|
49
|
-
|
|
39
|
+
|
|
50
40
|
// Compute position on globe.
|
|
51
41
|
vec3 direction = normalize(positionWC);
|
|
52
42
|
czm_ray ellipsoidRay = czm_ray(positionWC, -direction);
|
|
@@ -62,7 +52,7 @@ void computeAtmosphereScattering(vec3 positionWC, vec3 lightDirection, out vec3
|
|
|
62
52
|
vec3 nearColor = vec3(0.0);
|
|
63
53
|
|
|
64
54
|
rayleighColor = mix(nearColor, horizonColor, exp(-angle) * opacity);
|
|
65
|
-
|
|
55
|
+
|
|
66
56
|
// Set the traslucent flag to avoid alpha adjustment in computeFinalColor funciton.
|
|
67
57
|
underTranslucentGlobe = 1.0;
|
|
68
58
|
return;
|
|
@@ -9,16 +9,6 @@ export default "float interpolateByDistance(vec4 nearFarScalar, float distance)\
|
|
|
9
9
|
return mix(startValue, endValue, t);\n\
|
|
10
10
|
}\n\
|
|
11
11
|
\n\
|
|
12
|
-
vec3 getLightDirection(vec3 positionWC)\n\
|
|
13
|
-
{\n\
|
|
14
|
-
float lightEnum = u_radiiAndDynamicAtmosphereColor.z;\n\
|
|
15
|
-
vec3 lightDirection =\n\
|
|
16
|
-
positionWC * float(lightEnum == 0.0) +\n\
|
|
17
|
-
czm_lightDirectionWC * float(lightEnum == 1.0) +\n\
|
|
18
|
-
czm_sunDirectionWC * float(lightEnum == 2.0);\n\
|
|
19
|
-
return normalize(lightDirection);\n\
|
|
20
|
-
}\n\
|
|
21
|
-
\n\
|
|
22
12
|
void computeAtmosphereScattering(vec3 positionWC, vec3 lightDirection, out vec3 rayleighColor, out vec3 mieColor, out float opacity, out float underTranslucentGlobe)\n\
|
|
23
13
|
{\n\
|
|
24
14
|
float ellipsoidRadiiDifference = czm_ellipsoidRadii.x - czm_ellipsoidRadii.z;\n\
|
|
@@ -29,7 +19,7 @@ void computeAtmosphereScattering(vec3 positionWC, vec3 lightDirection, out vec3
|
|
|
29
19
|
float distanceAdjustModifier = ellipsoidRadiiDifference / 2.0;\n\
|
|
30
20
|
float distanceAdjust = distanceAdjustModifier * clamp((czm_eyeHeight - distanceAdjustMin) / (distanceAdjustMax - distanceAdjustMin), 0.0, 1.0);\n\
|
|
31
21
|
\n\
|
|
32
|
-
// Since atmosphere scattering assumes the atmosphere is a spherical shell, we compute an inner radius of the atmosphere best fit
|
|
22
|
+
// Since atmosphere scattering assumes the atmosphere is a spherical shell, we compute an inner radius of the atmosphere best fit\n\
|
|
33
23
|
// for the position on the ellipsoid.\n\
|
|
34
24
|
float radiusAdjust = (ellipsoidRadiiDifference / 4.0) + distanceAdjust;\n\
|
|
35
25
|
float atmosphereInnerRadius = (length(czm_viewerPositionWC) - czm_eyeHeight) - radiusAdjust;\n\
|
|
@@ -47,7 +37,7 @@ void computeAtmosphereScattering(vec3 positionWC, vec3 lightDirection, out vec3
|
|
|
47
37
|
// Check for intersection with the inner radius of the atmopshere.\n\
|
|
48
38
|
czm_raySegment primaryRayEarthIntersect = czm_raySphereIntersectionInterval(primaryRay, vec3(0.0), atmosphereInnerRadius + radiusAdjust);\n\
|
|
49
39
|
if (primaryRayEarthIntersect.start > 0.0 && primaryRayEarthIntersect.stop > 0.0) {\n\
|
|
50
|
-
|
|
40
|
+
\n\
|
|
51
41
|
// Compute position on globe.\n\
|
|
52
42
|
vec3 direction = normalize(positionWC);\n\
|
|
53
43
|
czm_ray ellipsoidRay = czm_ray(positionWC, -direction);\n\
|
|
@@ -63,7 +53,7 @@ void computeAtmosphereScattering(vec3 positionWC, vec3 lightDirection, out vec3
|
|
|
63
53
|
vec3 nearColor = vec3(0.0);\n\
|
|
64
54
|
\n\
|
|
65
55
|
rayleighColor = mix(nearColor, horizonColor, exp(-angle) * opacity);\n\
|
|
66
|
-
|
|
56
|
+
\n\
|
|
67
57
|
// Set the traslucent flag to avoid alpha adjustment in computeFinalColor funciton.\n\
|
|
68
58
|
underTranslucentGlobe = 1.0;\n\
|
|
69
59
|
return;\n\
|
|
@@ -11,8 +11,9 @@ in float v_translucent;
|
|
|
11
11
|
|
|
12
12
|
void main (void)
|
|
13
13
|
{
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
float lightEnum = u_radiiAndDynamicAtmosphereColor.z;
|
|
15
|
+
vec3 lightDirection = czm_getDynamicAtmosphereLightDirection(v_outerPositionWC, lightEnum);
|
|
16
|
+
|
|
16
17
|
vec3 mieColor;
|
|
17
18
|
vec3 rayleighColor;
|
|
18
19
|
float opacity;
|
|
@@ -42,14 +43,8 @@ void main (void)
|
|
|
42
43
|
#endif
|
|
43
44
|
|
|
44
45
|
#ifdef COLOR_CORRECT
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// Perform hsb shift
|
|
48
|
-
hsb.x += u_hsbShift.x; // hue
|
|
49
|
-
hsb.y = clamp(hsb.y + u_hsbShift.y, 0.0, 1.0); // saturation
|
|
50
|
-
hsb.z = hsb.z > czm_epsilon7 ? hsb.z + u_hsbShift.z : 0.0; // brightness
|
|
51
|
-
// Convert shifted hsb back to rgb
|
|
52
|
-
color.rgb = czm_HSBToRGB(hsb);
|
|
46
|
+
const bool ignoreBlackPixels = true;
|
|
47
|
+
color.rgb = czm_applyHSBShift(color.rgb, u_hsbShift, ignoreBlackPixels);
|
|
53
48
|
#endif
|
|
54
49
|
|
|
55
50
|
// For the parts of the sky atmosphere that are not behind a translucent globe,
|
|
@@ -12,8 +12,9 @@ in float v_translucent;\n\
|
|
|
12
12
|
\n\
|
|
13
13
|
void main (void)\n\
|
|
14
14
|
{\n\
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
float lightEnum = u_radiiAndDynamicAtmosphereColor.z;\n\
|
|
16
|
+
vec3 lightDirection = czm_getDynamicAtmosphereLightDirection(v_outerPositionWC, lightEnum);\n\
|
|
17
|
+
\n\
|
|
17
18
|
vec3 mieColor;\n\
|
|
18
19
|
vec3 rayleighColor;\n\
|
|
19
20
|
float opacity;\n\
|
|
@@ -43,14 +44,8 @@ void main (void)\n\
|
|
|
43
44
|
#endif\n\
|
|
44
45
|
\n\
|
|
45
46
|
#ifdef COLOR_CORRECT\n\
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// Perform hsb shift\n\
|
|
49
|
-
hsb.x += u_hsbShift.x; // hue\n\
|
|
50
|
-
hsb.y = clamp(hsb.y + u_hsbShift.y, 0.0, 1.0); // saturation\n\
|
|
51
|
-
hsb.z = hsb.z > czm_epsilon7 ? hsb.z + u_hsbShift.z : 0.0; // brightness\n\
|
|
52
|
-
// Convert shifted hsb back to rgb\n\
|
|
53
|
-
color.rgb = czm_HSBToRGB(hsb);\n\
|
|
47
|
+
const bool ignoreBlackPixels = true;\n\
|
|
48
|
+
color.rgb = czm_applyHSBShift(color.rgb, u_hsbShift, ignoreBlackPixels);\n\
|
|
54
49
|
#endif\n\
|
|
55
50
|
\n\
|
|
56
51
|
// For the parts of the sky atmosphere that are not behind a translucent globe,\n\
|
|
@@ -12,7 +12,8 @@ out float v_translucent;
|
|
|
12
12
|
void main(void)
|
|
13
13
|
{
|
|
14
14
|
vec4 positionWC = czm_model * position;
|
|
15
|
-
|
|
15
|
+
float lightEnum = u_radiiAndDynamicAtmosphereColor.z;
|
|
16
|
+
vec3 lightDirection = czm_getDynamicAtmosphereLightDirection(positionWC.xyz, lightEnum);
|
|
16
17
|
|
|
17
18
|
#ifndef PER_FRAGMENT_ATMOSPHERE
|
|
18
19
|
computeAtmosphereScattering(
|
|
@@ -24,7 +25,7 @@ void main(void)
|
|
|
24
25
|
v_translucent
|
|
25
26
|
);
|
|
26
27
|
#endif
|
|
27
|
-
|
|
28
|
+
|
|
28
29
|
v_outerPositionWC = positionWC.xyz;
|
|
29
30
|
gl_Position = czm_modelViewProjection * position;
|
|
30
31
|
}
|
|
@@ -13,7 +13,8 @@ out float v_translucent;\n\
|
|
|
13
13
|
void main(void)\n\
|
|
14
14
|
{\n\
|
|
15
15
|
vec4 positionWC = czm_model * position;\n\
|
|
16
|
-
|
|
16
|
+
float lightEnum = u_radiiAndDynamicAtmosphereColor.z;\n\
|
|
17
|
+
vec3 lightDirection = czm_getDynamicAtmosphereLightDirection(positionWC.xyz, lightEnum);\n\
|
|
17
18
|
\n\
|
|
18
19
|
#ifndef PER_FRAGMENT_ATMOSPHERE\n\
|
|
19
20
|
computeAtmosphereScattering(\n\
|
|
@@ -25,7 +26,7 @@ void main(void)\n\
|
|
|
25
26
|
v_translucent\n\
|
|
26
27
|
);\n\
|
|
27
28
|
#endif\n\
|
|
28
|
-
|
|
29
|
+
\n\
|
|
29
30
|
v_outerPositionWC = positionWC.xyz;\n\
|
|
30
31
|
gl_Position = czm_modelViewProjection * position;\n\
|
|
31
32
|
}\n\
|