@cesium/engine 6.1.1 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Build/ThirdParty/Workers/z-worker-pako.js +568 -407
- package/Build/Workers/{chunk-FRG2Z7DE.js → chunk-2HJWSU7B.js} +4 -4
- package/Build/Workers/{chunk-ZTYE74E2.js → chunk-46UD5ABS.js} +4 -4
- package/Build/Workers/{chunk-VODWDCX6.js → chunk-4EBHOMFX.js} +18 -20
- package/Build/Workers/{chunk-N7TYCDTR.js → chunk-5HDYHG3F.js} +13 -13
- package/Build/Workers/{chunk-C53JYYKX.js → chunk-5M3U6ZMA.js} +1 -1
- package/Build/Workers/{chunk-GTEXWEAP.js → chunk-5WQ523AW.js} +5 -5
- package/Build/Workers/{chunk-SEFDWMCW.js → chunk-5YLJ77FF.js} +31 -21
- package/Build/Workers/{chunk-VNRUVNIK.js → chunk-6HZQPRUS.js} +1 -1
- package/Build/Workers/{chunk-PB7BIXHI.js → chunk-6VJVYK2V.js} +2 -2
- package/Build/Workers/{chunk-PHQVHDVI.js → chunk-72SANQJV.js} +325 -5
- package/Build/Workers/{chunk-D325WRAY.js → chunk-7XEAYGZK.js} +35 -11
- package/Build/Workers/{chunk-FGUP2QEP.js → chunk-AIPU2VSX.js} +6 -6
- package/Build/Workers/{chunk-QUXSQQEF.js → chunk-AR5DNBJ4.js} +6 -6
- package/Build/Workers/{chunk-ZVUAJKAL.js → chunk-BZP4T2JJ.js} +11 -13
- package/Build/Workers/{chunk-K6Q5IRBK.js → chunk-DTAIXKTO.js} +6 -6
- package/Build/Workers/{chunk-D4YHO4NZ.js → chunk-F6SE42BK.js} +133 -101
- package/Build/Workers/{chunk-QY2WY5XJ.js → chunk-FP6GYBFX.js} +11 -11
- package/Build/Workers/{chunk-Z6LPXA7S.js → chunk-GEJTYLCO.js} +5 -5
- package/Build/Workers/{chunk-VKTKOIYG.js → chunk-GV56Q4LU.js} +11 -11
- package/Build/Workers/{chunk-KUB2HQXR.js → chunk-IQBYFRVW.js} +8 -8
- package/Build/Workers/{chunk-235MRXLH.js → chunk-IX2JCCNM.js} +1 -1
- package/Build/Workers/{chunk-3FCUUN6M.js → chunk-JCNXK6EL.js} +11 -11
- package/Build/Workers/{chunk-364TQORK.js → chunk-JJ4VBOQ3.js} +5 -7
- package/Build/Workers/{chunk-66CXKODF.js → chunk-JXDC723O.js} +2 -2
- package/Build/Workers/{chunk-OTBRPBCC.js → chunk-JY5YEZFA.js} +9 -9
- package/Build/Workers/{chunk-LSGUCCKJ.js → chunk-L2ZN645J.js} +6 -6
- package/Build/Workers/{chunk-VLDDXYKI.js → chunk-LZ7JIV3K.js} +18 -18
- package/Build/Workers/{chunk-36ESDRIZ.js → chunk-LZGHD6NY.js} +16 -16
- package/Build/Workers/{chunk-PXLFBN2Q.js → chunk-MY3VNFGQ.js} +7 -7
- package/Build/Workers/{chunk-W7F5VTH6.js → chunk-NKPBIX7F.js} +1 -1
- package/Build/Workers/{chunk-XBZSOW3F.js → chunk-NY3K4IM3.js} +12 -12
- package/Build/Workers/{chunk-AI3KSNM6.js → chunk-ODW7WYM4.js} +2 -2
- package/Build/Workers/{chunk-6PWSSCRA.js → chunk-OVLG3FRS.js} +6 -6
- package/Build/Workers/{chunk-MOLGJDJV.js → chunk-PNBGBETF.js} +11 -11
- package/Build/Workers/{chunk-T73B27DG.js → chunk-PTQQUQC3.js} +13 -13
- package/Build/Workers/{chunk-RSWBNJPT.js → chunk-QZAD5O7I.js} +8 -304
- package/Build/Workers/{chunk-I6TVJ6T7.js → chunk-R5X4OQT4.js} +8 -8
- package/Build/Workers/{chunk-DTNN3ODA.js → chunk-RAEV7K66.js} +5 -5
- package/Build/Workers/{chunk-IZED7ODV.js → chunk-RV7ZYPFT.js} +4 -4
- package/Build/Workers/{chunk-7FEGZO3D.js → chunk-S4MAZ3SS.js} +2 -2
- package/Build/Workers/{chunk-J3U6Z5YQ.js → chunk-S6SKF6DT.js} +5 -5
- package/Build/Workers/{chunk-CHDJ66UM.js → chunk-U2VCRRQW.js} +6 -6
- package/Build/Workers/{chunk-R22RQAAM.js → chunk-UAEW6HKG.js} +13 -13
- package/Build/Workers/{chunk-S7IBK36I.js → chunk-UDO6BFSF.js} +14 -16
- package/Build/Workers/{chunk-YS4KPNLC.js → chunk-UGK3FCDY.js} +1 -1
- package/Build/Workers/{chunk-SJDXMQSP.js → chunk-VK3EJHWI.js} +2 -2
- package/Build/Workers/{chunk-HEROVJML.js → chunk-VRGFV2UO.js} +7 -7
- package/Build/Workers/{chunk-VOAZN4IP.js → chunk-WBQCVXR3.js} +4 -4
- package/Build/Workers/{chunk-HSW63JN4.js → chunk-WZU2YLWG.js} +3 -3
- package/Build/Workers/{chunk-4EYB62WJ.js → chunk-XWXM2O2R.js} +6 -6
- package/Build/Workers/{chunk-ZGMOBRTG.js → chunk-YUCVWAY6.js} +7 -7
- package/Build/Workers/{chunk-CLVEIRXT.js → chunk-ZK5JOS3D.js} +15 -17
- package/Build/Workers/{chunk-5NZTU5YL.js → chunk-ZUA2UUNV.js} +2 -2
- package/Build/Workers/combineGeometry.js +23 -23
- package/Build/Workers/createBoxGeometry.js +17 -17
- package/Build/Workers/createBoxOutlineGeometry.js +15 -15
- package/Build/Workers/createCircleGeometry.js +25 -25
- package/Build/Workers/createCircleOutlineGeometry.js +18 -18
- package/Build/Workers/createCoplanarPolygonGeometry.js +33 -34
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +30 -30
- package/Build/Workers/createCorridorGeometry.js +28 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +27 -28
- package/Build/Workers/createCylinderGeometry.js +19 -19
- package/Build/Workers/createCylinderOutlineGeometry.js +18 -19
- package/Build/Workers/createEllipseGeometry.js +25 -25
- package/Build/Workers/createEllipseOutlineGeometry.js +18 -18
- package/Build/Workers/createEllipsoidGeometry.js +18 -18
- package/Build/Workers/createEllipsoidOutlineGeometry.js +17 -17
- package/Build/Workers/createFrustumGeometry.js +17 -17
- package/Build/Workers/createFrustumOutlineGeometry.js +17 -17
- package/Build/Workers/createGeometry.js +23 -23
- package/Build/Workers/createGroundPolylineGeometry.js +22 -22
- package/Build/Workers/createPlaneGeometry.js +15 -15
- package/Build/Workers/createPlaneOutlineGeometry.js +14 -14
- package/Build/Workers/createPolygonGeometry.js +32 -167
- package/Build/Workers/createPolygonOutlineGeometry.js +29 -29
- package/Build/Workers/createPolylineGeometry.js +24 -24
- package/Build/Workers/createPolylineVolumeGeometry.js +32 -35
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -29
- package/Build/Workers/createRectangleGeometry.js +27 -27
- package/Build/Workers/createRectangleOutlineGeometry.js +21 -23
- package/Build/Workers/createSimplePolylineGeometry.js +22 -22
- package/Build/Workers/createSphereGeometry.js +18 -18
- package/Build/Workers/createSphereOutlineGeometry.js +17 -17
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
- package/Build/Workers/createVectorTileGeometries.js +23 -23
- package/Build/Workers/createVectorTilePoints.js +12 -12
- package/Build/Workers/createVectorTilePolygons.js +21 -21
- package/Build/Workers/createVectorTilePolylines.js +14 -14
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
- package/Build/Workers/createVerticesFromHeightmap.js +22 -22
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +19 -19
- package/Build/Workers/createWallGeometry.js +23 -23
- package/Build/Workers/createWallOutlineGeometry.js +22 -22
- package/Build/Workers/decodeDraco.js +11 -11
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +9 -9
- package/Build/Workers/transcodeKTX2.js +7 -7
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
- package/LICENSE.md +1 -1
- package/Source/Assets/approximateTerrainHeights.json +1 -1
- package/Source/Core/Ellipsoid.js +45 -0
- package/Source/Core/GregorianDate.js +85 -0
- package/Source/Core/HeadingPitchRange.js +2 -2
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/PolygonGeometry.js +0 -169
- package/Source/Core/Quaternion.js +6 -2
- package/Source/Core/RectangleOutlineGeometry.js +2 -4
- package/Source/Core/RequestScheduler.js +3 -9
- package/Source/Core/Resource.js +30 -69
- package/Source/Core/TerrainEncoding.js +2 -2
- package/Source/Core/Transforms.js +27 -18
- package/Source/Core/VerticalExaggeration.js +69 -0
- package/Source/Core/createWorldBathymetryAsync.js +45 -0
- package/Source/DataSources/EllipsoidGeometryUpdater.js +3 -4
- package/Source/DataSources/Entity.js +8 -5
- package/Source/DataSources/EntityCollection.js +1 -2
- package/Source/DataSources/GeometryUpdater.js +1 -2
- package/Source/DataSources/GroundGeometryUpdater.js +6 -3
- package/Source/DataSources/ModelVisualizer.js +19 -98
- package/Source/DataSources/PolygonGeometryUpdater.js +14 -2
- package/Source/DataSources/PolylineGeometryUpdater.js +9 -8
- package/Source/DataSources/TerrainOffsetProperty.js +15 -23
- package/Source/Renderer/AutomaticUniforms.js +173 -0
- package/Source/Renderer/UniformState.js +246 -1
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Atmosphere.js +127 -0
- package/Source/Scene/Billboard.js +29 -26
- package/Source/Scene/BillboardCollection.js +3 -3
- package/Source/Scene/Camera.js +1 -1
- package/Source/Scene/Cesium3DTile.js +123 -10
- package/Source/Scene/Cesium3DTileContent.js +14 -0
- package/Source/Scene/Cesium3DTileset.js +326 -45
- package/Source/Scene/Cesium3DTilesetTraversal.js +4 -0
- package/Source/Scene/Composite3DTileContent.js +42 -0
- package/Source/Scene/DynamicAtmosphereLightingType.js +56 -0
- package/Source/Scene/Empty3DTileContent.js +4 -0
- package/Source/Scene/Fog.js +1 -0
- package/Source/Scene/FrameState.js +13 -5
- package/Source/Scene/Geometry3DTileContent.js +4 -0
- package/Source/Scene/Globe.js +69 -21
- package/Source/Scene/GlobeSurfaceTile.js +4 -4
- package/Source/Scene/GlobeSurfaceTileProvider.js +24 -22
- package/Source/Scene/GltfLoader.js +15 -5
- package/Source/Scene/GroundPrimitive.js +5 -5
- package/Source/Scene/HeightReference.js +59 -2
- package/Source/Scene/ImageryLayer.js +3 -3
- package/Source/Scene/Implicit3DTileContent.js +4 -0
- package/Source/Scene/LabelCollection.js +2 -2
- package/Source/Scene/MapboxImageryProvider.js +2 -2
- package/Source/Scene/Megatexture.js +1 -1
- package/Source/Scene/Model/AtmospherePipelineStage.js +59 -0
- package/Source/Scene/Model/B3dmLoader.js +4 -0
- package/Source/Scene/Model/FeatureIdPipelineStage.js +25 -2
- package/Source/Scene/Model/I3dmLoader.js +4 -0
- package/Source/Scene/Model/InstancingPipelineStage.js +24 -6
- package/Source/Scene/Model/MetadataPipelineStage.js +31 -3
- package/Source/Scene/Model/Model.js +93 -32
- package/Source/Scene/Model/Model3DTileContent.js +31 -0
- package/Source/Scene/Model/ModelAnimationChannel.js +16 -15
- package/Source/Scene/Model/ModelRuntimePrimitive.js +6 -0
- package/Source/Scene/Model/ModelSceneGraph.js +6 -0
- package/Source/Scene/Model/VerticalExaggerationPipelineStage.js +60 -0
- package/Source/Scene/Model/pickModel.js +408 -0
- package/Source/Scene/Multiple3DTileContent.js +42 -0
- package/Source/Scene/QuadtreePrimitive.js +1 -1
- package/Source/Scene/Scene.js +226 -19
- package/Source/Scene/ScreenSpaceCameraController.js +14 -25
- package/Source/Scene/SkyAtmosphere.js +5 -6
- package/Source/Scene/Terrain.js +49 -0
- package/Source/Scene/TerrainFillMesh.js +2 -2
- package/Source/Scene/TileBoundingS2Cell.js +2 -2
- package/Source/Scene/TileOrientedBoundingBox.js +1 -1
- package/Source/Scene/Tileset3DTileContent.js +4 -0
- package/Source/Scene/Vector3DTileContent.js +4 -0
- package/Source/Scene/VoxelPrimitive.js +73 -2
- package/Source/Shaders/AtmosphereCommon.glsl +3 -11
- package/Source/Shaders/AtmosphereCommon.js +3 -11
- package/Source/Shaders/Builtin/CzmBuiltins.js +12 -0
- package/Source/Shaders/Builtin/Functions/applyHSBShift.glsl +32 -0
- package/Source/Shaders/Builtin/Functions/applyHSBShift.js +34 -0
- package/Source/Shaders/Builtin/Functions/approximateTanh.glsl +10 -0
- package/Source/Shaders/Builtin/Functions/approximateTanh.js +12 -0
- package/Source/Shaders/Builtin/Functions/computeAtmosphereColor.glsl +44 -0
- package/Source/Shaders/Builtin/Functions/computeAtmosphereColor.js +46 -0
- package/Source/Shaders/Builtin/Functions/computeGroundAtmosphereScattering.glsl +30 -0
- package/Source/Shaders/Builtin/Functions/computeGroundAtmosphereScattering.js +32 -0
- package/Source/Shaders/Builtin/Functions/computeScattering.glsl +150 -0
- package/Source/Shaders/Builtin/Functions/computeScattering.js +152 -0
- package/Source/Shaders/Builtin/Functions/getDynamicAtmosphereLightDirection.glsl +22 -0
- package/Source/Shaders/Builtin/Functions/getDynamicAtmosphereLightDirection.js +24 -0
- package/Source/Shaders/Builtin/Functions/translateRelativeToEye.glsl +5 -0
- package/Source/Shaders/Builtin/Functions/translateRelativeToEye.js +5 -0
- package/Source/Shaders/GlobeFS.glsl +16 -25
- package/Source/Shaders/GlobeFS.js +16 -25
- package/Source/Shaders/GlobeVS.glsl +4 -4
- package/Source/Shaders/GlobeVS.js +4 -4
- package/Source/Shaders/Model/AtmosphereStageFS.glsl +111 -0
- package/Source/Shaders/Model/AtmosphereStageFS.js +113 -0
- package/Source/Shaders/Model/AtmosphereStageVS.glsl +12 -0
- package/Source/Shaders/Model/AtmosphereStageVS.js +14 -0
- package/Source/Shaders/Model/GeometryStageFS.glsl +1 -1
- package/Source/Shaders/Model/GeometryStageFS.js +1 -1
- package/Source/Shaders/Model/GeometryStageVS.glsl +4 -4
- package/Source/Shaders/Model/GeometryStageVS.js +4 -4
- package/Source/Shaders/Model/ModelColorStageFS.glsl +1 -1
- package/Source/Shaders/Model/ModelColorStageFS.js +2 -1
- package/Source/Shaders/Model/ModelFS.glsl +4 -0
- package/Source/Shaders/Model/ModelFS.js +4 -0
- package/Source/Shaders/Model/ModelVS.glsl +13 -4
- package/Source/Shaders/Model/ModelVS.js +13 -4
- package/Source/Shaders/Model/VerticalExaggerationStageVS.glsl +39 -0
- package/Source/Shaders/Model/VerticalExaggerationStageVS.js +41 -0
- package/Source/Shaders/SkyAtmosphereCommon.glsl +3 -13
- package/Source/Shaders/SkyAtmosphereCommon.js +3 -13
- package/Source/Shaders/SkyAtmosphereFS.glsl +5 -10
- package/Source/Shaders/SkyAtmosphereFS.js +5 -10
- package/Source/Shaders/SkyAtmosphereVS.glsl +3 -2
- package/Source/Shaders/SkyAtmosphereVS.js +3 -2
- package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
- package/Source/ThirdParty/draco_decoder.wasm +0 -0
- package/index.d.ts +318 -83
- package/index.js +77 -62
- package/package.json +3 -3
- package/Build/Workers/chunk-7ONRI7T4.js +0 -55
- package/Source/Core/TerrainExaggeration.js +0 -49
|
@@ -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;
|
|
@@ -93,6 +93,10 @@ void main()
|
|
|
93
93
|
MetadataStatistics metadataStatistics;
|
|
94
94
|
metadataStage(metadata, metadataClass, metadataStatistics, attributes);
|
|
95
95
|
|
|
96
|
+
#ifdef HAS_VERTICAL_EXAGGERATION
|
|
97
|
+
verticalExaggerationStage(attributes);
|
|
98
|
+
#endif
|
|
99
|
+
|
|
96
100
|
#ifdef HAS_CUSTOM_VERTEX_SHADER
|
|
97
101
|
czm_modelVertexOutput vsOutput = defaultVertexOutput(attributes.positionMC);
|
|
98
102
|
customShaderStage(vsOutput, attributes, featureIds, metadata, metadataClass, metadataStatistics);
|
|
@@ -100,7 +104,12 @@ void main()
|
|
|
100
104
|
|
|
101
105
|
// Compute the final position in each coordinate system needed.
|
|
102
106
|
// This returns the value that will be assigned to gl_Position.
|
|
103
|
-
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
|
|
104
113
|
|
|
105
114
|
#ifdef HAS_SILHOUETTE
|
|
106
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\
|
|
@@ -93,6 +93,10 @@ void main() \n\
|
|
|
93
93
|
MetadataClass metadataClass;\n\
|
|
94
94
|
MetadataStatistics metadataStatistics;\n\
|
|
95
95
|
metadataStage(metadata, metadataClass, metadataStatistics, attributes);\n\
|
|
96
|
+
\n\
|
|
97
|
+
#ifdef HAS_VERTICAL_EXAGGERATION\n\
|
|
98
|
+
verticalExaggerationStage(attributes);\n\
|
|
99
|
+
#endif\n\
|
|
96
100
|
\n\
|
|
97
101
|
#ifdef HAS_CUSTOM_VERTEX_SHADER\n\
|
|
98
102
|
czm_modelVertexOutput vsOutput = defaultVertexOutput(attributes.positionMC);\n\
|
|
@@ -101,7 +105,12 @@ void main() \n\
|
|
|
101
105
|
\n\
|
|
102
106
|
// Compute the final position in each coordinate system needed.\n\
|
|
103
107
|
// This returns the value that will be assigned to gl_Position.\n\
|
|
104
|
-
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\
|
|
105
114
|
\n\
|
|
106
115
|
#ifdef HAS_SILHOUETTE\n\
|
|
107
116
|
silhouetteStage(attributes, positionClip);\n\
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
void verticalExaggerationStage(
|
|
2
|
+
inout ProcessedAttributes attributes
|
|
3
|
+
) {
|
|
4
|
+
// Compute the distance from the camera to the local center of curvature.
|
|
5
|
+
vec4 vertexPositionENU = czm_modelToEnu * vec4(attributes.positionMC, 1.0);
|
|
6
|
+
vec2 vertexAzimuth = normalize(vertexPositionENU.xy);
|
|
7
|
+
// Curvature = 1 / radius of curvature.
|
|
8
|
+
float azimuthalCurvature = dot(vertexAzimuth * vertexAzimuth, czm_eyeEllipsoidCurvature);
|
|
9
|
+
float eyeToCenter = 1.0 / azimuthalCurvature + czm_eyeHeight;
|
|
10
|
+
|
|
11
|
+
// Compute the approximate ellipsoid normal at the vertex position.
|
|
12
|
+
// Uses a circular approximation for the Earth curvature along the geodesic.
|
|
13
|
+
vec3 vertexPositionEC = (czm_modelView * vec4(attributes.positionMC, 1.0)).xyz;
|
|
14
|
+
vec3 centerToVertex = eyeToCenter * czm_eyeEllipsoidNormalEC + vertexPositionEC;
|
|
15
|
+
vec3 vertexNormal = normalize(centerToVertex);
|
|
16
|
+
|
|
17
|
+
// Estimate the (sine of the) angle between the camera direction and the vertex normal
|
|
18
|
+
float verticalDistance = dot(vertexPositionEC, czm_eyeEllipsoidNormalEC);
|
|
19
|
+
float horizontalDistance = length(vertexPositionEC - verticalDistance * czm_eyeEllipsoidNormalEC);
|
|
20
|
+
float sinTheta = horizontalDistance / (eyeToCenter + verticalDistance);
|
|
21
|
+
bool isSmallAngle = clamp(sinTheta, 0.0, 0.05) == sinTheta;
|
|
22
|
+
|
|
23
|
+
// Approximate the change in height above the ellipsoid, from camera to vertex position.
|
|
24
|
+
float exactVersine = 1.0 - dot(czm_eyeEllipsoidNormalEC, vertexNormal);
|
|
25
|
+
float smallAngleVersine = 0.5 * sinTheta * sinTheta;
|
|
26
|
+
float versine = isSmallAngle ? smallAngleVersine : exactVersine;
|
|
27
|
+
float dHeight = dot(vertexPositionEC, vertexNormal) - eyeToCenter * versine;
|
|
28
|
+
float vertexHeight = czm_eyeHeight + dHeight;
|
|
29
|
+
|
|
30
|
+
// Transform the approximate vertex normal to model coordinates.
|
|
31
|
+
vec3 vertexNormalMC = (czm_inverseModelView * vec4(vertexNormal, 0.0)).xyz;
|
|
32
|
+
vertexNormalMC = normalize(vertexNormalMC);
|
|
33
|
+
|
|
34
|
+
// Compute the exaggeration and apply it along the approximate vertex normal.
|
|
35
|
+
float stretch = u_verticalExaggerationAndRelativeHeight.x;
|
|
36
|
+
float shift = u_verticalExaggerationAndRelativeHeight.y;
|
|
37
|
+
float exaggeration = (vertexHeight - shift) * (stretch - 1.0);
|
|
38
|
+
attributes.positionMC += exaggeration * vertexNormalMC;
|
|
39
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
+
export default "void verticalExaggerationStage(\n\
|
|
3
|
+
inout ProcessedAttributes attributes\n\
|
|
4
|
+
) {\n\
|
|
5
|
+
// Compute the distance from the camera to the local center of curvature.\n\
|
|
6
|
+
vec4 vertexPositionENU = czm_modelToEnu * vec4(attributes.positionMC, 1.0);\n\
|
|
7
|
+
vec2 vertexAzimuth = normalize(vertexPositionENU.xy);\n\
|
|
8
|
+
// Curvature = 1 / radius of curvature.\n\
|
|
9
|
+
float azimuthalCurvature = dot(vertexAzimuth * vertexAzimuth, czm_eyeEllipsoidCurvature);\n\
|
|
10
|
+
float eyeToCenter = 1.0 / azimuthalCurvature + czm_eyeHeight;\n\
|
|
11
|
+
\n\
|
|
12
|
+
// Compute the approximate ellipsoid normal at the vertex position.\n\
|
|
13
|
+
// Uses a circular approximation for the Earth curvature along the geodesic.\n\
|
|
14
|
+
vec3 vertexPositionEC = (czm_modelView * vec4(attributes.positionMC, 1.0)).xyz;\n\
|
|
15
|
+
vec3 centerToVertex = eyeToCenter * czm_eyeEllipsoidNormalEC + vertexPositionEC;\n\
|
|
16
|
+
vec3 vertexNormal = normalize(centerToVertex);\n\
|
|
17
|
+
\n\
|
|
18
|
+
// Estimate the (sine of the) angle between the camera direction and the vertex normal\n\
|
|
19
|
+
float verticalDistance = dot(vertexPositionEC, czm_eyeEllipsoidNormalEC);\n\
|
|
20
|
+
float horizontalDistance = length(vertexPositionEC - verticalDistance * czm_eyeEllipsoidNormalEC);\n\
|
|
21
|
+
float sinTheta = horizontalDistance / (eyeToCenter + verticalDistance);\n\
|
|
22
|
+
bool isSmallAngle = clamp(sinTheta, 0.0, 0.05) == sinTheta;\n\
|
|
23
|
+
\n\
|
|
24
|
+
// Approximate the change in height above the ellipsoid, from camera to vertex position.\n\
|
|
25
|
+
float exactVersine = 1.0 - dot(czm_eyeEllipsoidNormalEC, vertexNormal);\n\
|
|
26
|
+
float smallAngleVersine = 0.5 * sinTheta * sinTheta;\n\
|
|
27
|
+
float versine = isSmallAngle ? smallAngleVersine : exactVersine;\n\
|
|
28
|
+
float dHeight = dot(vertexPositionEC, vertexNormal) - eyeToCenter * versine;\n\
|
|
29
|
+
float vertexHeight = czm_eyeHeight + dHeight;\n\
|
|
30
|
+
\n\
|
|
31
|
+
// Transform the approximate vertex normal to model coordinates.\n\
|
|
32
|
+
vec3 vertexNormalMC = (czm_inverseModelView * vec4(vertexNormal, 0.0)).xyz;\n\
|
|
33
|
+
vertexNormalMC = normalize(vertexNormalMC);\n\
|
|
34
|
+
\n\
|
|
35
|
+
// Compute the exaggeration and apply it along the approximate vertex normal.\n\
|
|
36
|
+
float stretch = u_verticalExaggerationAndRelativeHeight.x;\n\
|
|
37
|
+
float shift = u_verticalExaggerationAndRelativeHeight.y;\n\
|
|
38
|
+
float exaggeration = (vertexHeight - shift) * (stretch - 1.0);\n\
|
|
39
|
+
attributes.positionMC += exaggeration * vertexNormalMC;\n\
|
|
40
|
+
}\n\
|
|
41
|
+
";
|
|
@@ -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\
|