@cesium/engine 6.2.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Build/ThirdParty/Workers/z-worker-pako.js +568 -407
- package/Build/Workers/{chunk-QRBRVGZC.js → chunk-2HJWSU7B.js} +4 -4
- package/Build/Workers/{chunk-ZQRZBHYI.js → chunk-46UD5ABS.js} +4 -4
- package/Build/Workers/{chunk-GVL5I7TC.js → chunk-4EBHOMFX.js} +17 -17
- package/Build/Workers/{chunk-CDGHUKQ4.js → chunk-5HDYHG3F.js} +13 -13
- package/Build/Workers/{chunk-CWJQGBWT.js → chunk-5M3U6ZMA.js} +1 -1
- package/Build/Workers/{chunk-Y4OJ4B23.js → chunk-5WQ523AW.js} +5 -5
- package/Build/Workers/{chunk-NE4JNU6H.js → chunk-5YLJ77FF.js} +10 -10
- package/Build/Workers/{chunk-SV7DDPAC.js → chunk-6HZQPRUS.js} +1 -1
- package/Build/Workers/{chunk-434ZTTFX.js → chunk-6VJVYK2V.js} +2 -2
- package/Build/Workers/{chunk-LGJUI2CE.js → chunk-72SANQJV.js} +5 -5
- package/Build/Workers/{chunk-QTZQZY2C.js → chunk-7XEAYGZK.js} +34 -10
- package/Build/Workers/{chunk-Z4JUBRHP.js → chunk-AIPU2VSX.js} +6 -6
- package/Build/Workers/{chunk-PZ2WJWUG.js → chunk-AR5DNBJ4.js} +6 -6
- package/Build/Workers/{chunk-BUZDZBUH.js → chunk-BZP4T2JJ.js} +10 -10
- package/Build/Workers/{chunk-Z2SIPUKB.js → chunk-DTAIXKTO.js} +6 -6
- package/Build/Workers/{chunk-HOT2SNXP.js → chunk-F6SE42BK.js} +127 -90
- package/Build/Workers/{chunk-TIXXVKUY.js → chunk-FP6GYBFX.js} +10 -10
- package/Build/Workers/{chunk-ARPTYYKS.js → chunk-GEJTYLCO.js} +5 -5
- package/Build/Workers/{chunk-XUTVA4K5.js → chunk-GV56Q4LU.js} +11 -11
- package/Build/Workers/{chunk-HPP4JLNH.js → chunk-IQBYFRVW.js} +7 -7
- package/Build/Workers/{chunk-O43GWBSF.js → chunk-IX2JCCNM.js} +1 -1
- package/Build/Workers/{chunk-H5DUXHCV.js → chunk-JCNXK6EL.js} +11 -11
- package/Build/Workers/{chunk-SQVTYRZY.js → chunk-JJ4VBOQ3.js} +4 -4
- package/Build/Workers/{chunk-RIDPF7PO.js → chunk-JXDC723O.js} +2 -2
- package/Build/Workers/{chunk-R3HUGXBH.js → chunk-JY5YEZFA.js} +8 -8
- package/Build/Workers/{chunk-GF5TNNKP.js → chunk-L2ZN645J.js} +6 -6
- package/Build/Workers/{chunk-5GDBZTHX.js → chunk-LZ7JIV3K.js} +17 -17
- package/Build/Workers/{chunk-52VSIKEA.js → chunk-LZGHD6NY.js} +15 -15
- package/Build/Workers/{chunk-RH4N2ONY.js → chunk-MY3VNFGQ.js} +7 -7
- package/Build/Workers/{chunk-MN34FIF5.js → chunk-NKPBIX7F.js} +1 -1
- package/Build/Workers/{chunk-AXFRNOVC.js → chunk-NY3K4IM3.js} +12 -12
- package/Build/Workers/{chunk-MW3CJYLX.js → chunk-ODW7WYM4.js} +2 -2
- package/Build/Workers/{chunk-R4OZKBXH.js → chunk-OVLG3FRS.js} +6 -6
- package/Build/Workers/{chunk-TMPVBFJQ.js → chunk-PNBGBETF.js} +10 -10
- package/Build/Workers/{chunk-DR5XZ6K5.js → chunk-PTQQUQC3.js} +13 -13
- package/Build/Workers/{chunk-3PW6ZBN4.js → chunk-QZAD5O7I.js} +7 -7
- package/Build/Workers/{chunk-5SK36PU4.js → chunk-R5X4OQT4.js} +7 -7
- package/Build/Workers/{chunk-DMCSY5BU.js → chunk-RAEV7K66.js} +5 -5
- package/Build/Workers/{chunk-BP467WX3.js → chunk-RV7ZYPFT.js} +4 -4
- package/Build/Workers/{chunk-5HLGKKG3.js → chunk-S4MAZ3SS.js} +2 -2
- package/Build/Workers/{chunk-LX6XV4DK.js → chunk-S6SKF6DT.js} +5 -5
- package/Build/Workers/{chunk-HUPNRBWW.js → chunk-U2VCRRQW.js} +6 -6
- package/Build/Workers/{chunk-SNN7WOC2.js → chunk-UAEW6HKG.js} +13 -13
- package/Build/Workers/{chunk-HFKSAB5K.js → chunk-UDO6BFSF.js} +13 -13
- package/Build/Workers/{chunk-YBKFS53K.js → chunk-UGK3FCDY.js} +1 -1
- package/Build/Workers/{chunk-PIXK6KHB.js → chunk-VK3EJHWI.js} +2 -2
- package/Build/Workers/{chunk-5IRLXUTA.js → chunk-VRGFV2UO.js} +7 -7
- package/Build/Workers/{chunk-JGG36SQV.js → chunk-WBQCVXR3.js} +4 -4
- package/Build/Workers/{chunk-4KP73B43.js → chunk-WZU2YLWG.js} +3 -3
- package/Build/Workers/{chunk-LGL4P5KL.js → chunk-XWXM2O2R.js} +6 -6
- package/Build/Workers/{chunk-FWGNCYP6.js → chunk-YUCVWAY6.js} +7 -7
- package/Build/Workers/{chunk-CSIZ3BGT.js → chunk-ZK5JOS3D.js} +14 -14
- package/Build/Workers/{chunk-HPH5HSFE.js → chunk-ZUA2UUNV.js} +2 -2
- package/Build/Workers/combineGeometry.js +23 -23
- package/Build/Workers/createBoxGeometry.js +17 -17
- package/Build/Workers/createBoxOutlineGeometry.js +15 -15
- package/Build/Workers/createCircleGeometry.js +25 -25
- package/Build/Workers/createCircleOutlineGeometry.js +18 -18
- package/Build/Workers/createCoplanarPolygonGeometry.js +32 -32
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +30 -30
- package/Build/Workers/createCorridorGeometry.js +28 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +27 -28
- package/Build/Workers/createCylinderGeometry.js +19 -19
- package/Build/Workers/createCylinderOutlineGeometry.js +17 -17
- package/Build/Workers/createEllipseGeometry.js +25 -25
- package/Build/Workers/createEllipseOutlineGeometry.js +18 -18
- package/Build/Workers/createEllipsoidGeometry.js +18 -18
- package/Build/Workers/createEllipsoidOutlineGeometry.js +17 -17
- package/Build/Workers/createFrustumGeometry.js +17 -17
- package/Build/Workers/createFrustumOutlineGeometry.js +17 -17
- package/Build/Workers/createGeometry.js +23 -23
- package/Build/Workers/createGroundPolylineGeometry.js +21 -21
- package/Build/Workers/createPlaneGeometry.js +15 -15
- package/Build/Workers/createPlaneOutlineGeometry.js +14 -14
- package/Build/Workers/createPolygonGeometry.js +31 -166
- package/Build/Workers/createPolygonOutlineGeometry.js +29 -29
- package/Build/Workers/createPolylineGeometry.js +24 -24
- package/Build/Workers/createPolylineVolumeGeometry.js +31 -33
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +26 -27
- package/Build/Workers/createRectangleGeometry.js +26 -26
- package/Build/Workers/createRectangleOutlineGeometry.js +19 -19
- package/Build/Workers/createSimplePolylineGeometry.js +22 -22
- package/Build/Workers/createSphereGeometry.js +18 -18
- package/Build/Workers/createSphereOutlineGeometry.js +17 -17
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
- package/Build/Workers/createVectorTileGeometries.js +23 -23
- package/Build/Workers/createVectorTilePoints.js +12 -12
- package/Build/Workers/createVectorTilePolygons.js +21 -21
- package/Build/Workers/createVectorTilePolylines.js +14 -14
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +21 -21
- package/Build/Workers/createVerticesFromHeightmap.js +21 -21
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +18 -18
- package/Build/Workers/createWallGeometry.js +23 -23
- package/Build/Workers/createWallOutlineGeometry.js +22 -22
- package/Build/Workers/decodeDraco.js +11 -11
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +9 -9
- package/Build/Workers/transcodeKTX2.js +7 -7
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +21 -21
- package/LICENSE.md +1 -1
- package/Source/Assets/approximateTerrainHeights.json +1 -1
- package/Source/Core/GregorianDate.js +85 -0
- package/Source/Core/HeadingPitchRange.js +2 -2
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/PolygonGeometry.js +0 -169
- package/Source/Core/Resource.js +30 -69
- package/Source/Core/Transforms.js +27 -18
- package/Source/Core/createWorldBathymetryAsync.js +45 -0
- package/Source/DataSources/EllipsoidGeometryUpdater.js +3 -4
- package/Source/DataSources/Entity.js +8 -5
- package/Source/DataSources/EntityCollection.js +1 -2
- package/Source/DataSources/GeometryUpdater.js +1 -2
- package/Source/DataSources/GroundGeometryUpdater.js +6 -3
- package/Source/DataSources/ModelVisualizer.js +19 -98
- package/Source/DataSources/PolygonGeometryUpdater.js +14 -2
- package/Source/DataSources/PolylineGeometryUpdater.js +9 -8
- package/Source/DataSources/TerrainOffsetProperty.js +15 -23
- package/Source/Renderer/AutomaticUniforms.js +121 -1
- package/Source/Renderer/UniformState.js +127 -0
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Atmosphere.js +127 -0
- package/Source/Scene/Billboard.js +29 -26
- package/Source/Scene/BillboardCollection.js +3 -3
- package/Source/Scene/Camera.js +1 -1
- package/Source/Scene/Cesium3DTile.js +1 -0
- package/Source/Scene/Cesium3DTileContent.js +14 -0
- package/Source/Scene/Cesium3DTileset.js +326 -45
- package/Source/Scene/Cesium3DTilesetTraversal.js +4 -0
- package/Source/Scene/Composite3DTileContent.js +42 -0
- package/Source/Scene/DynamicAtmosphereLightingType.js +56 -0
- package/Source/Scene/Empty3DTileContent.js +4 -0
- package/Source/Scene/Fog.js +1 -0
- package/Source/Scene/FrameState.js +9 -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/GltfLoader.js +15 -5
- package/Source/Scene/HeightReference.js +59 -2
- package/Source/Scene/Implicit3DTileContent.js +4 -0
- 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 +408 -0
- package/Source/Scene/Multiple3DTileContent.js +42 -0
- package/Source/Scene/QuadtreePrimitive.js +1 -1
- package/Source/Scene/Scene.js +198 -16
- package/Source/Scene/ScreenSpaceCameraController.js +2 -6
- package/Source/Scene/SkyAtmosphere.js +5 -6
- 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/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/ThirdParty/Workers/z-worker-pako.js +1 -1
- package/Source/ThirdParty/draco_decoder.wasm +0 -0
- package/index.d.ts +283 -65
- package/index.js +260 -247
- package/package.json +3 -3
- package/Build/Workers/chunk-ATB2I7OS.js +0 -55
|
@@ -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\
|
|
@@ -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;
|