@cesium/engine 9.0.0 → 9.2.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 +56 -105
- package/Build/Workers/{chunk-VR5RBW52.js → chunk-26NE4LRW.js} +7 -7
- package/Build/Workers/{chunk-P2YAAMT2.js → chunk-26XJDV3D.js} +15 -15
- package/Build/Workers/{chunk-L4BW3RUA.js → chunk-2TRB253J.js} +7 -7
- package/Build/Workers/{chunk-NP2GYYE5.js → chunk-3PV5HQ2R.js} +6 -6
- package/Build/Workers/{chunk-BCU2LH5T.js → chunk-3VDHTBY5.js} +10 -10
- package/Build/Workers/{chunk-WHUSTDIB.js → chunk-4RG6WOXH.js} +10 -10
- package/Build/Workers/{chunk-P4XKB3QZ.js → chunk-5OK5JFDP.js} +5 -5
- package/Build/Workers/{chunk-2ZBL3MVO.js → chunk-7HLZRYGD.js} +10 -12
- package/Build/Workers/chunk-7PFZ4Z7C.js +961 -0
- package/Build/Workers/{chunk-24YTYWNB.js → chunk-A5CSB5ZE.js} +11 -13
- package/Build/Workers/{chunk-RMOEYCZW.js → chunk-AROLUUGS.js} +2 -2
- package/Build/Workers/{chunk-3NCVAGDA.js → chunk-BBBTT36L.js} +14 -14
- package/Build/Workers/{chunk-QKBGRKKG.js → chunk-BNT2SNWU.js} +4 -4
- package/Build/Workers/{chunk-LQJ5FFFR.js → chunk-CFBGPZU6.js} +11 -13
- package/Build/Workers/{chunk-C6OI26DR.js → chunk-CVCVMOQA.js} +1 -1
- package/Build/Workers/{chunk-SS4ESNE3.js → chunk-DIVFF6DK.js} +2 -2
- package/Build/Workers/{chunk-PXB7T27O.js → chunk-EJZVBTX4.js} +6 -6
- package/Build/Workers/{chunk-TZORKRNK.js → chunk-EODIOQ35.js} +1 -1
- package/Build/Workers/{chunk-QCQUZGXI.js → chunk-ETC45PHH.js} +5 -6
- package/Build/Workers/{chunk-E6WXPSJS.js → chunk-G7IAO7CW.js} +7 -7
- package/Build/Workers/{chunk-X2F6BEPY.js → chunk-GOQEANLM.js} +16 -16
- package/Build/Workers/{chunk-7COR472O.js → chunk-GUFV24F4.js} +7197 -5096
- package/Build/Workers/{chunk-5TIV3L26.js → chunk-GX2BWBN2.js} +13 -13
- package/Build/Workers/{chunk-ADOVHYWO.js → chunk-GX5LMUGZ.js} +469 -6
- package/Build/Workers/{chunk-2632RVPI.js → chunk-I6CW7ZE5.js} +7 -7
- package/Build/Workers/{chunk-YDVSBWEO.js → chunk-IF2OX6R4.js} +3 -5
- package/Build/Workers/{chunk-RSJXEO2A.js → chunk-IXYFH7DV.js} +95 -155
- package/Build/Workers/{chunk-ZNVSKMQ2.js → chunk-K5F23SZO.js} +6 -6
- package/Build/Workers/{chunk-MWV7IZK4.js → chunk-KTZK2UDR.js} +7 -7
- package/Build/Workers/{chunk-HBQPB6IH.js → chunk-LZFFO4KB.js} +12 -12
- package/Build/Workers/{chunk-GFA4SMXV.js → chunk-OYP23VAL.js} +11 -11
- package/Build/Workers/{chunk-ZYPTP7GS.js → chunk-PHT53MCH.js} +11 -11
- package/Build/Workers/{chunk-TJBU6GML.js → chunk-PUQR43HZ.js} +6 -6
- package/Build/Workers/{chunk-CO35JNNE.js → chunk-QZIWFSRM.js} +4 -4
- package/Build/Workers/{chunk-C3XBUYBO.js → chunk-RDR4KVPA.js} +17 -17
- package/Build/Workers/{chunk-YV4H2Y7M.js → chunk-RRUO4QEK.js} +4 -4
- package/Build/Workers/{chunk-LAQP3SCC.js → chunk-RTIT7UDN.js} +2 -2
- package/Build/Workers/{chunk-Z7FQLK6N.js → chunk-SC3TBKST.js} +4 -4
- package/Build/Workers/{chunk-GXUXEOE2.js → chunk-TDIGL45B.js} +1 -1
- package/Build/Workers/{chunk-EOXYZ34O.js → chunk-TP4FFUAH.js} +2 -2
- package/Build/Workers/{chunk-N4KXMWQU.js → chunk-U2LSTOMA.js} +2 -2
- package/Build/Workers/{chunk-6WF3KIF5.js → chunk-U6MTSO6A.js} +47 -84
- package/Build/Workers/{chunk-I37B3MZ2.js → chunk-UICVDDCQ.js} +1 -1
- package/Build/Workers/{chunk-DPUSFA7S.js → chunk-UKJCFXVV.js} +6 -6
- package/Build/Workers/{chunk-EPKE7GE3.js → chunk-UYKG3UFK.js} +5 -5
- package/Build/Workers/{chunk-RV7ZOSS6.js → chunk-W4OS542B.js} +13 -13
- package/Build/Workers/{chunk-DGDUKCJJ.js → chunk-WHDEZSAL.js} +6 -6
- package/Build/Workers/{chunk-NZWNZA6S.js → chunk-WOYQB5HM.js} +5 -5
- package/Build/Workers/{chunk-M2AYBTNH.js → chunk-WP3LCUOE.js} +13 -13
- package/Build/Workers/{chunk-73FKKY52.js → chunk-YGNQJ4YI.js} +5 -5
- package/Build/Workers/{chunk-SE4PXOEA.js → chunk-YGTWKLFY.js} +19 -19
- package/Build/Workers/{chunk-5R6VWLMH.js → chunk-ZHJDE6JN.js} +6 -6
- package/Build/Workers/combineGeometry.js +22 -24
- package/Build/Workers/createBoxGeometry.js +16 -18
- package/Build/Workers/createBoxOutlineGeometry.js +14 -16
- package/Build/Workers/createCircleGeometry.js +24 -26
- package/Build/Workers/createCircleOutlineGeometry.js +17 -19
- package/Build/Workers/createCoplanarPolygonGeometry.js +33 -34
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +29 -31
- package/Build/Workers/createCorridorGeometry.js +27 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +26 -28
- package/Build/Workers/createCylinderGeometry.js +18 -20
- package/Build/Workers/createCylinderOutlineGeometry.js +16 -18
- package/Build/Workers/createEllipseGeometry.js +24 -26
- package/Build/Workers/createEllipseOutlineGeometry.js +17 -19
- package/Build/Workers/createEllipsoidGeometry.js +17 -19
- package/Build/Workers/createEllipsoidOutlineGeometry.js +16 -18
- package/Build/Workers/createFrustumGeometry.js +16 -18
- package/Build/Workers/createFrustumOutlineGeometry.js +18 -19
- package/Build/Workers/createGeometry.js +22 -24
- package/Build/Workers/createGroundPolylineGeometry.js +23 -25
- package/Build/Workers/createPlaneGeometry.js +14 -16
- package/Build/Workers/createPlaneOutlineGeometry.js +13 -15
- package/Build/Workers/createPolygonGeometry.js +32 -34
- package/Build/Workers/createPolygonOutlineGeometry.js +28 -30
- package/Build/Workers/createPolylineGeometry.js +23 -25
- package/Build/Workers/createPolylineVolumeGeometry.js +29 -31
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +25 -27
- package/Build/Workers/createRectangleGeometry.js +27 -29
- package/Build/Workers/createRectangleOutlineGeometry.js +18 -20
- package/Build/Workers/createSimplePolylineGeometry.js +21 -23
- package/Build/Workers/createSphereGeometry.js +17 -19
- package/Build/Workers/createSphereOutlineGeometry.js +16 -18
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +14 -16
- package/Build/Workers/createVectorTileGeometries.js +22 -24
- package/Build/Workers/createVectorTilePoints.js +12 -12
- package/Build/Workers/createVectorTilePolygons.js +20 -22
- package/Build/Workers/createVectorTilePolylines.js +14 -16
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +23 -25
- package/Build/Workers/createVerticesFromHeightmap.js +23 -25
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +19 -22
- package/Build/Workers/createWallGeometry.js +22 -24
- package/Build/Workers/createWallOutlineGeometry.js +21 -23
- package/Build/Workers/decodeDraco.js +11 -11
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +12 -19
- package/Build/Workers/decodeI3S.js +10 -11
- package/Build/Workers/transcodeKTX2.js +44 -80
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +20 -22
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/Math.js +0 -5
- package/Source/Core/PixelFormat.js +1 -0
- package/Source/Core/Rectangle.js +89 -0
- package/Source/Core/TaskProcessor.js +19 -3
- package/Source/Core/sampleTerrain.js +3 -3
- package/Source/DataSources/DataSourceDisplay.js +5 -0
- package/Source/Renderer/ShaderBuilder.js +6 -3
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Billboard.js +7 -5
- package/Source/Scene/Cesium3DTile.js +65 -0
- package/Source/Scene/Cesium3DTileset.js +48 -1
- package/Source/Scene/ClippingPolygon.js +212 -0
- package/Source/Scene/ClippingPolygonCollection.js +968 -0
- package/Source/Scene/Globe.js +14 -0
- package/Source/Scene/GlobeSurfaceShaderSet.js +81 -15
- package/Source/Scene/GlobeSurfaceTileProvider.js +81 -1
- package/Source/Scene/GltfLoader.js +458 -435
- package/Source/Scene/GltfLoaderUtil.js +3 -12
- package/Source/Scene/GltfPipeline/forEachTextureInMaterial.js +23 -7
- package/Source/Scene/GltfStructuralMetadataLoader.js +11 -9
- package/Source/Scene/Label.js +1 -1
- 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/LightingPipelineStage.js +2 -4
- package/Source/Scene/Model/MaterialPipelineStage.js +346 -29
- package/Source/Scene/Model/Model.js +91 -3
- package/Source/Scene/Model/Model3DTileContent.js +21 -0
- package/Source/Scene/Model/ModelClippingPolygonsPipelineStage.js +92 -0
- package/Source/Scene/Model/ModelSceneGraph.js +5 -0
- package/Source/Scene/Model/ModelUtility.js +3 -0
- package/Source/Scene/Model/VerticalExaggerationPipelineStage.js +4 -6
- package/Source/Scene/ModelComponents.js +169 -1
- package/Source/Scene/PickDepth.js +23 -15
- package/Source/Scene/ResourceCache.js +41 -50
- package/Source/Scene/ResourceCacheKey.js +41 -53
- package/Source/Scene/Terrain.js +2 -2
- package/Source/Shaders/Builtin/CzmBuiltins.js +6 -8
- package/Source/Shaders/Builtin/Functions/clipPolygons.glsl +37 -0
- package/Source/Shaders/Builtin/Functions/clipPolygons.js +39 -0
- 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/Functions/unpackClippingExtents.glsl +14 -0
- package/Source/Shaders/Builtin/Functions/unpackClippingExtents.js +15 -0
- package/Source/Shaders/Builtin/Structs/modelMaterial.glsl +14 -0
- package/Source/Shaders/Builtin/Structs/modelMaterial.js +14 -0
- package/Source/Shaders/GlobeFS.glsl +13 -1
- package/Source/Shaders/GlobeFS.js +13 -1
- package/Source/Shaders/GlobeVS.glsl +32 -0
- package/Source/Shaders/GlobeVS.js +32 -0
- package/Source/Shaders/Model/GeometryStageVS.glsl +1 -1
- package/Source/Shaders/Model/GeometryStageVS.js +1 -1
- 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 +399 -137
- package/Source/Shaders/Model/MaterialStageFS.js +399 -137
- package/Source/Shaders/Model/ModelClippingPolygonsStageFS.glsl +6 -0
- package/Source/Shaders/Model/ModelClippingPolygonsStageFS.js +8 -0
- package/Source/Shaders/Model/ModelClippingPolygonsStageVS.glsl +27 -0
- package/Source/Shaders/Model/ModelClippingPolygonsStageVS.js +29 -0
- package/Source/Shaders/Model/ModelFS.glsl +6 -0
- package/Source/Shaders/Model/ModelFS.js +7 -1
- package/Source/Shaders/Model/ModelVS.glsl +4 -0
- package/Source/Shaders/Model/ModelVS.js +4 -0
- package/Source/Shaders/PolygonSignedDistanceFS.glsl +100 -0
- package/Source/Shaders/PolygonSignedDistanceFS.js +101 -0
- package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
- package/index.d.ts +230 -4
- package/index.js +234 -229
- package/package.json +1 -1
- package/Build/Workers/chunk-2KACWKS4.js +0 -501
- package/Build/Workers/chunk-2XPLH3JY.js +0 -2977
- package/Build/Workers/chunk-X6XOMPWL.js +0 -73
- package/Source/Shaders/Builtin/Functions/defaultPbrMaterial.glsl +0 -16
- package/Source/Shaders/Builtin/Functions/defaultPbrMaterial.js +0 -18
- 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
|
@@ -6,9 +6,42 @@ export default "vec3 lambertianDiffuse(vec3 diffuseColor)\n\
|
|
|
6
6
|
\n\
|
|
7
7
|
vec3 fresnelSchlick2(vec3 f0, vec3 f90, float VdotH)\n\
|
|
8
8
|
{\n\
|
|
9
|
-
|
|
9
|
+
float versine = 1.0 - VdotH;\n\
|
|
10
|
+
// pow(versine, 5.0) is slow. See https://stackoverflow.com/a/68793086/10082269\n\
|
|
11
|
+
float versineSquared = versine * versine;\n\
|
|
12
|
+
return f0 + (f90 - f0) * versineSquared * versineSquared * versine;\n\
|
|
10
13
|
}\n\
|
|
11
14
|
\n\
|
|
15
|
+
#ifdef USE_ANISOTROPY\n\
|
|
16
|
+
/**\n\
|
|
17
|
+
* @param {float} roughness Material roughness (along the anisotropy bitangent)\n\
|
|
18
|
+
* @param {float} tangentialRoughness Anisotropic roughness (along the anisotropy tangent)\n\
|
|
19
|
+
* @param {vec3} lightDirection The direction from the fragment to the light source, transformed to tangent-bitangent-normal coordinates\n\
|
|
20
|
+
* @param {vec3} viewDirection The direction from the fragment to the camera, transformed to tangent-bitangent-normal coordinates\n\
|
|
21
|
+
*/\n\
|
|
22
|
+
float smithVisibilityGGX_anisotropic(float roughness, float tangentialRoughness, vec3 lightDirection, vec3 viewDirection)\n\
|
|
23
|
+
{\n\
|
|
24
|
+
vec3 roughnessScale = vec3(tangentialRoughness, roughness, 1.0);\n\
|
|
25
|
+
float GGXV = lightDirection.z * length(roughnessScale * viewDirection);\n\
|
|
26
|
+
float GGXL = viewDirection.z * length(roughnessScale * lightDirection);\n\
|
|
27
|
+
float v = 0.5 / (GGXV + GGXL);\n\
|
|
28
|
+
return clamp(v, 0.0, 1.0);\n\
|
|
29
|
+
}\n\
|
|
30
|
+
\n\
|
|
31
|
+
/**\n\
|
|
32
|
+
* @param {float} roughness Material roughness (along the anisotropy bitangent)\n\
|
|
33
|
+
* @param {float} tangentialRoughness Anisotropic roughness (along the anisotropy tangent)\n\
|
|
34
|
+
* @param {vec3} halfwayDirection The unit vector halfway between light and view directions, transformed to tangent-bitangent-normal coordinates\n\
|
|
35
|
+
*/\n\
|
|
36
|
+
float GGX_anisotropic(float roughness, float tangentialRoughness, vec3 halfwayDirection)\n\
|
|
37
|
+
{\n\
|
|
38
|
+
float roughnessSquared = roughness * tangentialRoughness;\n\
|
|
39
|
+
vec3 f = halfwayDirection * vec3(roughness, tangentialRoughness, roughnessSquared);\n\
|
|
40
|
+
float w2 = roughnessSquared / dot(f, f);\n\
|
|
41
|
+
return roughnessSquared * w2 * w2 / czm_pi;\n\
|
|
42
|
+
}\n\
|
|
43
|
+
#endif\n\
|
|
44
|
+
\n\
|
|
12
45
|
float smithVisibilityG1(float NdotV, float roughness)\n\
|
|
13
46
|
{\n\
|
|
14
47
|
// this is the k value for direct lighting.\n\
|
|
@@ -17,14 +50,34 @@ float smithVisibilityG1(float NdotV, float roughness)\n\
|
|
|
17
50
|
return NdotV / (NdotV * (1.0 - k) + k);\n\
|
|
18
51
|
}\n\
|
|
19
52
|
\n\
|
|
53
|
+
/**\n\
|
|
54
|
+
* Estimate the geometric self-shadowing of the microfacets in a surface,\n\
|
|
55
|
+
* using the Schlick GGX approximation of a Smith visibility function.\n\
|
|
56
|
+
*\n\
|
|
57
|
+
* @param {float} roughness The roughness of the material.\n\
|
|
58
|
+
* @param {float} NdotL The cosine of the angle between the surface normal and the direction to the light source.\n\
|
|
59
|
+
* @param {float} NdotV The cosine of the angle between the surface normal and the direction to the camera.\n\
|
|
60
|
+
*/\n\
|
|
20
61
|
float smithVisibilityGGX(float roughness, float NdotL, float NdotV)\n\
|
|
21
62
|
{\n\
|
|
63
|
+
// Avoid divide-by-zero errors\n\
|
|
64
|
+
NdotL = clamp(NdotL, 0.001, 1.0);\n\
|
|
65
|
+
NdotV += 0.001;\n\
|
|
22
66
|
return (\n\
|
|
23
67
|
smithVisibilityG1(NdotL, roughness) *\n\
|
|
24
68
|
smithVisibilityG1(NdotV, roughness)\n\
|
|
25
|
-
);\n\
|
|
69
|
+
) / (4.0 * NdotL * NdotV);\n\
|
|
26
70
|
}\n\
|
|
27
71
|
\n\
|
|
72
|
+
/**\n\
|
|
73
|
+
* Estimate the fraction of the microfacets in a surface that are aligned with \n\
|
|
74
|
+
* the halfway vector, which is aligned halfway between the directions from\n\
|
|
75
|
+
* the fragment to the camera and from the fragment to the light source.\n\
|
|
76
|
+
*\n\
|
|
77
|
+
* @param {float} roughness The roughness of the material.\n\
|
|
78
|
+
* @param {float} NdotH The cosine of the angle between the surface normal and the halfway vector.\n\
|
|
79
|
+
* @return {float} The fraction of microfacets aligned to the halfway vector.\n\
|
|
80
|
+
*/\n\
|
|
28
81
|
float GGX(float roughness, float NdotH)\n\
|
|
29
82
|
{\n\
|
|
30
83
|
float roughnessSquared = roughness * roughness;\n\
|
|
@@ -32,70 +85,81 @@ float GGX(float roughness, float NdotH)\n\
|
|
|
32
85
|
return roughnessSquared / (czm_pi * f * f);\n\
|
|
33
86
|
}\n\
|
|
34
87
|
\n\
|
|
88
|
+
/**\n\
|
|
89
|
+
* Compute the strength of the specular reflection due to direct lighting.\n\
|
|
90
|
+
*\n\
|
|
91
|
+
* @param {vec3} normal The surface normal.\n\
|
|
92
|
+
* @param {vec3} lightDirection The unit vector pointing from the fragment to the light source.\n\
|
|
93
|
+
* @param {vec3} viewDirection The unit vector pointing from the fragment to the camera.\n\
|
|
94
|
+
* @param {vec3} halfwayDirection The unit vector pointing from the fragment to halfway between the light source and the camera.\n\
|
|
95
|
+
* @param {float} roughness The roughness of the material.\n\
|
|
96
|
+
* @return {float} The strength of the specular reflection.\n\
|
|
97
|
+
*/\n\
|
|
98
|
+
float computeDirectSpecularStrength(vec3 normal, vec3 lightDirection, vec3 viewDirection, vec3 halfwayDirection, float roughness)\n\
|
|
99
|
+
{\n\
|
|
100
|
+
float NdotL = dot(normal, lightDirection);\n\
|
|
101
|
+
float NdotV = abs(dot(normal, viewDirection));\n\
|
|
102
|
+
float G = smithVisibilityGGX(roughness, NdotL, NdotV);\n\
|
|
103
|
+
float NdotH = clamp(dot(normal, halfwayDirection), 0.0, 1.0);\n\
|
|
104
|
+
float D = GGX(roughness, NdotH);\n\
|
|
105
|
+
return G * D;\n\
|
|
106
|
+
}\n\
|
|
107
|
+
\n\
|
|
35
108
|
/**\n\
|
|
36
109
|
* Compute the diffuse and specular contributions using physically based\n\
|
|
37
110
|
* rendering. This function only handles direct lighting.\n\
|
|
38
111
|
* <p>\n\
|
|
39
112
|
* This function only handles the lighting calculations. Metallic/roughness\n\
|
|
40
|
-
* and specular/glossy must be handled separately. See {@
|
|
113
|
+
* and specular/glossy must be handled separately. See {@MaterialStageFS}\n\
|
|
41
114
|
* </p>\n\
|
|
42
115
|
*\n\
|
|
43
|
-
* @name
|
|
116
|
+
* @name czm_pbrLighting\n\
|
|
44
117
|
* @glslFunction\n\
|
|
45
118
|
*\n\
|
|
46
|
-
* @param {vec3}
|
|
119
|
+
* @param {vec3} viewDirectionEC Unit vector pointing from the fragment to the eye position\n\
|
|
47
120
|
* @param {vec3} normalEC The surface normal in eye coordinates\n\
|
|
48
121
|
* @param {vec3} lightDirectionEC Unit vector pointing to the light source in eye coordinates.\n\
|
|
49
|
-
* @param {
|
|
50
|
-
* @param {czm_pbrParameters} The computed PBR parameters.\n\
|
|
122
|
+
* @param {czm_modelMaterial} The material properties.\n\
|
|
51
123
|
* @return {vec3} The computed HDR color\n\
|
|
52
|
-
*\n\
|
|
53
|
-
* @example\n\
|
|
54
|
-
* czm_pbrParameters pbrParameters = czm_pbrMetallicRoughnessMaterial(\n\
|
|
55
|
-
* baseColor,\n\
|
|
56
|
-
* metallic,\n\
|
|
57
|
-
* roughness\n\
|
|
58
|
-
* );\n\
|
|
59
|
-
* vec3 color = czm_pbrlighting(\n\
|
|
60
|
-
* positionEC,\n\
|
|
61
|
-
* normalEC,\n\
|
|
62
|
-
* lightDirectionEC,\n\
|
|
63
|
-
* lightColorHdr,\n\
|
|
64
|
-
* pbrParameters);\n\
|
|
65
124
|
*/\n\
|
|
66
|
-
vec3 czm_pbrLighting(\n\
|
|
67
|
-
vec3 positionEC,\n\
|
|
68
|
-
vec3 normalEC,\n\
|
|
69
|
-
vec3 lightDirectionEC,\n\
|
|
70
|
-
vec3 lightColorHdr,\n\
|
|
71
|
-
czm_pbrParameters pbrParameters\n\
|
|
72
|
-
)\n\
|
|
125
|
+
vec3 czm_pbrLighting(vec3 viewDirectionEC, vec3 normalEC, vec3 lightDirectionEC, czm_modelMaterial material)\n\
|
|
73
126
|
{\n\
|
|
74
|
-
vec3
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
vec3 n = normalEC;\n\
|
|
78
|
-
float NdotL = clamp(dot(n, l), 0.001, 1.0);\n\
|
|
79
|
-
float NdotV = abs(dot(n, v)) + 0.001;\n\
|
|
80
|
-
float NdotH = clamp(dot(n, h), 0.0, 1.0);\n\
|
|
81
|
-
float LdotH = clamp(dot(l, h), 0.0, 1.0);\n\
|
|
82
|
-
float VdotH = clamp(dot(v, h), 0.0, 1.0);\n\
|
|
127
|
+
vec3 halfwayDirectionEC = normalize(viewDirectionEC + lightDirectionEC);\n\
|
|
128
|
+
float VdotH = clamp(dot(viewDirectionEC, halfwayDirectionEC), 0.0, 1.0);\n\
|
|
129
|
+
float NdotL = clamp(dot(normalEC, lightDirectionEC), 0.001, 1.0);\n\
|
|
83
130
|
\n\
|
|
84
|
-
vec3 f0 =
|
|
85
|
-
float reflectance =
|
|
131
|
+
vec3 f0 = material.specular;\n\
|
|
132
|
+
float reflectance = czm_maximumComponent(f0);\n\
|
|
133
|
+
// Typical dielectrics will have reflectance 0.04, so f90 will be 1.0.\n\
|
|
134
|
+
// In this case, at grazing angle, all incident energy is reflected.\n\
|
|
86
135
|
vec3 f90 = vec3(clamp(reflectance * 25.0, 0.0, 1.0));\n\
|
|
87
136
|
vec3 F = fresnelSchlick2(f0, f90, VdotH);\n\
|
|
88
137
|
\n\
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
138
|
+
#if defined(USE_SPECULAR)\n\
|
|
139
|
+
F *= material.specularWeight;\n\
|
|
140
|
+
#endif\n\
|
|
141
|
+
\n\
|
|
142
|
+
float alpha = material.roughness;\n\
|
|
143
|
+
#ifdef USE_ANISOTROPY\n\
|
|
144
|
+
mat3 tbn = mat3(material.anisotropicT, material.anisotropicB, normalEC);\n\
|
|
145
|
+
vec3 lightDirection = lightDirectionEC * tbn;\n\
|
|
146
|
+
vec3 viewDirection = viewDirectionEC * tbn;\n\
|
|
147
|
+
vec3 halfwayDirection = halfwayDirectionEC * tbn;\n\
|
|
148
|
+
float anisotropyStrength = material.anisotropyStrength;\n\
|
|
149
|
+
float tangentialRoughness = mix(alpha, 1.0, anisotropyStrength * anisotropyStrength);\n\
|
|
150
|
+
float G = smithVisibilityGGX_anisotropic(alpha, tangentialRoughness, lightDirection, viewDirection);\n\
|
|
151
|
+
float D = GGX_anisotropic(alpha, tangentialRoughness, halfwayDirection);\n\
|
|
152
|
+
vec3 specularContribution = F * G * D;\n\
|
|
153
|
+
#else\n\
|
|
154
|
+
float specularStrength = computeDirectSpecularStrength(normalEC, lightDirectionEC, viewDirectionEC, halfwayDirectionEC, alpha);\n\
|
|
155
|
+
vec3 specularContribution = F * specularStrength;\n\
|
|
156
|
+
#endif\n\
|
|
93
157
|
\n\
|
|
94
|
-
vec3 diffuseColor =
|
|
158
|
+
vec3 diffuseColor = material.diffuse;\n\
|
|
95
159
|
// F here represents the specular contribution\n\
|
|
96
160
|
vec3 diffuseContribution = (1.0 - F) * lambertianDiffuse(diffuseColor);\n\
|
|
97
161
|
\n\
|
|
98
162
|
// Lo = (diffuse + specular) * Li * NdotL\n\
|
|
99
|
-
return (diffuseContribution + specularContribution) * NdotL
|
|
163
|
+
return (diffuseContribution + specularContribution) * NdotL;\n\
|
|
100
164
|
}\n\
|
|
101
165
|
";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
vec2 getLookupUv(vec2 dimensions, int i) {
|
|
2
|
+
int pixY = i / int(dimensions.x);
|
|
3
|
+
int pixX = i - (pixY * int(dimensions.x));
|
|
4
|
+
float pixelWidth = 1.0 / dimensions.x;
|
|
5
|
+
float pixelHeight = 1.0 / dimensions.y;
|
|
6
|
+
float u = (float(pixX) + 0.5) * pixelWidth; // sample from center of pixel
|
|
7
|
+
float v = (float(pixY) + 0.5) * pixelHeight;
|
|
8
|
+
return vec2(u, v);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
vec4 czm_unpackClippingExtents(highp sampler2D extentsTexture, int index) {
|
|
12
|
+
vec2 textureDimensions = vec2(textureSize(extentsTexture, 0));
|
|
13
|
+
return texture(extentsTexture, getLookupUv(textureDimensions, index));
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
+
export default "vec2 getLookupUv(vec2 dimensions, int i) {\n\
|
|
3
|
+
int pixY = i / int(dimensions.x);\n\
|
|
4
|
+
int pixX = i - (pixY * int(dimensions.x));\n\
|
|
5
|
+
float pixelWidth = 1.0 / dimensions.x;\n\
|
|
6
|
+
float pixelHeight = 1.0 / dimensions.y;\n\
|
|
7
|
+
float u = (float(pixX) + 0.5) * pixelWidth; // sample from center of pixel\n\
|
|
8
|
+
float v = (float(pixY) + 0.5) * pixelHeight;\n\
|
|
9
|
+
return vec2(u, v);\n\
|
|
10
|
+
}\n\
|
|
11
|
+
\n\
|
|
12
|
+
vec4 czm_unpackClippingExtents(highp sampler2D extentsTexture, int index) {\n\
|
|
13
|
+
vec2 textureDimensions = vec2(textureSize(extentsTexture, 0));\n\
|
|
14
|
+
return texture(extentsTexture, getLookupUv(textureDimensions, index));\n\
|
|
15
|
+
}";
|
|
@@ -26,4 +26,18 @@ struct czm_modelMaterial {
|
|
|
26
26
|
vec3 normalEC;
|
|
27
27
|
float occlusion;
|
|
28
28
|
vec3 emissive;
|
|
29
|
+
#ifdef USE_SPECULAR
|
|
30
|
+
float specularWeight;
|
|
31
|
+
#endif
|
|
32
|
+
#ifdef USE_ANISOTROPY
|
|
33
|
+
vec3 anisotropicT;
|
|
34
|
+
vec3 anisotropicB;
|
|
35
|
+
float anisotropyStrength;
|
|
36
|
+
#endif
|
|
37
|
+
#ifdef USE_CLEARCOAT
|
|
38
|
+
float clearcoatFactor;
|
|
39
|
+
float clearcoatRoughness;
|
|
40
|
+
vec3 clearcoatNormal;
|
|
41
|
+
// Add clearcoatF0 when KHR_materials_ior is implemented
|
|
42
|
+
#endif
|
|
29
43
|
};
|
|
@@ -27,5 +27,19 @@ struct czm_modelMaterial {\n\
|
|
|
27
27
|
vec3 normalEC;\n\
|
|
28
28
|
float occlusion;\n\
|
|
29
29
|
vec3 emissive;\n\
|
|
30
|
+
#ifdef USE_SPECULAR\n\
|
|
31
|
+
float specularWeight;\n\
|
|
32
|
+
#endif\n\
|
|
33
|
+
#ifdef USE_ANISOTROPY\n\
|
|
34
|
+
vec3 anisotropicT;\n\
|
|
35
|
+
vec3 anisotropicB;\n\
|
|
36
|
+
float anisotropyStrength;\n\
|
|
37
|
+
#endif\n\
|
|
38
|
+
#ifdef USE_CLEARCOAT\n\
|
|
39
|
+
float clearcoatFactor;\n\
|
|
40
|
+
float clearcoatRoughness;\n\
|
|
41
|
+
vec3 clearcoatNormal;\n\
|
|
42
|
+
// Add clearcoatF0 when KHR_materials_ior is implemented\n\
|
|
43
|
+
#endif\n\
|
|
30
44
|
};\n\
|
|
31
45
|
";
|
|
@@ -77,6 +77,12 @@ uniform mat4 u_clippingPlanesMatrix;
|
|
|
77
77
|
uniform vec4 u_clippingPlanesEdgeStyle;
|
|
78
78
|
#endif
|
|
79
79
|
|
|
80
|
+
#ifdef ENABLE_CLIPPING_POLYGONS
|
|
81
|
+
uniform highp sampler2D u_clippingDistance;
|
|
82
|
+
in vec2 v_clippingPosition;
|
|
83
|
+
flat in int v_regionIndex;
|
|
84
|
+
#endif
|
|
85
|
+
|
|
80
86
|
#if defined(GROUND_ATMOSPHERE) || defined(FOG) && defined(DYNAMIC_ATMOSPHERE_LIGHTING) && (defined(ENABLE_VERTEX_LIGHTING) || defined(ENABLE_DAYNIGHT_SHADING))
|
|
81
87
|
uniform float u_minimumBrightness;
|
|
82
88
|
#endif
|
|
@@ -201,7 +207,7 @@ vec4 sampleAndBlend(
|
|
|
201
207
|
|
|
202
208
|
#ifdef APPLY_COLOR_TO_ALPHA
|
|
203
209
|
vec3 colorDiff = abs(color.rgb - colorToAlpha.rgb);
|
|
204
|
-
colorDiff.r =
|
|
210
|
+
colorDiff.r = czm_maximumComponent(colorDiff);
|
|
205
211
|
alpha = czm_branchFreeTernary(colorDiff.r < colorToAlpha.a, 0.0, alpha);
|
|
206
212
|
#endif
|
|
207
213
|
|
|
@@ -413,6 +419,12 @@ void main()
|
|
|
413
419
|
}
|
|
414
420
|
#endif
|
|
415
421
|
|
|
422
|
+
#ifdef ENABLE_CLIPPING_POLYGONS
|
|
423
|
+
vec2 clippingPosition = v_clippingPosition;
|
|
424
|
+
int regionIndex = v_regionIndex;
|
|
425
|
+
clipPolygons(u_clippingDistance, CLIPPING_POLYGON_REGIONS_LENGTH, clippingPosition, regionIndex);
|
|
426
|
+
#endif
|
|
427
|
+
|
|
416
428
|
#ifdef HIGHLIGHT_FILL_TILE
|
|
417
429
|
finalColor = vec4(mix(finalColor.rgb, u_fillHighlightColor.rgb, u_fillHighlightColor.a), finalColor.a);
|
|
418
430
|
#endif
|
|
@@ -78,6 +78,12 @@ uniform mat4 u_clippingPlanesMatrix;\n\
|
|
|
78
78
|
uniform vec4 u_clippingPlanesEdgeStyle;\n\
|
|
79
79
|
#endif\n\
|
|
80
80
|
\n\
|
|
81
|
+
#ifdef ENABLE_CLIPPING_POLYGONS\n\
|
|
82
|
+
uniform highp sampler2D u_clippingDistance;\n\
|
|
83
|
+
in vec2 v_clippingPosition;\n\
|
|
84
|
+
flat in int v_regionIndex;\n\
|
|
85
|
+
#endif\n\
|
|
86
|
+
\n\
|
|
81
87
|
#if defined(GROUND_ATMOSPHERE) || defined(FOG) && defined(DYNAMIC_ATMOSPHERE_LIGHTING) && (defined(ENABLE_VERTEX_LIGHTING) || defined(ENABLE_DAYNIGHT_SHADING))\n\
|
|
82
88
|
uniform float u_minimumBrightness;\n\
|
|
83
89
|
#endif\n\
|
|
@@ -202,7 +208,7 @@ vec4 sampleAndBlend(\n\
|
|
|
202
208
|
\n\
|
|
203
209
|
#ifdef APPLY_COLOR_TO_ALPHA\n\
|
|
204
210
|
vec3 colorDiff = abs(color.rgb - colorToAlpha.rgb);\n\
|
|
205
|
-
colorDiff.r =
|
|
211
|
+
colorDiff.r = czm_maximumComponent(colorDiff);\n\
|
|
206
212
|
alpha = czm_branchFreeTernary(colorDiff.r < colorToAlpha.a, 0.0, alpha);\n\
|
|
207
213
|
#endif\n\
|
|
208
214
|
\n\
|
|
@@ -414,6 +420,12 @@ void main()\n\
|
|
|
414
420
|
}\n\
|
|
415
421
|
#endif\n\
|
|
416
422
|
\n\
|
|
423
|
+
#ifdef ENABLE_CLIPPING_POLYGONS\n\
|
|
424
|
+
vec2 clippingPosition = v_clippingPosition;\n\
|
|
425
|
+
int regionIndex = v_regionIndex;\n\
|
|
426
|
+
clipPolygons(u_clippingDistance, CLIPPING_POLYGON_REGIONS_LENGTH, clippingPosition, regionIndex); \n\
|
|
427
|
+
#endif\n\
|
|
428
|
+
\n\
|
|
417
429
|
#ifdef HIGHLIGHT_FILL_TILE\n\
|
|
418
430
|
finalColor = vec4(mix(finalColor.rgb, u_fillHighlightColor.rgb, u_fillHighlightColor.a), finalColor.a);\n\
|
|
419
431
|
#endif\n\
|
|
@@ -46,6 +46,12 @@ out vec3 v_atmosphereMieColor;
|
|
|
46
46
|
out float v_atmosphereOpacity;
|
|
47
47
|
#endif
|
|
48
48
|
|
|
49
|
+
#ifdef ENABLE_CLIPPING_POLYGONS
|
|
50
|
+
uniform highp sampler2D u_clippingExtents;
|
|
51
|
+
out vec2 v_clippingPosition;
|
|
52
|
+
flat out int v_regionIndex;
|
|
53
|
+
#endif
|
|
54
|
+
|
|
49
55
|
// These functions are generated at runtime.
|
|
50
56
|
vec4 getPosition(vec3 position, float height, vec2 textureCoordinates);
|
|
51
57
|
float get2DYPositionFraction(vec2 textureCoordinates);
|
|
@@ -207,6 +213,32 @@ void main()
|
|
|
207
213
|
v_normalEC = czm_normal3D * v_normalMC;
|
|
208
214
|
#endif
|
|
209
215
|
|
|
216
|
+
#ifdef ENABLE_CLIPPING_POLYGONS
|
|
217
|
+
vec2 sphericalLatLong = czm_approximateSphericalCoordinates(position3DWC);
|
|
218
|
+
sphericalLatLong.y = czm_branchFreeTernary(sphericalLatLong.y < czm_pi, sphericalLatLong.y, sphericalLatLong.y - czm_twoPi);
|
|
219
|
+
|
|
220
|
+
vec2 minDistance = vec2(czm_infinity);
|
|
221
|
+
v_clippingPosition = vec2(czm_infinity);
|
|
222
|
+
v_regionIndex = -1;
|
|
223
|
+
|
|
224
|
+
for (int regionIndex = 0; regionIndex < CLIPPING_POLYGON_REGIONS_LENGTH; regionIndex++) {
|
|
225
|
+
vec4 extents = unpackClippingExtents(u_clippingExtents, regionIndex);
|
|
226
|
+
vec2 rectUv = (sphericalLatLong.yx - extents.yx) * extents.wz;
|
|
227
|
+
|
|
228
|
+
vec2 clamped = clamp(rectUv, vec2(0.0), vec2(1.0));
|
|
229
|
+
vec2 distance = abs(rectUv - clamped) * extents.wz;
|
|
230
|
+
|
|
231
|
+
float threshold = 0.01;
|
|
232
|
+
if (minDistance.x > distance.x || minDistance.y > distance.y) {
|
|
233
|
+
minDistance = distance;
|
|
234
|
+
v_clippingPosition = rectUv;
|
|
235
|
+
if (rectUv.x > threshold && rectUv.y > threshold && rectUv.x < 1.0 - threshold && rectUv.y < 1.0 - threshold) {
|
|
236
|
+
v_regionIndex = regionIndex;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
#endif
|
|
241
|
+
|
|
210
242
|
#if defined(FOG) || (defined(GROUND_ATMOSPHERE) && !defined(PER_FRAGMENT_GROUND_ATMOSPHERE))
|
|
211
243
|
|
|
212
244
|
bool dynamicLighting = false;
|
|
@@ -47,6 +47,12 @@ out vec3 v_atmosphereMieColor;\n\
|
|
|
47
47
|
out float v_atmosphereOpacity;\n\
|
|
48
48
|
#endif\n\
|
|
49
49
|
\n\
|
|
50
|
+
#ifdef ENABLE_CLIPPING_POLYGONS\n\
|
|
51
|
+
uniform highp sampler2D u_clippingExtents;\n\
|
|
52
|
+
out vec2 v_clippingPosition;\n\
|
|
53
|
+
flat out int v_regionIndex;\n\
|
|
54
|
+
#endif\n\
|
|
55
|
+
\n\
|
|
50
56
|
// These functions are generated at runtime.\n\
|
|
51
57
|
vec4 getPosition(vec3 position, float height, vec2 textureCoordinates);\n\
|
|
52
58
|
float get2DYPositionFraction(vec2 textureCoordinates);\n\
|
|
@@ -208,6 +214,32 @@ void main()\n\
|
|
|
208
214
|
v_normalEC = czm_normal3D * v_normalMC;\n\
|
|
209
215
|
#endif\n\
|
|
210
216
|
\n\
|
|
217
|
+
#ifdef ENABLE_CLIPPING_POLYGONS\n\
|
|
218
|
+
vec2 sphericalLatLong = czm_approximateSphericalCoordinates(position3DWC);\n\
|
|
219
|
+
sphericalLatLong.y = czm_branchFreeTernary(sphericalLatLong.y < czm_pi, sphericalLatLong.y, sphericalLatLong.y - czm_twoPi);\n\
|
|
220
|
+
\n\
|
|
221
|
+
vec2 minDistance = vec2(czm_infinity);\n\
|
|
222
|
+
v_clippingPosition = vec2(czm_infinity);\n\
|
|
223
|
+
v_regionIndex = -1;\n\
|
|
224
|
+
\n\
|
|
225
|
+
for (int regionIndex = 0; regionIndex < CLIPPING_POLYGON_REGIONS_LENGTH; regionIndex++) {\n\
|
|
226
|
+
vec4 extents = unpackClippingExtents(u_clippingExtents, regionIndex);\n\
|
|
227
|
+
vec2 rectUv = (sphericalLatLong.yx - extents.yx) * extents.wz;\n\
|
|
228
|
+
\n\
|
|
229
|
+
vec2 clamped = clamp(rectUv, vec2(0.0), vec2(1.0));\n\
|
|
230
|
+
vec2 distance = abs(rectUv - clamped) * extents.wz;\n\
|
|
231
|
+
\n\
|
|
232
|
+
float threshold = 0.01;\n\
|
|
233
|
+
if (minDistance.x > distance.x || minDistance.y > distance.y) {\n\
|
|
234
|
+
minDistance = distance;\n\
|
|
235
|
+
v_clippingPosition = rectUv;\n\
|
|
236
|
+
if (rectUv.x > threshold && rectUv.y > threshold && rectUv.x < 1.0 - threshold && rectUv.y < 1.0 - threshold) {\n\
|
|
237
|
+
v_regionIndex = regionIndex;\n\
|
|
238
|
+
}\n\
|
|
239
|
+
}\n\
|
|
240
|
+
}\n\
|
|
241
|
+
#endif\n\
|
|
242
|
+
\n\
|
|
211
243
|
#if defined(FOG) || (defined(GROUND_ATMOSPHERE) && !defined(PER_FRAGMENT_GROUND_ATMOSPHERE))\n\
|
|
212
244
|
\n\
|
|
213
245
|
bool dynamicLighting = false;\n\
|
|
@@ -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) || defined(COMPUTE_POSITION_WC_ATMOSPHERE)
|
|
19
|
+
#if defined(COMPUTE_POSITION_WC_CUSTOM_SHADER) || defined(COMPUTE_POSITION_WC_STYLE) || defined(COMPUTE_POSITION_WC_ATMOSPHERE) || defined(ENABLE_CLIPPING_POLYGONS)
|
|
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;
|
|
@@ -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) || defined(COMPUTE_POSITION_WC_ATMOSPHERE)\n\
|
|
20
|
+
#if defined(COMPUTE_POSITION_WC_CUSTOM_SHADER) || defined(COMPUTE_POSITION_WC_STYLE) || defined(COMPUTE_POSITION_WC_ATMOSPHERE) || defined(ENABLE_CLIPPING_POLYGONS)\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\
|