@cesium/engine 9.1.0 → 10.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/pako_deflate.min.js +108 -210
- package/Build/ThirdParty/Workers/pako_inflate.min.js +466 -568
- package/Build/ThirdParty/Workers/z-worker-pako.js +54 -104
- package/Build/Workers/{chunk-TMMOULW3.js → chunk-2J3JKXCP.js} +5 -5
- package/Build/Workers/{chunk-ZDP32RQI.js → chunk-3WUV74WM.js} +95 -155
- package/Build/Workers/{chunk-FOZQIHZK.js → chunk-4BAE4PWO.js} +6 -6
- package/Build/Workers/{chunk-CYAJYEKW.js → chunk-4MSUJ4I7.js} +8 -8
- package/Build/Workers/{chunk-KPY4F4BW.js → chunk-4YSNMHZ4.js} +6 -6
- package/Build/Workers/{chunk-66E3H2KU.js → chunk-5S7OLEPK.js} +12 -12
- package/Build/Workers/{chunk-4AJGCQFX.js → chunk-7XGC6YB2.js} +14 -14
- package/Build/Workers/{chunk-BDUJXBVF.js → chunk-AA4GZKOT.js} +3 -5
- package/Build/Workers/{chunk-7LPEGKOF.js → chunk-AD5HBJ2F.js} +11 -8
- package/Build/Workers/{chunk-XHLDDE65.js → chunk-AVI4IUWC.js} +11 -11
- package/Build/Workers/{chunk-MWYZ64MH.js → chunk-BCL4PHHT.js} +10 -10
- package/Build/Workers/{chunk-PWF3YJJ5.js → chunk-BDFNKFOE.js} +13 -13
- package/Build/Workers/{chunk-7VZNXIKG.js → chunk-BJF5LOWE.js} +7 -7
- package/Build/Workers/{chunk-3S2MFY4B.js → chunk-C2CGMAIU.js} +13 -13
- package/Build/Workers/{chunk-UAJEGIWA.js → chunk-COYFZ5VA.js} +6 -6
- package/Build/Workers/{chunk-ZWPIM77Q.js → chunk-DGS5QNIO.js} +13 -13
- package/Build/Workers/{chunk-V7JB576Q.js → chunk-DKVHRNFY.js} +5 -5
- package/Build/Workers/{chunk-NI2R52QD.js → chunk-DOXCPOG4.js} +11 -9
- package/Build/Workers/{chunk-XWML5Y7N.js → chunk-FXIHSF7O.js} +9 -9
- package/Build/Workers/{chunk-LW7WGHEU.js → chunk-G3YR53LY.js} +13 -13
- package/Build/Workers/{chunk-34DGOKCO.js → chunk-GR3CDLCP.js} +7 -7
- package/Build/Workers/{chunk-AOIKO5Y7.js → chunk-GRAT5GE7.js} +5 -5
- package/Build/Workers/{chunk-AOFMPKUB.js → chunk-I2RC4XVN.js} +4 -4
- package/Build/Workers/{chunk-PK7TEP3J.js → chunk-JYAHOGGL.js} +15 -15
- package/Build/Workers/{chunk-4KIUON73.js → chunk-KUN2ZA5X.js} +4 -4
- package/Build/Workers/{chunk-POLFRINT.js → chunk-L6RTJ3RE.js} +14 -14
- package/Build/Workers/{chunk-LVJCR7DH.js → chunk-LCLJJ2MZ.js} +18 -18
- package/Build/Workers/{chunk-3RZK5NNV.js → chunk-LEABCTLP.js} +4 -4
- package/Build/Workers/{chunk-QKF7XXEQ.js → chunk-MDHQR3ZS.js} +10 -8
- package/Build/Workers/{chunk-4PHPQRSH.js → chunk-MSKXMXJI.js} +5 -6
- package/Build/Workers/{chunk-GIFJ77E4.js → chunk-NTXTUNEF.js} +4 -4
- package/Build/Workers/{chunk-I5TDPPC4.js → chunk-O3JCMSS3.js} +17 -17
- package/Build/Workers/{chunk-PEABJLCK.js → chunk-OOK53QUQ.js} +1 -1
- package/Build/Workers/{chunk-PS6AEMBR.js → chunk-OORVMGDU.js} +7 -7
- package/Build/Workers/{chunk-JI2445T5.js → chunk-PCP4YQST.js} +11 -11
- package/Build/Workers/{chunk-C5CE4OG6.js → chunk-PYHLO636.js} +42 -13
- package/Build/Workers/{chunk-S4XDCPKD.js → chunk-Q55ECN3Y.js} +1 -1
- package/Build/Workers/{chunk-WWP3I7R5.js → chunk-QD4KM3GO.js} +5 -5
- package/Build/Workers/{chunk-YLZTCEBJ.js → chunk-QMLTCCYG.js} +1 -1
- package/Build/Workers/{chunk-IBXGK4WV.js → chunk-QX5XS4LC.js} +2 -2
- package/Build/Workers/{chunk-RL73GOEF.js → chunk-R6B7UCQB.js} +2 -2
- package/Build/Workers/{chunk-RR7EOKGZ.js → chunk-RJYML24O.js} +48 -85
- package/Build/Workers/{chunk-U4IMCOF5.js → chunk-S3PI2KFM.js} +2 -2
- package/Build/Workers/{chunk-6HCAQOVK.js → chunk-STBBMQGG.js} +6 -6
- package/Build/Workers/{chunk-CE6GTZ4I.js → chunk-SYCPRK3D.js} +10 -10
- package/Build/Workers/{chunk-WFICTTOE.js → chunk-T77JILCU.js} +2 -2
- package/Build/Workers/{chunk-ZC4AGBZK.js → chunk-TO2PVHKI.js} +2 -2
- package/Build/Workers/{chunk-UCPPWV64.js → chunk-VE7BFUIX.js} +1 -1
- package/Build/Workers/{chunk-2CSEEWHN.js → chunk-VFBNELXB.js} +7 -7
- package/Build/Workers/{chunk-A6NCZSL3.js → chunk-VO3ACQB2.js} +19 -19
- package/Build/Workers/{chunk-WEGCQ5DY.js → chunk-X23FRWHJ.js} +6 -6
- package/Build/Workers/{chunk-G7CJQKKD.js → chunk-XD445VDH.js} +7 -7
- 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 +29 -25
- package/Build/Workers/createCircleOutlineGeometry.js +17 -17
- package/Build/Workers/createCoplanarPolygonGeometry.js +32 -32
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +29 -29
- package/Build/Workers/createCorridorGeometry.js +29 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +27 -27
- 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 +24 -24
- package/Build/Workers/createPlaneGeometry.js +14 -14
- package/Build/Workers/createPlaneOutlineGeometry.js +13 -13
- package/Build/Workers/createPolygonGeometry.js +32 -32
- package/Build/Workers/createPolygonOutlineGeometry.js +29 -29
- package/Build/Workers/createPolylineGeometry.js +24 -24
- package/Build/Workers/createPolylineVolumeGeometry.js +30 -30
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +26 -26
- package/Build/Workers/createRectangleGeometry.js +27 -27
- package/Build/Workers/createRectangleOutlineGeometry.js +19 -19
- package/Build/Workers/createSimplePolylineGeometry.js +22 -22
- 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 +21 -21
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +17 -17
- 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 +12 -19
- package/Build/Workers/decodeI3S.js +10 -10
- package/Build/Workers/transcodeKTX2.js +43 -79
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +20 -20
- package/Source/Core/ApproximateTerrainHeights.js +4 -4
- package/Source/Core/ArcGISTiledElevationTerrainProvider.js +12 -8
- package/Source/Core/BoundingRectangle.js +2 -0
- package/Source/Core/BoundingSphere.js +4 -2
- package/Source/Core/Cartesian3.js +13 -10
- package/Source/Core/Cartographic.js +11 -8
- package/Source/Core/CesiumTerrainProvider.js +3 -2
- package/Source/Core/CircleGeometry.js +6 -2
- package/Source/Core/CircleOutlineGeometry.js +1 -1
- package/Source/Core/CoplanarPolygonGeometry.js +3 -3
- package/Source/Core/CorridorGeometry.js +4 -4
- package/Source/Core/CorridorOutlineGeometry.js +2 -2
- package/Source/Core/Credit.js +3 -2
- package/Source/Core/CustomHeightmapTerrainProvider.js +17 -3
- package/Source/Core/EllipseGeometry.js +4 -4
- package/Source/Core/EllipseOutlineGeometry.js +2 -2
- package/Source/Core/Ellipsoid.js +34 -0
- package/Source/Core/EllipsoidGeodesic.js +2 -2
- package/Source/Core/EllipsoidRhumbLine.js +4 -4
- package/Source/Core/EllipsoidTangentPlane.js +3 -3
- package/Source/Core/EllipsoidTerrainProvider.js +3 -3
- package/Source/Core/GeographicProjection.js +4 -3
- package/Source/Core/GeographicTilingScheme.js +3 -3
- package/Source/Core/GeometryPipeline.js +2 -2
- package/Source/Core/GoogleEarthEnterpriseTerrainProvider.js +1 -1
- package/Source/Core/GoogleMaps.js +1 -1
- package/Source/Core/GroundPolylineGeometry.js +1 -1
- package/Source/Core/HeightmapTessellator.js +2 -2
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/Math.js +0 -5
- package/Source/Core/Occluder.js +3 -3
- package/Source/Core/OrientedBoundingBox.js +2 -2
- package/Source/Core/PolygonGeometry.js +4 -4
- package/Source/Core/PolygonGeometryLibrary.js +1 -1
- package/Source/Core/PolygonOutlineGeometry.js +3 -3
- package/Source/Core/PolygonPipeline.js +2 -2
- package/Source/Core/PolylineGeometry.js +2 -2
- package/Source/Core/PolylinePipeline.js +6 -6
- package/Source/Core/PolylineVolumeGeometry.js +2 -2
- package/Source/Core/PolylineVolumeOutlineGeometry.js +2 -2
- package/Source/Core/Rectangle.js +6 -6
- package/Source/Core/RectangleGeometry.js +6 -6
- package/Source/Core/RectangleGeometryLibrary.js +3 -0
- package/Source/Core/RectangleOutlineGeometry.js +2 -2
- package/Source/Core/Simon1994PlanetaryPositions.js +3 -2
- package/Source/Core/SimplePolylineGeometry.js +2 -2
- package/Source/Core/Stereographic.js +2 -2
- package/Source/Core/TaskProcessor.js +19 -3
- package/Source/Core/Transforms.js +17 -17
- package/Source/Core/VRTheWorldTerrainProvider.js +2 -2
- package/Source/Core/WallGeometry.js +3 -3
- package/Source/Core/WallOutlineGeometry.js +3 -3
- package/Source/Core/WebMercatorTilingScheme.js +3 -3
- package/Source/Core/createWorldTerrainAsync.js +2 -0
- package/Source/Core/sampleTerrain.js +3 -3
- package/Source/DataSources/BoxGeometryUpdater.js +2 -2
- package/Source/DataSources/CylinderGeometryUpdater.js +2 -2
- package/Source/DataSources/CzmlDataSource.js +8 -8
- package/Source/DataSources/EllipsoidGeometryUpdater.js +3 -3
- package/Source/DataSources/EntityCluster.js +1 -1
- package/Source/DataSources/EntityView.js +2 -2
- package/Source/DataSources/KmlDataSource.js +4 -4
- package/Source/DataSources/ModelVisualizer.js +1 -2
- package/Source/DataSources/PolygonGeometryUpdater.js +1 -1
- package/Source/DataSources/PolylineGeometryUpdater.js +3 -2
- package/Source/DataSources/RectangleGeometryUpdater.js +1 -1
- package/Source/DataSources/ScaledPositionProperty.js +2 -2
- package/Source/DataSources/TerrainOffsetProperty.js +3 -7
- package/Source/DataSources/VelocityOrientationProperty.js +2 -2
- package/Source/DataSources/exportKml.js +2 -2
- package/Source/Renderer/UniformState.js +1 -1
- package/Source/Scene/ArcGisMapServerImageryProvider.js +2 -2
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Billboard.js +8 -6
- package/Source/Scene/BingMapsImageryProvider.js +1 -1
- package/Source/Scene/Camera.js +16 -10
- package/Source/Scene/Cesium3DTileset.js +1 -1
- package/Source/Scene/ClippingPolygon.js +2 -2
- package/Source/Scene/ClippingPolygonCollection.js +1 -1
- package/Source/Scene/CreditDisplay.js +94 -104
- package/Source/Scene/Globe.js +16 -13
- package/Source/Scene/GltfLoader.js +458 -435
- package/Source/Scene/GltfLoaderUtil.js +5 -16
- package/Source/Scene/GltfPipeline/forEachTextureInMaterial.js +23 -7
- package/Source/Scene/GltfStructuralMetadataLoader.js +11 -9
- package/Source/Scene/GoogleEarthEnterpriseImageryProvider.js +1 -1
- package/Source/Scene/GoogleEarthEnterpriseMapsProvider.js +1 -1
- package/Source/Scene/GridImageryProvider.js +2 -2
- package/Source/Scene/ImageryLayerCollection.js +2 -2
- package/Source/Scene/Label.js +1 -1
- package/Source/Scene/MapboxImageryProvider.js +1 -1
- package/Source/Scene/MapboxStyleImageryProvider.js +1 -1
- package/Source/Scene/MetadataSemantic.js +4 -4
- package/Source/Scene/Model/AlphaPipelineStage.js +1 -1
- package/Source/Scene/Model/GeometryPipelineStage.js +15 -43
- package/Source/Scene/Model/ImageBasedLightingPipelineStage.js +7 -0
- package/Source/Scene/Model/InstancingPipelineStage.js +3 -3
- package/Source/Scene/Model/LightingPipelineStage.js +2 -4
- package/Source/Scene/Model/MaterialPipelineStage.js +395 -29
- package/Source/Scene/Model/Model.js +15 -7
- package/Source/Scene/Model/ModelSceneGraph.js +1 -1
- package/Source/Scene/Model/ModelUtility.js +3 -0
- package/Source/Scene/Model/SceneMode2DPipelineStage.js +3 -3
- package/Source/Scene/Model/VerticalExaggerationPipelineStage.js +4 -6
- package/Source/Scene/Model/pickModel.js +2 -2
- package/Source/Scene/ModelComponents.js +178 -1
- package/Source/Scene/PickDepth.js +23 -15
- package/Source/Scene/Picking.js +4 -13
- package/Source/Scene/PointPrimitive.js +5 -2
- package/Source/Scene/ResourceCache.js +41 -50
- package/Source/Scene/ResourceCacheKey.js +41 -53
- package/Source/Scene/Scene.js +39 -31
- package/Source/Scene/SceneTransforms.js +78 -20
- package/Source/Scene/SceneTransitioner.js +2 -2
- package/Source/Scene/ScreenSpaceCameraController.js +29 -19
- package/Source/Scene/SkyBox.js +26 -0
- package/Source/Scene/Sun.js +1 -1
- package/Source/Shaders/Builtin/CzmBuiltins.js +4 -10
- package/Source/Shaders/Builtin/Functions/ellipsoidTextureCoordinates.glsl +10 -0
- package/Source/Shaders/Builtin/Functions/{ellipsoidWgs84TextureCoordinates.js → ellipsoidTextureCoordinates.js} +3 -3
- package/Source/Shaders/Builtin/Functions/maximumComponent.glsl +21 -0
- package/Source/Shaders/Builtin/Functions/maximumComponent.js +23 -0
- package/Source/Shaders/Builtin/Functions/pbrLighting.glsl +108 -44
- package/Source/Shaders/Builtin/Functions/pbrLighting.js +108 -44
- package/Source/Shaders/Builtin/Structs/materialInput.glsl +1 -1
- package/Source/Shaders/Builtin/Structs/materialInput.js +1 -1
- package/Source/Shaders/Builtin/Structs/modelMaterial.glsl +16 -0
- package/Source/Shaders/Builtin/Structs/modelMaterial.js +16 -0
- package/Source/Shaders/EllipsoidFS.glsl +1 -1
- package/Source/Shaders/EllipsoidFS.js +1 -1
- package/Source/Shaders/GlobeFS.glsl +3 -3
- package/Source/Shaders/GlobeFS.js +3 -3
- package/Source/Shaders/Model/ImageBasedLightingStageFS.glsl +211 -133
- package/Source/Shaders/Model/ImageBasedLightingStageFS.js +212 -133
- package/Source/Shaders/Model/LightingStageFS.glsl +113 -48
- package/Source/Shaders/Model/LightingStageFS.js +113 -48
- package/Source/Shaders/Model/MaterialStageFS.glsl +407 -136
- package/Source/Shaders/Model/MaterialStageFS.js +407 -136
- package/Source/Widget/CesiumWidget.css +0 -5
- package/Source/Widget/CesiumWidget.js +29 -28
- package/index.d.ts +184 -116
- package/index.js +92 -95
- package/package.json +2 -2
- package/Source/Shaders/Builtin/Functions/defaultPbrMaterial.glsl +0 -16
- package/Source/Shaders/Builtin/Functions/defaultPbrMaterial.js +0 -18
- package/Source/Shaders/Builtin/Functions/ellipsoidWgs84TextureCoordinates.glsl +0 -10
- package/Source/Shaders/Builtin/Functions/pbrMetallicRoughnessMaterial.glsl +0 -37
- package/Source/Shaders/Builtin/Functions/pbrMetallicRoughnessMaterial.js +0 -39
- package/Source/Shaders/Builtin/Functions/pbrSpecularGlossinessMaterial.glsl +0 -30
- package/Source/Shaders/Builtin/Functions/pbrSpecularGlossinessMaterial.js +0 -32
- package/Source/Shaders/Builtin/Structs/pbrParameters.glsl +0 -16
- package/Source/Shaders/Builtin/Structs/pbrParameters.js +0 -18
|
@@ -1,165 +1,243 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Compute some metrics for a procedural sky lighting model
|
|
3
|
+
*
|
|
4
|
+
* @param {vec3} positionWC The position of the fragment in world coordinates.
|
|
5
|
+
* @param {vec3} reflectionWC A unit vector in the direction of the reflection, in world coordinates.
|
|
6
|
+
* @return {vec3} The dot products of the horizon and reflection directions with the nadir, and an atmosphere boundary distance.
|
|
7
|
+
*/
|
|
8
|
+
vec3 getProceduralSkyMetrics(vec3 positionWC, vec3 reflectionWC)
|
|
9
|
+
{
|
|
10
|
+
// Figure out if the reflection vector hits the ellipsoid
|
|
11
|
+
float horizonDotNadir = 1.0 - min(1.0, czm_ellipsoidRadii.x / length(positionWC));
|
|
12
|
+
float reflectionDotNadir = dot(reflectionWC, normalize(positionWC));
|
|
13
|
+
float atmosphereHeight = 0.05;
|
|
14
|
+
float smoothstepHeight = smoothstep(0.0, atmosphereHeight, horizonDotNadir);
|
|
15
|
+
return vec3(horizonDotNadir, reflectionDotNadir, smoothstepHeight);
|
|
16
|
+
}
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Compute the diffuse irradiance for a procedural sky lighting model
|
|
20
|
+
*
|
|
21
|
+
* @param {vec3} skyMetrics The dot products of the horizon and reflection directions with the nadir, and an atmosphere boundary distance.
|
|
22
|
+
* @return {vec3} The computed diffuse irradiance
|
|
23
|
+
*/
|
|
24
|
+
vec3 getProceduralDiffuseIrradiance(vec3 skyMetrics)
|
|
25
|
+
{
|
|
26
|
+
vec3 blueSkyDiffuseColor = vec3(0.7, 0.85, 0.9);
|
|
27
|
+
float diffuseIrradianceFromEarth = (1.0 - skyMetrics.x) * (skyMetrics.y * 0.25 + 0.75) * skyMetrics.z;
|
|
28
|
+
float diffuseIrradianceFromSky = (1.0 - skyMetrics.z) * (1.0 - (skyMetrics.y * 0.25 + 0.25));
|
|
29
|
+
return blueSkyDiffuseColor * clamp(diffuseIrradianceFromEarth + diffuseIrradianceFromSky, 0.0, 1.0);
|
|
30
|
+
}
|
|
17
31
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Compute the specular irradiance for a procedural sky lighting model
|
|
34
|
+
*
|
|
35
|
+
* @param {vec3} skyMetrics The dot products of the horizon and reflection directions with the nadir, and an atmosphere boundary distance.
|
|
36
|
+
* @return {vec3} The computed specular irradiance
|
|
37
|
+
*/
|
|
38
|
+
vec3 getProceduralSpecularIrradiance(vec3 reflectionWC, vec3 skyMetrics, float roughness)
|
|
39
|
+
{
|
|
22
40
|
// Flipping the X vector is a cheap way to get the inverse of czm_temeToPseudoFixed, since that's a rotation about Z.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
vec3 diffuseColor = pbrParameters.diffuseColor;
|
|
28
|
-
float roughness = pbrParameters.roughness;
|
|
29
|
-
vec3 specularColor = pbrParameters.f0;
|
|
41
|
+
reflectionWC.x = -reflectionWC.x;
|
|
42
|
+
reflectionWC = -normalize(czm_temeToPseudoFixed * reflectionWC);
|
|
43
|
+
reflectionWC.x = -reflectionWC.x;
|
|
30
44
|
|
|
31
45
|
float inverseRoughness = 1.04 - roughness;
|
|
32
46
|
inverseRoughness *= inverseRoughness;
|
|
33
|
-
vec3 sceneSkyBox = czm_textureCube(czm_environmentMap,
|
|
47
|
+
vec3 sceneSkyBox = czm_textureCube(czm_environmentMap, reflectionWC).rgb * inverseRoughness;
|
|
34
48
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
float blendRegionOffset = roughness * -1.0;
|
|
38
|
-
float farAboveHorizon = clamp(horizonDotNadir - blendRegionSize * 0.5 + blendRegionOffset, 1.0e-10 - blendRegionSize, 0.99999);
|
|
39
|
-
float aroundHorizon = clamp(horizonDotNadir + blendRegionSize * 0.5, 1.0e-10 - blendRegionSize, 0.99999);
|
|
40
|
-
float farBelowHorizon = clamp(horizonDotNadir + blendRegionSize * 1.5, 1.0e-10 - blendRegionSize, 0.99999);
|
|
41
|
-
float smoothstepHeight = smoothstep(0.0, atmosphereHeight, horizonDotNadir);
|
|
42
|
-
vec3 belowHorizonColor = mix(vec3(0.1, 0.15, 0.25), vec3(0.4, 0.7, 0.9), smoothstepHeight);
|
|
49
|
+
// Compute colors at different angles relative to the horizon
|
|
50
|
+
vec3 belowHorizonColor = mix(vec3(0.1, 0.15, 0.25), vec3(0.4, 0.7, 0.9), skyMetrics.z);
|
|
43
51
|
vec3 nadirColor = belowHorizonColor * 0.5;
|
|
44
52
|
vec3 aboveHorizonColor = mix(vec3(0.9, 1.0, 1.2), belowHorizonColor, roughness * 0.5);
|
|
45
|
-
vec3 blueSkyColor = mix(vec3(0.18, 0.26, 0.48), aboveHorizonColor,
|
|
46
|
-
vec3 zenithColor = mix(blueSkyColor, sceneSkyBox,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
float
|
|
50
|
-
|
|
51
|
-
float
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
vec3 blueSkyColor = mix(vec3(0.18, 0.26, 0.48), aboveHorizonColor, skyMetrics.y * inverseRoughness * 0.5 + 0.75);
|
|
54
|
+
vec3 zenithColor = mix(blueSkyColor, sceneSkyBox, skyMetrics.z);
|
|
55
|
+
|
|
56
|
+
// Compute blend zones
|
|
57
|
+
float blendRegionSize = 0.1 * ((1.0 - inverseRoughness) * 8.0 + 1.1 - skyMetrics.x);
|
|
58
|
+
float blendRegionOffset = roughness * -1.0;
|
|
59
|
+
float farAboveHorizon = clamp(skyMetrics.x - blendRegionSize * 0.5 + blendRegionOffset, 1.0e-10 - blendRegionSize, 0.99999);
|
|
60
|
+
float aroundHorizon = clamp(skyMetrics.x + blendRegionSize * 0.5, 1.0e-10 - blendRegionSize, 0.99999);
|
|
61
|
+
float farBelowHorizon = clamp(skyMetrics.x + blendRegionSize * 1.5, 1.0e-10 - blendRegionSize, 0.99999);
|
|
62
|
+
|
|
63
|
+
// Blend colors
|
|
64
|
+
float notDistantRough = (1.0 - skyMetrics.x * roughness * 0.8);
|
|
65
|
+
vec3 specularIrradiance = mix(zenithColor, aboveHorizonColor, smoothstep(farAboveHorizon, aroundHorizon, skyMetrics.y) * notDistantRough);
|
|
66
|
+
specularIrradiance = mix(specularIrradiance, belowHorizonColor, smoothstep(aroundHorizon, farBelowHorizon, skyMetrics.y) * inverseRoughness);
|
|
67
|
+
specularIrradiance = mix(specularIrradiance, nadirColor, smoothstep(farBelowHorizon, 1.0, skyMetrics.y) * inverseRoughness);
|
|
68
|
+
|
|
69
|
+
return specularIrradiance;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
#ifdef USE_SUN_LUMINANCE
|
|
73
|
+
float clampedDot(vec3 x, vec3 y)
|
|
74
|
+
{
|
|
75
|
+
return clamp(dot(x, y), 0.001, 1.0);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Sun luminance following the "CIE Clear Sky Model"
|
|
79
|
+
* See page 40 of https://3dvar.com/Green2003Spherical.pdf
|
|
80
|
+
*
|
|
81
|
+
* @param {vec3} positionWC The position of the fragment in world coordinates.
|
|
82
|
+
* @param {vec3} normalEC The surface normal in eye coordinates.
|
|
83
|
+
* @param {vec3} lightDirectionEC Unit vector pointing to the light source in eye coordinates.
|
|
84
|
+
* @return {float} The computed sun luminance.
|
|
85
|
+
*/
|
|
86
|
+
float getSunLuminance(vec3 positionWC, vec3 normalEC, vec3 lightDirectionEC)
|
|
87
|
+
{
|
|
88
|
+
vec3 normalWC = normalize(czm_inverseViewRotation * normalEC);
|
|
89
|
+
vec3 lightDirectionWC = normalize(czm_inverseViewRotation * lightDirectionEC);
|
|
90
|
+
vec3 vWC = -normalize(positionWC);
|
|
91
|
+
|
|
92
|
+
// Angle between sun and zenith.
|
|
93
|
+
float LdotZenith = clampedDot(lightDirectionWC, vWC);
|
|
60
94
|
float S = acos(LdotZenith);
|
|
61
95
|
// Angle between zenith and current pixel
|
|
62
|
-
float NdotZenith =
|
|
96
|
+
float NdotZenith = clampedDot(normalWC, vWC);
|
|
63
97
|
// Angle between sun and current pixel
|
|
98
|
+
float NdotL = clampedDot(normalEC, lightDirectionEC);
|
|
64
99
|
float gamma = acos(NdotL);
|
|
65
|
-
float numerator = ((0.91 + 10.0 * exp(-3.0 * gamma) + 0.45 * pow(NdotL, 2.0)) * (1.0 - exp(-0.32 / NdotZenith)));
|
|
66
|
-
float denominator = (0.91 + 10.0 * exp(-3.0 * S) + 0.45 * pow(LdotZenith,2.0)) * (1.0 - exp(-0.32));
|
|
67
|
-
float luminance = model_luminanceAtZenith * (numerator / denominator);
|
|
68
|
-
#endif
|
|
69
100
|
|
|
101
|
+
float numerator = ((0.91 + 10.0 * exp(-3.0 * gamma) + 0.45 * NdotL * NdotL) * (1.0 - exp(-0.32 / NdotZenith)));
|
|
102
|
+
float denominator = (0.91 + 10.0 * exp(-3.0 * S) + 0.45 * LdotZenith * LdotZenith) * (1.0 - exp(-0.32));
|
|
103
|
+
return model_luminanceAtZenith * (numerator / denominator);
|
|
104
|
+
}
|
|
105
|
+
#endif
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Compute the light contribution from a procedural sky model
|
|
109
|
+
*
|
|
110
|
+
* @param {vec3} positionEC The position of the fragment in eye coordinates.
|
|
111
|
+
* @param {vec3} normalEC The surface normal in eye coordinates.
|
|
112
|
+
* @param {vec3} lightDirectionEC Unit vector pointing to the light source in eye coordinates.
|
|
113
|
+
* @param {czm_modelMaterial} The material properties.
|
|
114
|
+
* @return {vec3} The computed HDR color
|
|
115
|
+
*/
|
|
116
|
+
vec3 proceduralIBL(
|
|
117
|
+
vec3 positionEC,
|
|
118
|
+
vec3 normalEC,
|
|
119
|
+
vec3 lightDirectionEC,
|
|
120
|
+
czm_modelMaterial material
|
|
121
|
+
) {
|
|
122
|
+
vec3 viewDirectionEC = -normalize(positionEC);
|
|
123
|
+
vec3 positionWC = vec3(czm_inverseView * vec4(positionEC, 1.0));
|
|
124
|
+
vec3 reflectionWC = normalize(czm_inverseViewRotation * normalize(reflect(viewDirectionEC, normalEC)));
|
|
125
|
+
vec3 skyMetrics = getProceduralSkyMetrics(positionWC, reflectionWC);
|
|
126
|
+
|
|
127
|
+
float roughness = material.roughness;
|
|
128
|
+
vec3 f0 = material.specular;
|
|
129
|
+
|
|
130
|
+
vec3 specularIrradiance = getProceduralSpecularIrradiance(reflectionWC, skyMetrics, roughness);
|
|
131
|
+
float NdotV = abs(dot(normalEC, viewDirectionEC)) + 0.001;
|
|
70
132
|
vec2 brdfLut = texture(czm_brdfLut, vec2(NdotV, roughness)).rg;
|
|
71
|
-
vec3
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
133
|
+
vec3 specularColor = czm_srgbToLinear(f0 * brdfLut.x + brdfLut.y);
|
|
134
|
+
vec3 specularContribution = specularIrradiance * specularColor * model_iblFactor.y;
|
|
135
|
+
#ifdef USE_SPECULAR
|
|
136
|
+
specularContribution *= material.specularWeight;
|
|
137
|
+
#endif
|
|
138
|
+
|
|
139
|
+
vec3 diffuseIrradiance = getProceduralDiffuseIrradiance(skyMetrics);
|
|
140
|
+
vec3 diffuseColor = material.diffuse;
|
|
141
|
+
vec3 diffuseContribution = diffuseIrradiance * diffuseColor * model_iblFactor.x;
|
|
75
142
|
|
|
76
|
-
|
|
77
|
-
|
|
143
|
+
vec3 iblColor = specularContribution + diffuseContribution;
|
|
144
|
+
|
|
145
|
+
#ifdef USE_SUN_LUMINANCE
|
|
146
|
+
iblColor *= getSunLuminance(positionWC, normalEC, lightDirectionEC);
|
|
78
147
|
#endif
|
|
79
148
|
|
|
80
149
|
return iblColor;
|
|
81
150
|
}
|
|
82
151
|
|
|
152
|
+
#ifdef DIFFUSE_IBL
|
|
153
|
+
vec3 computeDiffuseIBL(vec3 cubeDir)
|
|
154
|
+
{
|
|
155
|
+
#ifdef CUSTOM_SPHERICAL_HARMONICS
|
|
156
|
+
return czm_sphericalHarmonics(cubeDir, model_sphericalHarmonicCoefficients);
|
|
157
|
+
#else
|
|
158
|
+
return czm_sphericalHarmonics(cubeDir, czm_sphericalHarmonicCoefficients);
|
|
159
|
+
#endif
|
|
160
|
+
}
|
|
161
|
+
#endif
|
|
162
|
+
|
|
163
|
+
#ifdef SPECULAR_IBL
|
|
164
|
+
vec3 sampleSpecularEnvironment(vec3 cubeDir, float roughness)
|
|
165
|
+
{
|
|
166
|
+
#ifdef CUSTOM_SPECULAR_IBL
|
|
167
|
+
float maxLod = model_specularEnvironmentMapsMaximumLOD;
|
|
168
|
+
float lod = roughness * maxLod;
|
|
169
|
+
return czm_sampleOctahedralProjection(model_specularEnvironmentMaps, model_specularEnvironmentMapsSize, cubeDir, lod, maxLod);
|
|
170
|
+
#else
|
|
171
|
+
float maxLod = czm_specularEnvironmentMapsMaximumLOD;
|
|
172
|
+
float lod = roughness * maxLod;
|
|
173
|
+
return czm_sampleOctahedralProjection(czm_specularEnvironmentMaps, czm_specularEnvironmentMapSize, cubeDir, lod, maxLod);
|
|
174
|
+
#endif
|
|
175
|
+
}
|
|
176
|
+
vec3 computeSpecularIBL(vec3 cubeDir, float NdotV, float VdotH, vec3 f0, float roughness)
|
|
177
|
+
{
|
|
178
|
+
float reflectance = czm_maximumComponent(f0);
|
|
179
|
+
vec3 f90 = vec3(clamp(reflectance * 25.0, 0.0, 1.0));
|
|
180
|
+
vec3 F = fresnelSchlick2(f0, f90, VdotH);
|
|
181
|
+
|
|
182
|
+
vec2 brdfLut = texture(czm_brdfLut, vec2(NdotV, roughness)).rg;
|
|
183
|
+
vec3 specularSample = sampleSpecularEnvironment(cubeDir, roughness);
|
|
184
|
+
|
|
185
|
+
return specularSample * (F * brdfLut.x + brdfLut.y);
|
|
186
|
+
}
|
|
187
|
+
#endif
|
|
188
|
+
|
|
83
189
|
#if defined(DIFFUSE_IBL) || defined(SPECULAR_IBL)
|
|
190
|
+
/**
|
|
191
|
+
* Compute the light contributions from environment maps and spherical harmonic coefficients
|
|
192
|
+
*
|
|
193
|
+
* @param {vec3} viewDirectionEC Unit vector pointing from the fragment to the eye position
|
|
194
|
+
* @param {vec3} normalEC The surface normal in eye coordinates
|
|
195
|
+
* @param {vec3} lightDirectionEC Unit vector pointing to the light source in eye coordinates.
|
|
196
|
+
* @param {czm_modelMaterial} The material properties.
|
|
197
|
+
* @return {vec3} The computed HDR color
|
|
198
|
+
*/
|
|
84
199
|
vec3 textureIBL(
|
|
85
|
-
vec3
|
|
200
|
+
vec3 viewDirectionEC,
|
|
86
201
|
vec3 normalEC,
|
|
87
202
|
vec3 lightDirectionEC,
|
|
88
|
-
|
|
203
|
+
czm_modelMaterial material
|
|
89
204
|
) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
float
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
vec3 diffuseIrradiance = czm_sphericalHarmonics(cubeDir, model_sphericalHarmonicCoefficients);
|
|
112
|
-
#else
|
|
113
|
-
vec3 diffuseIrradiance = czm_sphericalHarmonics(cubeDir, czm_sphericalHarmonicCoefficients);
|
|
114
|
-
#endif
|
|
115
|
-
#else
|
|
116
|
-
vec3 diffuseIrradiance = vec3(0.0);
|
|
117
|
-
#endif
|
|
205
|
+
// Find the direction in which to sample the environment map
|
|
206
|
+
vec3 cubeDir = normalize(model_iblReferenceFrameMatrix * normalize(reflect(-viewDirectionEC, normalEC)));
|
|
207
|
+
|
|
208
|
+
#ifdef DIFFUSE_IBL
|
|
209
|
+
vec3 diffuseContribution = computeDiffuseIBL(cubeDir) * material.diffuse;
|
|
210
|
+
#else
|
|
211
|
+
vec3 diffuseContribution = vec3(0.0);
|
|
212
|
+
#endif
|
|
213
|
+
|
|
214
|
+
float roughness = material.roughness;
|
|
215
|
+
|
|
216
|
+
#ifdef USE_ANISOTROPY
|
|
217
|
+
// Update environment map sampling direction to account for anisotropic distortion of specular reflection
|
|
218
|
+
vec3 anisotropyDirection = material.anisotropicB;
|
|
219
|
+
vec3 anisotropicTangent = cross(anisotropyDirection, viewDirectionEC);
|
|
220
|
+
vec3 anisotropicNormal = cross(anisotropicTangent, anisotropyDirection);
|
|
221
|
+
float bendFactor = 1.0 - material.anisotropyStrength * (1.0 - roughness);
|
|
222
|
+
float bendFactorPow4 = bendFactor * bendFactor * bendFactor * bendFactor;
|
|
223
|
+
vec3 bentNormal = normalize(mix(anisotropicNormal, normalEC, bendFactorPow4));
|
|
224
|
+
cubeDir = normalize(model_iblReferenceFrameMatrix * normalize(reflect(-viewDirectionEC, bentNormal)));
|
|
225
|
+
#endif
|
|
118
226
|
|
|
119
227
|
#ifdef SPECULAR_IBL
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
specularIBL *= F * brdfLut.x + brdfLut.y;
|
|
132
|
-
#else
|
|
133
|
-
vec3 specularIBL = vec3(0.0);
|
|
228
|
+
float NdotV = abs(dot(normalEC, viewDirectionEC)) + 0.001;
|
|
229
|
+
vec3 halfwayDirectionEC = normalize(viewDirectionEC + lightDirectionEC);
|
|
230
|
+
float VdotH = clamp(dot(viewDirectionEC, halfwayDirectionEC), 0.0, 1.0);
|
|
231
|
+
vec3 f0 = material.specular;
|
|
232
|
+
vec3 specularContribution = computeSpecularIBL(cubeDir, NdotV, VdotH, f0, roughness);
|
|
233
|
+
#else
|
|
234
|
+
vec3 specularContribution = vec3(0.0);
|
|
235
|
+
#endif
|
|
236
|
+
|
|
237
|
+
#ifdef USE_SPECULAR
|
|
238
|
+
specularContribution *= material.specularWeight;
|
|
134
239
|
#endif
|
|
135
240
|
|
|
136
|
-
return
|
|
241
|
+
return diffuseContribution + specularContribution;
|
|
137
242
|
}
|
|
138
243
|
#endif
|
|
139
|
-
|
|
140
|
-
vec3 imageBasedLightingStage(
|
|
141
|
-
vec3 positionEC,
|
|
142
|
-
vec3 normalEC,
|
|
143
|
-
vec3 lightDirectionEC,
|
|
144
|
-
vec3 lightColorHdr,
|
|
145
|
-
czm_pbrParameters pbrParameters
|
|
146
|
-
) {
|
|
147
|
-
#if defined(DIFFUSE_IBL) || defined(SPECULAR_IBL)
|
|
148
|
-
// Environment maps were provided, use them for IBL
|
|
149
|
-
return textureIBL(
|
|
150
|
-
positionEC,
|
|
151
|
-
normalEC,
|
|
152
|
-
lightDirectionEC,
|
|
153
|
-
pbrParameters
|
|
154
|
-
);
|
|
155
|
-
#else
|
|
156
|
-
// Use the procedural IBL if there are no environment maps
|
|
157
|
-
return proceduralIBL(
|
|
158
|
-
positionEC,
|
|
159
|
-
normalEC,
|
|
160
|
-
lightDirectionEC,
|
|
161
|
-
lightColorHdr,
|
|
162
|
-
pbrParameters
|
|
163
|
-
);
|
|
164
|
-
#endif
|
|
165
|
-
}
|