@cesium/engine 11.1.0 → 12.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/Workers/{chunk-MXIZJAPH.js → chunk-2B5H7KIN.js} +1 -1
- package/Build/Workers/{chunk-DI5NGJUP.js → chunk-2RHMHHJH.js} +2 -2
- package/Build/Workers/{chunk-E6V6SQZW.js → chunk-3OHDXGFC.js} +6 -6
- package/Build/Workers/{chunk-GESF4OXQ.js → chunk-3OM5QZSI.js} +2 -2
- package/Build/Workers/{chunk-E63IIM5T.js → chunk-3UJV3W4Y.js} +1 -1
- package/Build/Workers/{chunk-O3E4OAOE.js → chunk-3X2LXRHU.js} +13 -13
- package/Build/Workers/{chunk-CKY7HOHV.js → chunk-4ESQ3DN2.js} +9 -9
- package/Build/Workers/{chunk-BHQJ2NT7.js → chunk-4IQPX22D.js} +6 -6
- package/Build/Workers/{chunk-JW4FOI6M.js → chunk-4XPGN5Y7.js} +11 -11
- package/Build/Workers/{chunk-DHYHSFFJ.js → chunk-56LALJCU.js} +2 -2
- package/Build/Workers/{chunk-YZ733KKS.js → chunk-5FSKL7US.js} +12 -12
- package/Build/Workers/{chunk-3Q2L65QU.js → chunk-5YKJKOFE.js} +7 -7
- package/Build/Workers/{chunk-GWCFU2SA.js → chunk-62YGXNGC.js} +7 -7
- package/Build/Workers/{chunk-M3GMB5OP.js → chunk-6DYMJ57Z.js} +10 -10
- package/Build/Workers/{chunk-IBLIYJZR.js → chunk-7DSVCRFD.js} +6 -6
- package/Build/Workers/{chunk-5PTXS2GO.js → chunk-7OISMGQF.js} +7 -7
- package/Build/Workers/{chunk-2ZGOQXYU.js → chunk-AL7BHP36.js} +6 -6
- package/Build/Workers/{chunk-TGONEMZO.js → chunk-AOCENJVH.js} +11 -11
- package/Build/Workers/{chunk-472HQ3EH.js → chunk-ARTM66DL.js} +5 -5
- package/Build/Workers/{chunk-K4GQUNB5.js → chunk-B4AZL6Q4.js} +5 -5
- package/Build/Workers/{chunk-GNBFYG7F.js → chunk-BQNTN4CC.js} +13 -13
- package/Build/Workers/{chunk-GGZJN2TI.js → chunk-C4IAULHW.js} +15 -15
- package/Build/Workers/{chunk-7BMOHCPM.js → chunk-ES6Q5HWK.js} +13 -13
- package/Build/Workers/{chunk-PGRPDNHG.js → chunk-GKBICLGC.js} +17 -17
- package/Build/Workers/{chunk-C6YYBQXW.js → chunk-GMGUR5GM.js} +4 -4
- package/Build/Workers/{chunk-FDOV2LBJ.js → chunk-GUW6BS72.js} +7 -7
- package/Build/Workers/{chunk-U72QNFOJ.js → chunk-GYHHNFW5.js} +10 -10
- package/Build/Workers/{chunk-YSGTGQQO.js → chunk-GZG526CC.js} +14 -14
- package/Build/Workers/{chunk-5ODQSF26.js → chunk-HILBDZUP.js} +2 -2
- package/Build/Workers/{chunk-TKVT5GQM.js → chunk-HYUTWUXN.js} +13 -13
- package/Build/Workers/{chunk-XY4BATBS.js → chunk-IL6SMMDD.js} +4 -4
- package/Build/Workers/{chunk-6CHGCNMW.js → chunk-IT6AWHFV.js} +2 -2
- package/Build/Workers/{chunk-7O373FFS.js → chunk-J64XIF5C.js} +8 -8
- package/Build/Workers/{chunk-I2ITFFPX.js → chunk-JGGZ3H4W.js} +1 -1
- package/Build/Workers/{chunk-26GA3JAM.js → chunk-JRULXFCC.js} +5 -5
- package/Build/Workers/{chunk-27HUZ7SA.js → chunk-MSY2AAW2.js} +4 -4
- package/Build/Workers/{chunk-SMDOP47J.js → chunk-QXBRZZQS.js} +10 -10
- package/Build/Workers/{chunk-5OOFQLKF.js → chunk-SXJ37VUC.js} +7 -7
- package/Build/Workers/{chunk-AD63PIY6.js → chunk-T6FZFMTF.js} +2 -2
- package/Build/Workers/{chunk-VU2MNO7L.js → chunk-TQK4D4AR.js} +7 -7
- package/Build/Workers/{chunk-E27BLMDD.js → chunk-US3L7FXC.js} +6 -6
- package/Build/Workers/{chunk-N5KJGGCM.js → chunk-VGT4ONMC.js} +17 -17
- package/Build/Workers/{chunk-PRGYLLJT.js → chunk-VJVTWBXB.js} +1 -1
- package/Build/Workers/{chunk-EJZTDTUH.js → chunk-VQZNBD3T.js} +4 -4
- package/Build/Workers/{chunk-NGPPMXRM.js → chunk-VUCVRDLD.js} +7 -7
- package/Build/Workers/{chunk-YFXQECWV.js → chunk-W2Q2F7JS.js} +5 -5
- package/Build/Workers/{chunk-VJZB3WAV.js → chunk-WQCX7U65.js} +7 -7
- package/Build/Workers/{chunk-7JO7GPJN.js → chunk-WW5RTJ72.js} +1 -1
- package/Build/Workers/{chunk-76BYBWHP.js → chunk-X67KKHI7.js} +4 -4
- package/Build/Workers/{chunk-7KTQP4VB.js → chunk-X7VRF25X.js} +5 -5
- package/Build/Workers/{chunk-S6MRMMQU.js → chunk-YANQEHO5.js} +6 -6
- package/Build/Workers/{chunk-FIGIZHAQ.js → chunk-ZZNBFQL5.js} +11 -11
- package/Build/Workers/combineGeometry.js +22 -22
- package/Build/Workers/createBoxGeometry.js +16 -16
- package/Build/Workers/createBoxOutlineGeometry.js +14 -14
- package/Build/Workers/createCircleGeometry.js +24 -24
- package/Build/Workers/createCircleOutlineGeometry.js +17 -17
- package/Build/Workers/createCoplanarPolygonGeometry.js +31 -31
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +29 -29
- package/Build/Workers/createCorridorGeometry.js +27 -27
- package/Build/Workers/createCorridorOutlineGeometry.js +26 -26
- package/Build/Workers/createCylinderGeometry.js +18 -18
- package/Build/Workers/createCylinderOutlineGeometry.js +16 -16
- package/Build/Workers/createEllipseGeometry.js +24 -24
- package/Build/Workers/createEllipseOutlineGeometry.js +17 -17
- package/Build/Workers/createEllipsoidGeometry.js +17 -17
- package/Build/Workers/createEllipsoidOutlineGeometry.js +16 -16
- package/Build/Workers/createFrustumGeometry.js +16 -16
- package/Build/Workers/createFrustumOutlineGeometry.js +16 -16
- package/Build/Workers/createGeometry.js +22 -22
- package/Build/Workers/createGroundPolylineGeometry.js +20 -20
- package/Build/Workers/createPlaneGeometry.js +14 -14
- package/Build/Workers/createPlaneOutlineGeometry.js +13 -13
- package/Build/Workers/createPolygonGeometry.js +30 -30
- package/Build/Workers/createPolygonOutlineGeometry.js +28 -28
- package/Build/Workers/createPolylineGeometry.js +23 -23
- package/Build/Workers/createPolylineVolumeGeometry.js +29 -29
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +25 -25
- package/Build/Workers/createRectangleGeometry.js +25 -25
- package/Build/Workers/createRectangleOutlineGeometry.js +18 -18
- package/Build/Workers/createSimplePolylineGeometry.js +21 -21
- package/Build/Workers/createSphereGeometry.js +17 -17
- package/Build/Workers/createSphereOutlineGeometry.js +16 -16
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +13 -13
- package/Build/Workers/createVectorTileGeometries.js +22 -22
- package/Build/Workers/createVectorTilePoints.js +12 -12
- package/Build/Workers/createVectorTilePolygons.js +20 -20
- package/Build/Workers/createVectorTilePolylines.js +13 -13
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +20 -20
- package/Build/Workers/createVerticesFromHeightmap.js +20 -20
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +17 -17
- package/Build/Workers/createWallGeometry.js +22 -22
- package/Build/Workers/createWallOutlineGeometry.js +21 -21
- package/Build/Workers/decodeDraco.js +11 -11
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +10 -10
- package/Build/Workers/transcodeKTX2.js +7 -7
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +20 -20
- package/Source/Core/BoundingSphere.js +1 -1
- package/Source/Core/Color.js +1 -1
- package/Source/Core/CorridorGeometryLibrary.js +4 -4
- package/Source/Core/EllipseGeometry.js +1 -1
- package/Source/Core/EllipsoidGeodesic.js +1 -1
- package/Source/Core/FrustumGeometry.js +1 -1
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/Math.js +2 -0
- package/Source/Core/PolylineVolumeGeometryLibrary.js +2 -2
- package/Source/Core/decodeGoogleEarthEnterpriseData.js +1 -1
- package/Source/DataSources/DataSourceDisplay.js +1 -1
- package/Source/DataSources/ModelGraphics.js +1 -0
- package/Source/Renderer/AutomaticUniforms.js +13 -0
- package/Source/Renderer/CubeMap.js +89 -12
- package/Source/Renderer/CubeMapFace.js +90 -13
- package/Source/Renderer/UniformState.js +13 -0
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Atmosphere.js +22 -0
- package/Source/Scene/BingMapsImageryProvider.js +1 -1
- package/Source/Scene/Cesium3DTileset.js +39 -0
- package/Source/Scene/DynamicEnvironmentMapManager.js +852 -0
- package/Source/Scene/Fog.js +75 -82
- package/Source/Scene/FrameState.js +5 -3
- package/Source/Scene/ImageBasedLighting.js +7 -64
- package/Source/Scene/Model/AtmospherePipelineStage.js +10 -5
- package/Source/Scene/Model/ImageBasedLightingPipelineStage.js +43 -21
- package/Source/Scene/Model/Model.js +98 -25
- package/Source/Scene/Model/Model3DTileContent.js +5 -0
- package/Source/Scene/Model/ModelSceneGraph.js +1 -0
- package/Source/Scene/ScreenSpaceCameraController.js +20 -1
- package/Source/Shaders/Builtin/Functions/computeAtmosphereColor.glsl +44 -0
- package/Source/Shaders/Builtin/Functions/computeAtmosphereColor.js +44 -0
- package/Source/Shaders/Builtin/Functions/computeScattering.glsl +0 -1
- package/Source/Shaders/Builtin/Functions/computeScattering.js +0 -1
- package/Source/Shaders/Builtin/Functions/sphericalHarmonics.glsl +3 -1
- package/Source/Shaders/Builtin/Functions/sphericalHarmonics.js +3 -1
- package/Source/Shaders/ComputeIrradianceFS.glsl +103 -0
- package/Source/Shaders/ComputeIrradianceFS.js +105 -0
- package/Source/Shaders/ComputeRadianceMapFS.glsl +107 -0
- package/Source/Shaders/ComputeRadianceMapFS.js +109 -0
- package/Source/Shaders/ConvolveSpecularMapFS.glsl +70 -0
- package/Source/Shaders/ConvolveSpecularMapFS.js +72 -0
- package/Source/Shaders/ConvolveSpecularMapVS.glsl +24 -0
- package/Source/Shaders/ConvolveSpecularMapVS.js +26 -0
- package/Source/Shaders/GlobeFS.glsl +1 -2
- package/Source/Shaders/GlobeFS.js +1 -2
- package/Source/Shaders/Model/AtmosphereStageFS.glsl +1 -4
- package/Source/Shaders/Model/AtmosphereStageFS.js +1 -4
- package/Source/Shaders/Model/ImageBasedLightingStageFS.glsl +2 -155
- package/Source/Shaders/Model/ImageBasedLightingStageFS.js +3 -156
- package/Source/Shaders/Model/LightingStageFS.glsl +3 -22
- package/Source/Shaders/Model/LightingStageFS.js +3 -22
- package/Source/Shaders/SkyBoxVS.glsl +0 -1
- package/Source/Shaders/SkyBoxVS.js +0 -1
- package/Source/Widget/CesiumWidget.js +776 -1
- package/Source/Workers/decodeGoogleEarthEnterprisePacket.js +1 -1
- package/index.d.ts +266 -12
- package/index.js +15 -10
- package/package.json +2 -2
package/Source/Scene/Fog.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Cartesian3 from "../Core/Cartesian3.js";
|
|
2
2
|
import defined from "../Core/defined.js";
|
|
3
|
+
import DeveloperError from "../Core/DeveloperError.js";
|
|
3
4
|
import CesiumMath from "../Core/Math.js";
|
|
4
5
|
import SceneMode from "./SceneMode.js";
|
|
5
6
|
|
|
@@ -7,6 +8,8 @@ import SceneMode from "./SceneMode.js";
|
|
|
7
8
|
* Blends the atmosphere to geometry far from the camera for horizon views. Allows for additional
|
|
8
9
|
* performance improvements by rendering less geometry and dispatching less terrain requests.
|
|
9
10
|
*
|
|
11
|
+
* @demo {@link https://sandcastle.cesium.com/index.html?src=Fog.html|Cesium Sandcastle Fog Demo}
|
|
12
|
+
*
|
|
10
13
|
* @alias Fog
|
|
11
14
|
* @constructor
|
|
12
15
|
*/
|
|
@@ -15,6 +18,9 @@ function Fog() {
|
|
|
15
18
|
* <code>true</code> if fog is enabled, <code>false</code> otherwise.
|
|
16
19
|
* @type {boolean}
|
|
17
20
|
* @default true
|
|
21
|
+
* @example
|
|
22
|
+
* // Disable fog in the scene
|
|
23
|
+
* viewer.scene.fog.enabled = false;
|
|
18
24
|
*/
|
|
19
25
|
this.enabled = true;
|
|
20
26
|
/**
|
|
@@ -22,6 +28,10 @@ function Fog() {
|
|
|
22
28
|
* This allows to benefits from optimized tile loading strategy based on fog density without the actual visual rendering.
|
|
23
29
|
* @type {boolean}
|
|
24
30
|
* @default true
|
|
31
|
+
* @example
|
|
32
|
+
* // Use fog culling but don't render it
|
|
33
|
+
* viewer.scene.fog.enabled = true;
|
|
34
|
+
* viewer.scene.fog.renderable = false;
|
|
25
35
|
*/
|
|
26
36
|
this.renderable = true;
|
|
27
37
|
/**
|
|
@@ -31,9 +41,36 @@ function Fog() {
|
|
|
31
41
|
* 1000.0m above the ellipsoid, increasing the value to 3.0e-3 will cause many tiles close to the viewer be culled.
|
|
32
42
|
* Decreasing the value will push the fog further from the viewer, but decrease performance as more of the terrain is rendered.
|
|
33
43
|
* @type {number}
|
|
34
|
-
* @default
|
|
44
|
+
* @default 0.0006
|
|
45
|
+
* @example
|
|
46
|
+
* // Double the default fog density
|
|
47
|
+
* viewer.scene.fog.density = 0.0012;
|
|
48
|
+
*/
|
|
49
|
+
this.density = 0.0006;
|
|
50
|
+
/**
|
|
51
|
+
* A scalar used in the function to adjust density based on the height of the camera above the terrain.
|
|
52
|
+
* @type {number}
|
|
53
|
+
* @default 0.001
|
|
35
54
|
*/
|
|
36
|
-
this.
|
|
55
|
+
this.heightScalar = 0.001;
|
|
56
|
+
this._heightFalloff = 0.59;
|
|
57
|
+
/**
|
|
58
|
+
* The maximum height fog is applied. If the camera is above this height fog will be disabled.
|
|
59
|
+
* @type {number}
|
|
60
|
+
* @default 800000.0
|
|
61
|
+
*/
|
|
62
|
+
this.maxHeight = 800000.0;
|
|
63
|
+
/**
|
|
64
|
+
* A scalar that impacts the visual density of fog. This value does not impact the culling of terrain.
|
|
65
|
+
* Use in combination with the {@link Fog.density} to make fog appear more or less dense.
|
|
66
|
+
* @type {number}
|
|
67
|
+
* @default 0.15
|
|
68
|
+
* @experimental The value of this scalar may not be final and is subject to change.
|
|
69
|
+
* @example
|
|
70
|
+
* // Increase fog appearance effect
|
|
71
|
+
* viewer.scene.fog.visualDensityScalar = 0.6;
|
|
72
|
+
*/
|
|
73
|
+
this.visualDensityScalar = 0.15;
|
|
37
74
|
/**
|
|
38
75
|
* A factor used to increase the screen space error of terrain tiles when they are partially in fog. The effect is to reduce
|
|
39
76
|
* the number of terrain tiles requested for rendering. If set to zero, the feature will be disabled. If the value is increased
|
|
@@ -52,76 +89,36 @@ function Fog() {
|
|
|
52
89
|
this.minimumBrightness = 0.03;
|
|
53
90
|
}
|
|
54
91
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
let tableLastIndex = 0;
|
|
81
|
-
|
|
82
|
-
function findInterval(height) {
|
|
83
|
-
const heights = heightsTable;
|
|
84
|
-
const length = heights.length;
|
|
85
|
-
|
|
86
|
-
if (height < heights[0]) {
|
|
87
|
-
tableLastIndex = 0;
|
|
88
|
-
return tableLastIndex;
|
|
89
|
-
} else if (height > heights[length - 1]) {
|
|
90
|
-
tableLastIndex = length - 2;
|
|
91
|
-
return tableLastIndex;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Take advantage of temporal coherence by checking current, next and previous intervals
|
|
95
|
-
// for containment of time.
|
|
96
|
-
if (height >= heights[tableLastIndex]) {
|
|
97
|
-
if (tableLastIndex + 1 < length && height < heights[tableLastIndex + 1]) {
|
|
98
|
-
return tableLastIndex;
|
|
99
|
-
} else if (
|
|
100
|
-
tableLastIndex + 2 < length &&
|
|
101
|
-
height < heights[tableLastIndex + 2]
|
|
102
|
-
) {
|
|
103
|
-
++tableLastIndex;
|
|
104
|
-
return tableLastIndex;
|
|
105
|
-
}
|
|
106
|
-
} else if (tableLastIndex - 1 >= 0 && height >= heights[tableLastIndex - 1]) {
|
|
107
|
-
--tableLastIndex;
|
|
108
|
-
return tableLastIndex;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// The above failed so do a linear search.
|
|
112
|
-
let i;
|
|
113
|
-
for (i = 0; i < length - 2; ++i) {
|
|
114
|
-
if (height >= heights[i] && height < heights[i + 1]) {
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
tableLastIndex = i;
|
|
120
|
-
return tableLastIndex;
|
|
121
|
-
}
|
|
92
|
+
Object.defineProperties(Fog.prototype, {
|
|
93
|
+
/**
|
|
94
|
+
* Exponent factor used in the function to adjust how density changes based on the height of the camera above the ellipsoid. Smaller values produce a more gradual transition as camera height increases.
|
|
95
|
+
* Value must be greater than 0.
|
|
96
|
+
* @memberof Fog.prototype
|
|
97
|
+
* @type {number}
|
|
98
|
+
* @default 0.59
|
|
99
|
+
*/
|
|
100
|
+
heightFalloff: {
|
|
101
|
+
get: function () {
|
|
102
|
+
return this._heightFalloff;
|
|
103
|
+
},
|
|
104
|
+
set: function (value) {
|
|
105
|
+
//>>includeStart('debug', pragmas.debug);
|
|
106
|
+
if (defined(value) && value < 0) {
|
|
107
|
+
throw new DeveloperError("value must be positive.");
|
|
108
|
+
}
|
|
109
|
+
//>>includeEnd('debug');
|
|
110
|
+
|
|
111
|
+
this._heightFalloff = value;
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
});
|
|
122
115
|
|
|
123
116
|
const scratchPositionNormal = new Cartesian3();
|
|
124
117
|
|
|
118
|
+
/**
|
|
119
|
+
* @param {FrameState} frameState
|
|
120
|
+
* @private
|
|
121
|
+
*/
|
|
125
122
|
Fog.prototype.update = function (frameState) {
|
|
126
123
|
const enabled = (frameState.fog.enabled = this.enabled);
|
|
127
124
|
if (!enabled) {
|
|
@@ -136,7 +133,7 @@ Fog.prototype.update = function (frameState) {
|
|
|
136
133
|
// Turn off fog in space.
|
|
137
134
|
if (
|
|
138
135
|
!defined(positionCartographic) ||
|
|
139
|
-
positionCartographic.height >
|
|
136
|
+
positionCartographic.height > this.maxHeight ||
|
|
140
137
|
frameState.mode !== SceneMode.SCENE3D
|
|
141
138
|
) {
|
|
142
139
|
frameState.fog.enabled = false;
|
|
@@ -145,18 +142,13 @@ Fog.prototype.update = function (frameState) {
|
|
|
145
142
|
}
|
|
146
143
|
|
|
147
144
|
const height = positionCartographic.height;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
// Again, scale value to be in the range of densityTable (prevents divide by zero) and change to new range.
|
|
157
|
-
const startDensity = this.density * 1.0e6;
|
|
158
|
-
const endDensity = (startDensity / tableStartDensity) * tableEndDensity;
|
|
159
|
-
density = density * (startDensity - endDensity) * 1.0e-6;
|
|
145
|
+
let density =
|
|
146
|
+
this.density *
|
|
147
|
+
this.heightScalar *
|
|
148
|
+
Math.pow(
|
|
149
|
+
Math.max(height / this.maxHeight, CesiumMath.EPSILON4),
|
|
150
|
+
-Math.max(this._heightFalloff, 0.0),
|
|
151
|
+
);
|
|
160
152
|
|
|
161
153
|
// Fade fog in as the camera tilts toward the horizon.
|
|
162
154
|
const positionNormal = Cartesian3.normalize(
|
|
@@ -167,6 +159,7 @@ Fog.prototype.update = function (frameState) {
|
|
|
167
159
|
density *= 1.0 - dot;
|
|
168
160
|
|
|
169
161
|
frameState.fog.density = density;
|
|
162
|
+
frameState.fog.visualDensityScalar = this.visualDensityScalar;
|
|
170
163
|
frameState.fog.sse = this.screenSpaceErrorFactor;
|
|
171
164
|
frameState.fog.minimumBrightness = this.minimumBrightness;
|
|
172
165
|
};
|
|
@@ -261,9 +261,10 @@ function FrameState(context, creditDisplay, jobScheduler) {
|
|
|
261
261
|
* @type {object}
|
|
262
262
|
* @property {boolean} enabled <code>true</code> if fog is enabled, <code>false</code> otherwise. This affects both fog culling and rendering.
|
|
263
263
|
* @property {boolean} renderable <code>true</code> if fog should be rendered, <code>false</code> if not. This flag should be checked in combination with fog.enabled.
|
|
264
|
-
* @property {number} density A positive number used to mix the color and fog color based on camera distance.
|
|
265
|
-
* @property {number}
|
|
266
|
-
* @property {number}
|
|
264
|
+
* @property {number | undefined} density A positive number used to mix the color and fog color based on camera distance.
|
|
265
|
+
* @property {number | undefined} visualDensityScalar A positive number to modify how impactful the fog is based off the density
|
|
266
|
+
* @property {number | undefined} sse A scalar used to modify the screen space error of geometry partially in fog.
|
|
267
|
+
* @property {number | undefined} minimumBrightness The minimum brightness of terrain with fog applied.
|
|
267
268
|
*/
|
|
268
269
|
|
|
269
270
|
/**
|
|
@@ -277,6 +278,7 @@ function FrameState(context, creditDisplay, jobScheduler) {
|
|
|
277
278
|
enabled: false,
|
|
278
279
|
renderable: false,
|
|
279
280
|
density: undefined,
|
|
281
|
+
visualDensityScalar: undefined,
|
|
280
282
|
sse: undefined,
|
|
281
283
|
minimumBrightness: undefined,
|
|
282
284
|
};
|
|
@@ -20,7 +20,6 @@ import SpecularEnvironmentCubeMap from "./SpecularEnvironmentCubeMap.js";
|
|
|
20
20
|
* @constructor
|
|
21
21
|
*
|
|
22
22
|
* @param {Cartesian2} [options.imageBasedLightingFactor=Cartesian2(1.0, 1.0)] Scales diffuse and specular image-based lighting from the earth, sky, atmosphere and star skybox.
|
|
23
|
-
* @param {number} [options.luminanceAtZenith=0.2] The sun's luminance at the zenith in kilo candela per meter squared to use for this model's procedural environment map.
|
|
24
23
|
* @param {Cartesian3[]} [options.sphericalHarmonicCoefficients] The third order spherical harmonic coefficients used for the diffuse color of image-based lighting.
|
|
25
24
|
* @param {string} [options.specularEnvironmentMaps] A URL to a KTX2 file that contains a cube map of the specular lighting and the convoluted specular mipmaps.
|
|
26
25
|
*/
|
|
@@ -59,14 +58,6 @@ function ImageBasedLighting(options) {
|
|
|
59
58
|
|
|
60
59
|
this._imageBasedLightingFactor = imageBasedLightingFactor;
|
|
61
60
|
|
|
62
|
-
const luminanceAtZenith = defaultValue(options.luminanceAtZenith, 0.2);
|
|
63
|
-
|
|
64
|
-
//>>includeStart('debug', pragmas.debug);
|
|
65
|
-
Check.typeOf.number("options.luminanceAtZenith", luminanceAtZenith);
|
|
66
|
-
//>>includeEnd('debug');
|
|
67
|
-
|
|
68
|
-
this._luminanceAtZenith = luminanceAtZenith;
|
|
69
|
-
|
|
70
61
|
const sphericalHarmonicCoefficients = options.sphericalHarmonicCoefficients;
|
|
71
62
|
|
|
72
63
|
//>>includeStart('debug', pragmas.debug);
|
|
@@ -100,7 +91,6 @@ function ImageBasedLighting(options) {
|
|
|
100
91
|
this._previousImageBasedLightingFactor = Cartesian2.clone(
|
|
101
92
|
imageBasedLightingFactor,
|
|
102
93
|
);
|
|
103
|
-
this._previousLuminanceAtZenith = luminanceAtZenith;
|
|
104
94
|
this._previousSphericalHarmonicCoefficients = sphericalHarmonicCoefficients;
|
|
105
95
|
this._removeErrorListener = undefined;
|
|
106
96
|
}
|
|
@@ -156,27 +146,6 @@ Object.defineProperties(ImageBasedLighting.prototype, {
|
|
|
156
146
|
},
|
|
157
147
|
},
|
|
158
148
|
|
|
159
|
-
/**
|
|
160
|
-
* The sun's luminance at the zenith in kilo candela per meter squared
|
|
161
|
-
* to use for this model's procedural environment map. This is used when
|
|
162
|
-
* {@link ImageBasedLighting#specularEnvironmentMaps} and {@link ImageBasedLighting#sphericalHarmonicCoefficients}
|
|
163
|
-
* are not defined.
|
|
164
|
-
*
|
|
165
|
-
* @memberof ImageBasedLighting.prototype
|
|
166
|
-
*
|
|
167
|
-
* @type {number}
|
|
168
|
-
* @default 0.2
|
|
169
|
-
*/
|
|
170
|
-
luminanceAtZenith: {
|
|
171
|
-
get: function () {
|
|
172
|
-
return this._luminanceAtZenith;
|
|
173
|
-
},
|
|
174
|
-
set: function (value) {
|
|
175
|
-
this._previousLuminanceAtZenith = this._luminanceAtZenith;
|
|
176
|
-
this._luminanceAtZenith = value;
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
|
|
180
149
|
/**
|
|
181
150
|
* The third order spherical harmonic coefficients used for the diffuse color of image-based lighting. When <code>undefined</code>, a diffuse irradiance
|
|
182
151
|
* computed from the atmosphere color is used.
|
|
@@ -269,47 +238,30 @@ Object.defineProperties(ImageBasedLighting.prototype, {
|
|
|
269
238
|
},
|
|
270
239
|
|
|
271
240
|
/**
|
|
272
|
-
*
|
|
241
|
+
* The texture atlas for the specular environment maps.
|
|
273
242
|
*
|
|
274
243
|
* @memberof ImageBasedLighting.prototype
|
|
275
|
-
* @type {
|
|
244
|
+
* @type {SpecularEnvironmentCubeMap}
|
|
276
245
|
*
|
|
277
246
|
* @private
|
|
278
247
|
*/
|
|
279
|
-
|
|
248
|
+
specularEnvironmentCubeMap: {
|
|
280
249
|
get: function () {
|
|
281
|
-
return this.
|
|
250
|
+
return this._specularEnvironmentCubeMap;
|
|
282
251
|
},
|
|
283
252
|
},
|
|
284
253
|
|
|
285
254
|
/**
|
|
286
|
-
* Whether or not
|
|
255
|
+
* Whether or not to use the default spherical harmonics coefficients.
|
|
287
256
|
*
|
|
288
257
|
* @memberof ImageBasedLighting.prototype
|
|
289
258
|
* @type {boolean}
|
|
290
259
|
*
|
|
291
260
|
* @private
|
|
292
261
|
*/
|
|
293
|
-
|
|
294
|
-
get: function () {
|
|
295
|
-
return (
|
|
296
|
-
defined(this._sphericalHarmonicCoefficients) ||
|
|
297
|
-
this._useDefaultSphericalHarmonics
|
|
298
|
-
);
|
|
299
|
-
},
|
|
300
|
-
},
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* The cube map for the specular environment maps.
|
|
304
|
-
*
|
|
305
|
-
* @memberof ImageBasedLighting.prototype
|
|
306
|
-
* @type {SpecularEnvironmentCubeMap}
|
|
307
|
-
*
|
|
308
|
-
* @private
|
|
309
|
-
*/
|
|
310
|
-
specularEnvironmentCubeMap: {
|
|
262
|
+
useDefaultSphericalHarmonics: {
|
|
311
263
|
get: function () {
|
|
312
|
-
return this.
|
|
264
|
+
return this._useDefaultSphericalHarmonics;
|
|
313
265
|
},
|
|
314
266
|
},
|
|
315
267
|
|
|
@@ -400,15 +352,6 @@ ImageBasedLighting.prototype.update = function (frameState) {
|
|
|
400
352
|
);
|
|
401
353
|
}
|
|
402
354
|
|
|
403
|
-
if (this._luminanceAtZenith !== this._previousLuminanceAtZenith) {
|
|
404
|
-
this._shouldRegenerateShaders =
|
|
405
|
-
this._shouldRegenerateShaders ||
|
|
406
|
-
defined(this._luminanceAtZenith) !==
|
|
407
|
-
defined(this._previousLuminanceAtZenith);
|
|
408
|
-
|
|
409
|
-
this._previousLuminanceAtZenith = this._luminanceAtZenith;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
355
|
if (
|
|
413
356
|
this._previousSphericalHarmonicCoefficients !==
|
|
414
357
|
this._sphericalHarmonicCoefficients
|
|
@@ -16,12 +16,17 @@ const AtmospherePipelineStage = {
|
|
|
16
16
|
name: "AtmospherePipelineStage", // Helps with debugging
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* @param {ModelRenderResources} modelRenderResources
|
|
21
|
+
* @param {Model} model
|
|
22
|
+
* @param {FrameState} frameState
|
|
23
|
+
*/
|
|
19
24
|
AtmospherePipelineStage.process = function (
|
|
20
|
-
|
|
25
|
+
modelRenderResources,
|
|
21
26
|
model,
|
|
22
27
|
frameState,
|
|
23
28
|
) {
|
|
24
|
-
const shaderBuilder =
|
|
29
|
+
const shaderBuilder = modelRenderResources.shaderBuilder;
|
|
25
30
|
|
|
26
31
|
shaderBuilder.addDefine("HAS_ATMOSPHERE", undefined, ShaderDestination.BOTH);
|
|
27
32
|
shaderBuilder.addDefine(
|
|
@@ -37,12 +42,12 @@ AtmospherePipelineStage.process = function (
|
|
|
37
42
|
shaderBuilder.addVertexLines([AtmosphereStageVS]);
|
|
38
43
|
shaderBuilder.addFragmentLines([AtmosphereStageFS]);
|
|
39
44
|
|
|
40
|
-
// Add a uniform so fog is only calculated when the
|
|
41
|
-
// be non-negligible For example when the camera is in space, fog density decreases
|
|
45
|
+
// Add a uniform so fog is only calculated when the effect would
|
|
46
|
+
// be non-negligible. For example when the camera is in space, fog density decreases
|
|
42
47
|
// to 0 so fog shouldn't be rendered. Since this state may change rapidly if
|
|
43
48
|
// the camera is moving, this is implemented as a uniform, not a define.
|
|
44
49
|
shaderBuilder.addUniform("bool", "u_isInFog", ShaderDestination.FRAGMENT);
|
|
45
|
-
|
|
50
|
+
modelRenderResources.uniformMap.u_isInFog = function () {
|
|
46
51
|
// We only need a rough measure of distance to the model, so measure
|
|
47
52
|
// from the camera to the bounding sphere center.
|
|
48
53
|
const distance = Cartesian3.distance(
|
|
@@ -3,11 +3,14 @@ import defined from "../../Core/defined.js";
|
|
|
3
3
|
import ImageBasedLightingStageFS from "../../Shaders/Model/ImageBasedLightingStageFS.js";
|
|
4
4
|
import ShaderDestination from "../../Renderer/ShaderDestination.js";
|
|
5
5
|
import SpecularEnvironmentCubeMap from "../SpecularEnvironmentCubeMap.js";
|
|
6
|
+
import Cartesian2 from "../../Core/Cartesian2.js";
|
|
6
7
|
|
|
7
8
|
const ImageBasedLightingPipelineStage = {
|
|
8
9
|
name: "ImageBasedLightingPipelineStage", // Helps with debugging
|
|
9
10
|
};
|
|
10
11
|
|
|
12
|
+
const scratchCartesian = new Cartesian2();
|
|
13
|
+
|
|
11
14
|
/**
|
|
12
15
|
* Add shader code, uniforms, and defines related to image based lighting
|
|
13
16
|
* @param {ModelRenderResources} renderResources
|
|
@@ -21,8 +24,18 @@ ImageBasedLightingPipelineStage.process = function (
|
|
|
21
24
|
frameState,
|
|
22
25
|
) {
|
|
23
26
|
const imageBasedLighting = model.imageBasedLighting;
|
|
27
|
+
const environmentMapManager = model.environmentMapManager;
|
|
24
28
|
const shaderBuilder = renderResources.shaderBuilder;
|
|
25
29
|
|
|
30
|
+
// If environment maps or spherical harmonics are not specifically provided, use procedural lighting.
|
|
31
|
+
let specularEnvironmentMapAtlas;
|
|
32
|
+
if (!defined(imageBasedLighting.specularEnvironmentMaps)) {
|
|
33
|
+
specularEnvironmentMapAtlas = environmentMapManager.radianceCubeMap;
|
|
34
|
+
}
|
|
35
|
+
const sphericalHarmonicCoefficients =
|
|
36
|
+
imageBasedLighting.sphericalHarmonicCoefficients ??
|
|
37
|
+
environmentMapManager.sphericalHarmonicCoefficients;
|
|
38
|
+
|
|
26
39
|
shaderBuilder.addDefine(
|
|
27
40
|
"USE_IBL_LIGHTING",
|
|
28
41
|
undefined,
|
|
@@ -47,7 +60,18 @@ ImageBasedLightingPipelineStage.process = function (
|
|
|
47
60
|
);
|
|
48
61
|
}
|
|
49
62
|
|
|
50
|
-
if (defined(
|
|
63
|
+
if (defined(specularEnvironmentMapAtlas)) {
|
|
64
|
+
shaderBuilder.addDefine(
|
|
65
|
+
"COMPUTE_POSITION_WC_ATMOSPHERE",
|
|
66
|
+
undefined,
|
|
67
|
+
ShaderDestination.BOTH,
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (
|
|
72
|
+
defined(sphericalHarmonicCoefficients) &&
|
|
73
|
+
defined(sphericalHarmonicCoefficients[0])
|
|
74
|
+
) {
|
|
51
75
|
shaderBuilder.addDefine(
|
|
52
76
|
"DIFFUSE_IBL",
|
|
53
77
|
undefined,
|
|
@@ -72,8 +96,9 @@ ImageBasedLightingPipelineStage.process = function (
|
|
|
72
96
|
}
|
|
73
97
|
|
|
74
98
|
if (
|
|
75
|
-
defined(imageBasedLighting.specularEnvironmentCubeMap) &&
|
|
76
|
-
|
|
99
|
+
(defined(imageBasedLighting.specularEnvironmentCubeMap) &&
|
|
100
|
+
imageBasedLighting.specularEnvironmentCubeMap.ready) ||
|
|
101
|
+
defined(specularEnvironmentMapAtlas)
|
|
77
102
|
) {
|
|
78
103
|
shaderBuilder.addDefine(
|
|
79
104
|
"SPECULAR_IBL",
|
|
@@ -104,33 +129,21 @@ ImageBasedLightingPipelineStage.process = function (
|
|
|
104
129
|
}
|
|
105
130
|
}
|
|
106
131
|
|
|
107
|
-
if (defined(imageBasedLighting.luminanceAtZenith)) {
|
|
108
|
-
shaderBuilder.addDefine(
|
|
109
|
-
"USE_SUN_LUMINANCE",
|
|
110
|
-
undefined,
|
|
111
|
-
ShaderDestination.FRAGMENT,
|
|
112
|
-
);
|
|
113
|
-
shaderBuilder.addUniform(
|
|
114
|
-
"float",
|
|
115
|
-
"model_luminanceAtZenith",
|
|
116
|
-
ShaderDestination.FRAGMENT,
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
132
|
shaderBuilder.addFragmentLines(ImageBasedLightingStageFS);
|
|
121
133
|
|
|
122
134
|
const uniformMap = {
|
|
123
135
|
model_iblFactor: function () {
|
|
124
|
-
return
|
|
136
|
+
return Cartesian2.multiplyByScalar(
|
|
137
|
+
imageBasedLighting.imageBasedLightingFactor,
|
|
138
|
+
environmentMapManager?.intensity || 1.0,
|
|
139
|
+
scratchCartesian,
|
|
140
|
+
);
|
|
125
141
|
},
|
|
126
142
|
model_iblReferenceFrameMatrix: function () {
|
|
127
143
|
return model._iblReferenceFrameMatrix;
|
|
128
144
|
},
|
|
129
|
-
model_luminanceAtZenith: function () {
|
|
130
|
-
return imageBasedLighting.luminanceAtZenith;
|
|
131
|
-
},
|
|
132
145
|
model_sphericalHarmonicCoefficients: function () {
|
|
133
|
-
return
|
|
146
|
+
return sphericalHarmonicCoefficients;
|
|
134
147
|
},
|
|
135
148
|
model_specularEnvironmentMaps: function () {
|
|
136
149
|
return imageBasedLighting.specularEnvironmentCubeMap.texture;
|
|
@@ -140,6 +153,15 @@ ImageBasedLightingPipelineStage.process = function (
|
|
|
140
153
|
},
|
|
141
154
|
};
|
|
142
155
|
|
|
156
|
+
if (defined(specularEnvironmentMapAtlas)) {
|
|
157
|
+
uniformMap.model_specularEnvironmentMaps = function () {
|
|
158
|
+
return specularEnvironmentMapAtlas;
|
|
159
|
+
};
|
|
160
|
+
uniformMap.model_specularEnvironmentMapsMaximumLOD = function () {
|
|
161
|
+
return environmentMapManager.maximumMipmapLevel;
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
143
165
|
renderResources.uniformMap = combine(uniformMap, renderResources.uniformMap);
|
|
144
166
|
};
|
|
145
167
|
|