@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.
Files changed (189) hide show
  1. package/Build/ThirdParty/Workers/pako_deflate.min.js +108 -210
  2. package/Build/ThirdParty/Workers/pako_inflate.min.js +466 -568
  3. package/Build/ThirdParty/Workers/z-worker-pako.js +56 -105
  4. package/Build/Workers/{chunk-VR5RBW52.js → chunk-26NE4LRW.js} +7 -7
  5. package/Build/Workers/{chunk-P2YAAMT2.js → chunk-26XJDV3D.js} +15 -15
  6. package/Build/Workers/{chunk-L4BW3RUA.js → chunk-2TRB253J.js} +7 -7
  7. package/Build/Workers/{chunk-NP2GYYE5.js → chunk-3PV5HQ2R.js} +6 -6
  8. package/Build/Workers/{chunk-BCU2LH5T.js → chunk-3VDHTBY5.js} +10 -10
  9. package/Build/Workers/{chunk-WHUSTDIB.js → chunk-4RG6WOXH.js} +10 -10
  10. package/Build/Workers/{chunk-P4XKB3QZ.js → chunk-5OK5JFDP.js} +5 -5
  11. package/Build/Workers/{chunk-2ZBL3MVO.js → chunk-7HLZRYGD.js} +10 -12
  12. package/Build/Workers/chunk-7PFZ4Z7C.js +961 -0
  13. package/Build/Workers/{chunk-24YTYWNB.js → chunk-A5CSB5ZE.js} +11 -13
  14. package/Build/Workers/{chunk-RMOEYCZW.js → chunk-AROLUUGS.js} +2 -2
  15. package/Build/Workers/{chunk-3NCVAGDA.js → chunk-BBBTT36L.js} +14 -14
  16. package/Build/Workers/{chunk-QKBGRKKG.js → chunk-BNT2SNWU.js} +4 -4
  17. package/Build/Workers/{chunk-LQJ5FFFR.js → chunk-CFBGPZU6.js} +11 -13
  18. package/Build/Workers/{chunk-C6OI26DR.js → chunk-CVCVMOQA.js} +1 -1
  19. package/Build/Workers/{chunk-SS4ESNE3.js → chunk-DIVFF6DK.js} +2 -2
  20. package/Build/Workers/{chunk-PXB7T27O.js → chunk-EJZVBTX4.js} +6 -6
  21. package/Build/Workers/{chunk-TZORKRNK.js → chunk-EODIOQ35.js} +1 -1
  22. package/Build/Workers/{chunk-QCQUZGXI.js → chunk-ETC45PHH.js} +5 -6
  23. package/Build/Workers/{chunk-E6WXPSJS.js → chunk-G7IAO7CW.js} +7 -7
  24. package/Build/Workers/{chunk-X2F6BEPY.js → chunk-GOQEANLM.js} +16 -16
  25. package/Build/Workers/{chunk-7COR472O.js → chunk-GUFV24F4.js} +7197 -5096
  26. package/Build/Workers/{chunk-5TIV3L26.js → chunk-GX2BWBN2.js} +13 -13
  27. package/Build/Workers/{chunk-ADOVHYWO.js → chunk-GX5LMUGZ.js} +469 -6
  28. package/Build/Workers/{chunk-2632RVPI.js → chunk-I6CW7ZE5.js} +7 -7
  29. package/Build/Workers/{chunk-YDVSBWEO.js → chunk-IF2OX6R4.js} +3 -5
  30. package/Build/Workers/{chunk-RSJXEO2A.js → chunk-IXYFH7DV.js} +95 -155
  31. package/Build/Workers/{chunk-ZNVSKMQ2.js → chunk-K5F23SZO.js} +6 -6
  32. package/Build/Workers/{chunk-MWV7IZK4.js → chunk-KTZK2UDR.js} +7 -7
  33. package/Build/Workers/{chunk-HBQPB6IH.js → chunk-LZFFO4KB.js} +12 -12
  34. package/Build/Workers/{chunk-GFA4SMXV.js → chunk-OYP23VAL.js} +11 -11
  35. package/Build/Workers/{chunk-ZYPTP7GS.js → chunk-PHT53MCH.js} +11 -11
  36. package/Build/Workers/{chunk-TJBU6GML.js → chunk-PUQR43HZ.js} +6 -6
  37. package/Build/Workers/{chunk-CO35JNNE.js → chunk-QZIWFSRM.js} +4 -4
  38. package/Build/Workers/{chunk-C3XBUYBO.js → chunk-RDR4KVPA.js} +17 -17
  39. package/Build/Workers/{chunk-YV4H2Y7M.js → chunk-RRUO4QEK.js} +4 -4
  40. package/Build/Workers/{chunk-LAQP3SCC.js → chunk-RTIT7UDN.js} +2 -2
  41. package/Build/Workers/{chunk-Z7FQLK6N.js → chunk-SC3TBKST.js} +4 -4
  42. package/Build/Workers/{chunk-GXUXEOE2.js → chunk-TDIGL45B.js} +1 -1
  43. package/Build/Workers/{chunk-EOXYZ34O.js → chunk-TP4FFUAH.js} +2 -2
  44. package/Build/Workers/{chunk-N4KXMWQU.js → chunk-U2LSTOMA.js} +2 -2
  45. package/Build/Workers/{chunk-6WF3KIF5.js → chunk-U6MTSO6A.js} +47 -84
  46. package/Build/Workers/{chunk-I37B3MZ2.js → chunk-UICVDDCQ.js} +1 -1
  47. package/Build/Workers/{chunk-DPUSFA7S.js → chunk-UKJCFXVV.js} +6 -6
  48. package/Build/Workers/{chunk-EPKE7GE3.js → chunk-UYKG3UFK.js} +5 -5
  49. package/Build/Workers/{chunk-RV7ZOSS6.js → chunk-W4OS542B.js} +13 -13
  50. package/Build/Workers/{chunk-DGDUKCJJ.js → chunk-WHDEZSAL.js} +6 -6
  51. package/Build/Workers/{chunk-NZWNZA6S.js → chunk-WOYQB5HM.js} +5 -5
  52. package/Build/Workers/{chunk-M2AYBTNH.js → chunk-WP3LCUOE.js} +13 -13
  53. package/Build/Workers/{chunk-73FKKY52.js → chunk-YGNQJ4YI.js} +5 -5
  54. package/Build/Workers/{chunk-SE4PXOEA.js → chunk-YGTWKLFY.js} +19 -19
  55. package/Build/Workers/{chunk-5R6VWLMH.js → chunk-ZHJDE6JN.js} +6 -6
  56. package/Build/Workers/combineGeometry.js +22 -24
  57. package/Build/Workers/createBoxGeometry.js +16 -18
  58. package/Build/Workers/createBoxOutlineGeometry.js +14 -16
  59. package/Build/Workers/createCircleGeometry.js +24 -26
  60. package/Build/Workers/createCircleOutlineGeometry.js +17 -19
  61. package/Build/Workers/createCoplanarPolygonGeometry.js +33 -34
  62. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +29 -31
  63. package/Build/Workers/createCorridorGeometry.js +27 -29
  64. package/Build/Workers/createCorridorOutlineGeometry.js +26 -28
  65. package/Build/Workers/createCylinderGeometry.js +18 -20
  66. package/Build/Workers/createCylinderOutlineGeometry.js +16 -18
  67. package/Build/Workers/createEllipseGeometry.js +24 -26
  68. package/Build/Workers/createEllipseOutlineGeometry.js +17 -19
  69. package/Build/Workers/createEllipsoidGeometry.js +17 -19
  70. package/Build/Workers/createEllipsoidOutlineGeometry.js +16 -18
  71. package/Build/Workers/createFrustumGeometry.js +16 -18
  72. package/Build/Workers/createFrustumOutlineGeometry.js +18 -19
  73. package/Build/Workers/createGeometry.js +22 -24
  74. package/Build/Workers/createGroundPolylineGeometry.js +23 -25
  75. package/Build/Workers/createPlaneGeometry.js +14 -16
  76. package/Build/Workers/createPlaneOutlineGeometry.js +13 -15
  77. package/Build/Workers/createPolygonGeometry.js +32 -34
  78. package/Build/Workers/createPolygonOutlineGeometry.js +28 -30
  79. package/Build/Workers/createPolylineGeometry.js +23 -25
  80. package/Build/Workers/createPolylineVolumeGeometry.js +29 -31
  81. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +25 -27
  82. package/Build/Workers/createRectangleGeometry.js +27 -29
  83. package/Build/Workers/createRectangleOutlineGeometry.js +18 -20
  84. package/Build/Workers/createSimplePolylineGeometry.js +21 -23
  85. package/Build/Workers/createSphereGeometry.js +17 -19
  86. package/Build/Workers/createSphereOutlineGeometry.js +16 -18
  87. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  88. package/Build/Workers/createVectorTileClampedPolylines.js +14 -16
  89. package/Build/Workers/createVectorTileGeometries.js +22 -24
  90. package/Build/Workers/createVectorTilePoints.js +12 -12
  91. package/Build/Workers/createVectorTilePolygons.js +20 -22
  92. package/Build/Workers/createVectorTilePolylines.js +14 -16
  93. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +23 -25
  94. package/Build/Workers/createVerticesFromHeightmap.js +23 -25
  95. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +19 -22
  96. package/Build/Workers/createWallGeometry.js +22 -24
  97. package/Build/Workers/createWallOutlineGeometry.js +21 -23
  98. package/Build/Workers/decodeDraco.js +11 -11
  99. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +12 -19
  100. package/Build/Workers/decodeI3S.js +10 -11
  101. package/Build/Workers/transcodeKTX2.js +44 -80
  102. package/Build/Workers/transferTypedArrayTest.js +1 -1
  103. package/Build/Workers/upsampleQuantizedTerrainMesh.js +20 -22
  104. package/Source/Core/Ion.js +1 -1
  105. package/Source/Core/Math.js +0 -5
  106. package/Source/Core/PixelFormat.js +1 -0
  107. package/Source/Core/Rectangle.js +89 -0
  108. package/Source/Core/TaskProcessor.js +19 -3
  109. package/Source/Core/sampleTerrain.js +3 -3
  110. package/Source/DataSources/DataSourceDisplay.js +5 -0
  111. package/Source/Renderer/ShaderBuilder.js +6 -3
  112. package/Source/Scene/ArcGisMapService.js +1 -1
  113. package/Source/Scene/Billboard.js +7 -5
  114. package/Source/Scene/Cesium3DTile.js +65 -0
  115. package/Source/Scene/Cesium3DTileset.js +48 -1
  116. package/Source/Scene/ClippingPolygon.js +212 -0
  117. package/Source/Scene/ClippingPolygonCollection.js +968 -0
  118. package/Source/Scene/Globe.js +14 -0
  119. package/Source/Scene/GlobeSurfaceShaderSet.js +81 -15
  120. package/Source/Scene/GlobeSurfaceTileProvider.js +81 -1
  121. package/Source/Scene/GltfLoader.js +458 -435
  122. package/Source/Scene/GltfLoaderUtil.js +3 -12
  123. package/Source/Scene/GltfPipeline/forEachTextureInMaterial.js +23 -7
  124. package/Source/Scene/GltfStructuralMetadataLoader.js +11 -9
  125. package/Source/Scene/Label.js +1 -1
  126. package/Source/Scene/Model/AlphaPipelineStage.js +1 -1
  127. package/Source/Scene/Model/GeometryPipelineStage.js +15 -43
  128. package/Source/Scene/Model/ImageBasedLightingPipelineStage.js +7 -0
  129. package/Source/Scene/Model/LightingPipelineStage.js +2 -4
  130. package/Source/Scene/Model/MaterialPipelineStage.js +346 -29
  131. package/Source/Scene/Model/Model.js +91 -3
  132. package/Source/Scene/Model/Model3DTileContent.js +21 -0
  133. package/Source/Scene/Model/ModelClippingPolygonsPipelineStage.js +92 -0
  134. package/Source/Scene/Model/ModelSceneGraph.js +5 -0
  135. package/Source/Scene/Model/ModelUtility.js +3 -0
  136. package/Source/Scene/Model/VerticalExaggerationPipelineStage.js +4 -6
  137. package/Source/Scene/ModelComponents.js +169 -1
  138. package/Source/Scene/PickDepth.js +23 -15
  139. package/Source/Scene/ResourceCache.js +41 -50
  140. package/Source/Scene/ResourceCacheKey.js +41 -53
  141. package/Source/Scene/Terrain.js +2 -2
  142. package/Source/Shaders/Builtin/CzmBuiltins.js +6 -8
  143. package/Source/Shaders/Builtin/Functions/clipPolygons.glsl +37 -0
  144. package/Source/Shaders/Builtin/Functions/clipPolygons.js +39 -0
  145. package/Source/Shaders/Builtin/Functions/maximumComponent.glsl +21 -0
  146. package/Source/Shaders/Builtin/Functions/maximumComponent.js +23 -0
  147. package/Source/Shaders/Builtin/Functions/pbrLighting.glsl +108 -44
  148. package/Source/Shaders/Builtin/Functions/pbrLighting.js +108 -44
  149. package/Source/Shaders/Builtin/Functions/unpackClippingExtents.glsl +14 -0
  150. package/Source/Shaders/Builtin/Functions/unpackClippingExtents.js +15 -0
  151. package/Source/Shaders/Builtin/Structs/modelMaterial.glsl +14 -0
  152. package/Source/Shaders/Builtin/Structs/modelMaterial.js +14 -0
  153. package/Source/Shaders/GlobeFS.glsl +13 -1
  154. package/Source/Shaders/GlobeFS.js +13 -1
  155. package/Source/Shaders/GlobeVS.glsl +32 -0
  156. package/Source/Shaders/GlobeVS.js +32 -0
  157. package/Source/Shaders/Model/GeometryStageVS.glsl +1 -1
  158. package/Source/Shaders/Model/GeometryStageVS.js +1 -1
  159. package/Source/Shaders/Model/ImageBasedLightingStageFS.glsl +211 -133
  160. package/Source/Shaders/Model/ImageBasedLightingStageFS.js +212 -133
  161. package/Source/Shaders/Model/LightingStageFS.glsl +113 -48
  162. package/Source/Shaders/Model/LightingStageFS.js +113 -48
  163. package/Source/Shaders/Model/MaterialStageFS.glsl +399 -137
  164. package/Source/Shaders/Model/MaterialStageFS.js +399 -137
  165. package/Source/Shaders/Model/ModelClippingPolygonsStageFS.glsl +6 -0
  166. package/Source/Shaders/Model/ModelClippingPolygonsStageFS.js +8 -0
  167. package/Source/Shaders/Model/ModelClippingPolygonsStageVS.glsl +27 -0
  168. package/Source/Shaders/Model/ModelClippingPolygonsStageVS.js +29 -0
  169. package/Source/Shaders/Model/ModelFS.glsl +6 -0
  170. package/Source/Shaders/Model/ModelFS.js +7 -1
  171. package/Source/Shaders/Model/ModelVS.glsl +4 -0
  172. package/Source/Shaders/Model/ModelVS.js +4 -0
  173. package/Source/Shaders/PolygonSignedDistanceFS.glsl +100 -0
  174. package/Source/Shaders/PolygonSignedDistanceFS.js +101 -0
  175. package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
  176. package/index.d.ts +230 -4
  177. package/index.js +234 -229
  178. package/package.json +1 -1
  179. package/Build/Workers/chunk-2KACWKS4.js +0 -501
  180. package/Build/Workers/chunk-2XPLH3JY.js +0 -2977
  181. package/Build/Workers/chunk-X6XOMPWL.js +0 -73
  182. package/Source/Shaders/Builtin/Functions/defaultPbrMaterial.glsl +0 -16
  183. package/Source/Shaders/Builtin/Functions/defaultPbrMaterial.js +0 -18
  184. package/Source/Shaders/Builtin/Functions/pbrMetallicRoughnessMaterial.glsl +0 -37
  185. package/Source/Shaders/Builtin/Functions/pbrMetallicRoughnessMaterial.js +0 -39
  186. package/Source/Shaders/Builtin/Functions/pbrSpecularGlossinessMaterial.glsl +0 -30
  187. package/Source/Shaders/Builtin/Functions/pbrSpecularGlossinessMaterial.js +0 -32
  188. package/Source/Shaders/Builtin/Structs/pbrParameters.glsl +0 -16
  189. package/Source/Shaders/Builtin/Structs/pbrParameters.js +0 -18
@@ -20,8 +20,7 @@ function getExternalResourceCacheKey(resource) {
20
20
  }
21
21
 
22
22
  function getBufferViewCacheKey(bufferView) {
23
- let byteOffset = bufferView.byteOffset;
24
- let byteLength = bufferView.byteLength;
23
+ let { byteOffset, byteLength } = bufferView;
25
24
 
26
25
  if (hasExtension(bufferView, "EXT_meshopt_compression")) {
27
26
  const meshopt = bufferView.extensions.EXT_meshopt_compression;
@@ -34,16 +33,10 @@ function getBufferViewCacheKey(bufferView) {
34
33
 
35
34
  function getAccessorCacheKey(accessor, bufferView) {
36
35
  const byteOffset = bufferView.byteOffset + accessor.byteOffset;
37
- const componentType = accessor.componentType;
38
- const type = accessor.type;
39
- const count = accessor.count;
36
+ const { componentType, type, count } = accessor;
40
37
  return `${byteOffset}-${componentType}-${type}-${count}`;
41
38
  }
42
39
 
43
- function getExternalBufferCacheKey(resource) {
44
- return getExternalResourceCacheKey(resource);
45
- }
46
-
47
40
  function getEmbeddedBufferCacheKey(parentResource, bufferId) {
48
41
  const parentCacheKey = getExternalResourceCacheKey(parentResource);
49
42
  return `${parentCacheKey}-buffer-id-${bufferId}`;
@@ -54,7 +47,7 @@ function getBufferCacheKey(buffer, bufferId, gltfResource, baseResource) {
54
47
  const resource = baseResource.getDerivedResource({
55
48
  url: buffer.uri,
56
49
  });
57
- return getExternalBufferCacheKey(resource);
50
+ return getExternalResourceCacheKey(resource);
58
51
  }
59
52
 
60
53
  return getEmbeddedBufferCacheKey(gltfResource, bufferId);
@@ -128,8 +121,7 @@ function getSamplerCacheKey(gltf, textureInfo) {
128
121
  * @private
129
122
  */
130
123
  ResourceCacheKey.getSchemaCacheKey = function (options) {
131
- const schema = options.schema;
132
- const resource = options.resource;
124
+ const { schema, resource } = options;
133
125
 
134
126
  //>>includeStart('debug', pragmas.debug);
135
127
  if (defined(schema) === defined(resource)) {
@@ -157,13 +149,13 @@ ResourceCacheKey.getSchemaCacheKey = function (options) {
157
149
  */
158
150
  ResourceCacheKey.getExternalBufferCacheKey = function (options) {
159
151
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
160
- const resource = options.resource;
152
+ const { resource } = options;
161
153
 
162
154
  //>>includeStart('debug', pragmas.debug);
163
155
  Check.typeOf.object("options.resource", resource);
164
156
  //>>includeEnd('debug');
165
157
 
166
- return `external-buffer:${getExternalBufferCacheKey(resource)}`;
158
+ return `external-buffer:${getExternalResourceCacheKey(resource)}`;
167
159
  };
168
160
 
169
161
  /**
@@ -178,8 +170,7 @@ ResourceCacheKey.getExternalBufferCacheKey = function (options) {
178
170
  */
179
171
  ResourceCacheKey.getEmbeddedBufferCacheKey = function (options) {
180
172
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
181
- const parentResource = options.parentResource;
182
- const bufferId = options.bufferId;
173
+ const { parentResource, bufferId } = options;
183
174
 
184
175
  //>>includeStart('debug', pragmas.debug);
185
176
  Check.typeOf.object("options.parentResource", parentResource);
@@ -203,7 +194,7 @@ ResourceCacheKey.getEmbeddedBufferCacheKey = function (options) {
203
194
  */
204
195
  ResourceCacheKey.getGltfCacheKey = function (options) {
205
196
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
206
- const gltfResource = options.gltfResource;
197
+ const { gltfResource } = options;
207
198
 
208
199
  //>>includeStart('debug', pragmas.debug);
209
200
  Check.typeOf.object("options.gltfResource", gltfResource);
@@ -226,10 +217,7 @@ ResourceCacheKey.getGltfCacheKey = function (options) {
226
217
  */
227
218
  ResourceCacheKey.getBufferViewCacheKey = function (options) {
228
219
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
229
- const gltf = options.gltf;
230
- const bufferViewId = options.bufferViewId;
231
- const gltfResource = options.gltfResource;
232
- const baseResource = options.baseResource;
220
+ const { gltf, bufferViewId, gltfResource, baseResource } = options;
233
221
 
234
222
  //>>includeStart('debug', pragmas.debug);
235
223
  Check.typeOf.object("options.gltf", gltf);
@@ -272,10 +260,7 @@ ResourceCacheKey.getBufferViewCacheKey = function (options) {
272
260
  */
273
261
  ResourceCacheKey.getDracoCacheKey = function (options) {
274
262
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
275
- const gltf = options.gltf;
276
- const draco = options.draco;
277
- const gltfResource = options.gltfResource;
278
- const baseResource = options.baseResource;
263
+ const { gltf, draco, gltfResource, baseResource } = options;
279
264
 
280
265
  //>>includeStart('debug', pragmas.debug);
281
266
  Check.typeOf.object("options.gltf", gltf);
@@ -309,16 +294,18 @@ ResourceCacheKey.getDracoCacheKey = function (options) {
309
294
  */
310
295
  ResourceCacheKey.getVertexBufferCacheKey = function (options) {
311
296
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
312
- const gltf = options.gltf;
313
- const gltfResource = options.gltfResource;
314
- const baseResource = options.baseResource;
315
- const frameState = options.frameState;
316
- const bufferViewId = options.bufferViewId;
317
- const draco = options.draco;
318
- const attributeSemantic = options.attributeSemantic;
319
- const dequantize = defaultValue(options.dequantize, false);
320
- const loadBuffer = defaultValue(options.loadBuffer, false);
321
- const loadTypedArray = defaultValue(options.loadTypedArray, false);
297
+ const {
298
+ gltf,
299
+ gltfResource,
300
+ baseResource,
301
+ frameState,
302
+ bufferViewId,
303
+ draco,
304
+ attributeSemantic,
305
+ dequantize = false,
306
+ loadBuffer = false,
307
+ loadTypedArray = false,
308
+ } = options;
322
309
 
323
310
  //>>includeStart('debug', pragmas.debug);
324
311
  Check.typeOf.object("options.gltf", gltf);
@@ -420,14 +407,16 @@ function hasDracoCompression(draco, semantic) {
420
407
  */
421
408
  ResourceCacheKey.getIndexBufferCacheKey = function (options) {
422
409
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
423
- const gltf = options.gltf;
424
- const accessorId = options.accessorId;
425
- const gltfResource = options.gltfResource;
426
- const baseResource = options.baseResource;
427
- const frameState = options.frameState;
428
- const draco = options.draco;
429
- const loadBuffer = defaultValue(options.loadBuffer, false);
430
- const loadTypedArray = defaultValue(options.loadTypedArray, false);
410
+ const {
411
+ gltf,
412
+ accessorId,
413
+ gltfResource,
414
+ baseResource,
415
+ frameState,
416
+ draco,
417
+ loadBuffer = false,
418
+ loadTypedArray = false,
419
+ } = options;
431
420
 
432
421
  //>>includeStart('debug', pragmas.debug);
433
422
  Check.typeOf.object("options.gltf", gltf);
@@ -495,10 +484,7 @@ ResourceCacheKey.getIndexBufferCacheKey = function (options) {
495
484
  */
496
485
  ResourceCacheKey.getImageCacheKey = function (options) {
497
486
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
498
- const gltf = options.gltf;
499
- const imageId = options.imageId;
500
- const gltfResource = options.gltfResource;
501
- const baseResource = options.baseResource;
487
+ const { gltf, imageId, gltfResource, baseResource } = options;
502
488
 
503
489
  //>>includeStart('debug', pragmas.debug);
504
490
  Check.typeOf.object("options.gltf", gltf);
@@ -533,12 +519,14 @@ ResourceCacheKey.getImageCacheKey = function (options) {
533
519
  */
534
520
  ResourceCacheKey.getTextureCacheKey = function (options) {
535
521
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
536
- const gltf = options.gltf;
537
- const textureInfo = options.textureInfo;
538
- const gltfResource = options.gltfResource;
539
- const baseResource = options.baseResource;
540
- const supportedImageFormats = options.supportedImageFormats;
541
- const frameState = options.frameState;
522
+ const {
523
+ gltf,
524
+ textureInfo,
525
+ gltfResource,
526
+ baseResource,
527
+ supportedImageFormats,
528
+ frameState,
529
+ } = options;
542
530
 
543
531
  //>>includeStart('debug', pragmas.debug);
544
532
  Check.typeOf.object("options.gltf", gltf);
@@ -83,7 +83,7 @@ Object.defineProperties(Terrain.prototype, {
83
83
 
84
84
  /**
85
85
  * Returns true when the terrain provider has been successfully created. Otherwise, returns false.
86
- * @memberof Viewer.prototype
86
+ * @memberof Terrain.prototype
87
87
  *
88
88
  * @type {boolean}
89
89
  * @readonly
@@ -96,7 +96,7 @@ Object.defineProperties(Terrain.prototype, {
96
96
 
97
97
  /**
98
98
  * The terrain provider providing surface geometry to a globe. Do not use until {@link Terrain.readyEvent} is raised.
99
- * @memberof Viewer.prototype
99
+ * @memberof Terrain.prototype
100
100
  *
101
101
  * @type {TerrainProvider}
102
102
  * @readonly
@@ -42,7 +42,6 @@ import czm_material from './Structs/material.js'
42
42
  import czm_materialInput from './Structs/materialInput.js'
43
43
  import czm_modelMaterial from './Structs/modelMaterial.js'
44
44
  import czm_modelVertexOutput from './Structs/modelVertexOutput.js'
45
- import czm_pbrParameters from './Structs/pbrParameters.js'
46
45
  import czm_ray from './Structs/ray.js'
47
46
  import czm_raySegment from './Structs/raySegment.js'
48
47
  import czm_shadowParameters from './Structs/shadowParameters.js'
@@ -64,6 +63,7 @@ import czm_cascadeColor from './Functions/cascadeColor.js'
64
63
  import czm_cascadeDistance from './Functions/cascadeDistance.js'
65
64
  import czm_cascadeMatrix from './Functions/cascadeMatrix.js'
66
65
  import czm_cascadeWeights from './Functions/cascadeWeights.js'
66
+ import czm_clipPolygons from './Functions/clipPolygons.js'
67
67
  import czm_columbusViewMorph from './Functions/columbusViewMorph.js'
68
68
  import czm_computeAtmosphereColor from './Functions/computeAtmosphereColor.js'
69
69
  import czm_computeGroundAtmosphereScattering from './Functions/computeGroundAtmosphereScattering.js'
@@ -71,7 +71,6 @@ import czm_computePosition from './Functions/computePosition.js'
71
71
  import czm_computeScattering from './Functions/computeScattering.js'
72
72
  import czm_cosineAndSine from './Functions/cosineAndSine.js'
73
73
  import czm_decompressTextureCoordinates from './Functions/decompressTextureCoordinates.js'
74
- import czm_defaultPbrMaterial from './Functions/defaultPbrMaterial.js'
75
74
  import czm_depthClamp from './Functions/depthClamp.js'
76
75
  import czm_eastNorthUpToEyeCoordinates from './Functions/eastNorthUpToEyeCoordinates.js'
77
76
  import czm_ellipsoidContainsPoint from './Functions/ellipsoidContainsPoint.js'
@@ -96,6 +95,7 @@ import czm_latitudeToWebMercatorFraction from './Functions/latitudeToWebMercator
96
95
  import czm_lineDistance from './Functions/lineDistance.js'
97
96
  import czm_linearToSrgb from './Functions/linearToSrgb.js'
98
97
  import czm_luminance from './Functions/luminance.js'
98
+ import czm_maximumComponent from './Functions/maximumComponent.js'
99
99
  import czm_metersPerPixel from './Functions/metersPerPixel.js'
100
100
  import czm_modelToWindowCoordinates from './Functions/modelToWindowCoordinates.js'
101
101
  import czm_multiplyWithColorBalance from './Functions/multiplyWithColorBalance.js'
@@ -103,8 +103,6 @@ import czm_nearFarScalar from './Functions/nearFarScalar.js'
103
103
  import czm_octDecode from './Functions/octDecode.js'
104
104
  import czm_packDepth from './Functions/packDepth.js'
105
105
  import czm_pbrLighting from './Functions/pbrLighting.js'
106
- import czm_pbrMetallicRoughnessMaterial from './Functions/pbrMetallicRoughnessMaterial.js'
107
- import czm_pbrSpecularGlossinessMaterial from './Functions/pbrSpecularGlossinessMaterial.js'
108
106
  import czm_phong from './Functions/phong.js'
109
107
  import czm_planeDistance from './Functions/planeDistance.js'
110
108
  import czm_pointAlongRay from './Functions/pointAlongRay.js'
@@ -127,6 +125,7 @@ import czm_transformPlane from './Functions/transformPlane.js'
127
125
  import czm_translateRelativeToEye from './Functions/translateRelativeToEye.js'
128
126
  import czm_translucentPhong from './Functions/translucentPhong.js'
129
127
  import czm_transpose from './Functions/transpose.js'
128
+ import czm_unpackClippingExtents from './Functions/unpackClippingExtents.js'
130
129
  import czm_unpackDepth from './Functions/unpackDepth.js'
131
130
  import czm_unpackFloat from './Functions/unpackFloat.js'
132
131
  import czm_unpackUint from './Functions/unpackUint.js'
@@ -181,7 +180,6 @@ export default {
181
180
  czm_materialInput : czm_materialInput,
182
181
  czm_modelMaterial : czm_modelMaterial,
183
182
  czm_modelVertexOutput : czm_modelVertexOutput,
184
- czm_pbrParameters : czm_pbrParameters,
185
183
  czm_ray : czm_ray,
186
184
  czm_raySegment : czm_raySegment,
187
185
  czm_shadowParameters : czm_shadowParameters,
@@ -203,6 +201,7 @@ export default {
203
201
  czm_cascadeDistance : czm_cascadeDistance,
204
202
  czm_cascadeMatrix : czm_cascadeMatrix,
205
203
  czm_cascadeWeights : czm_cascadeWeights,
204
+ czm_clipPolygons : czm_clipPolygons,
206
205
  czm_columbusViewMorph : czm_columbusViewMorph,
207
206
  czm_computeAtmosphereColor : czm_computeAtmosphereColor,
208
207
  czm_computeGroundAtmosphereScattering : czm_computeGroundAtmosphereScattering,
@@ -210,7 +209,6 @@ export default {
210
209
  czm_computeScattering : czm_computeScattering,
211
210
  czm_cosineAndSine : czm_cosineAndSine,
212
211
  czm_decompressTextureCoordinates : czm_decompressTextureCoordinates,
213
- czm_defaultPbrMaterial : czm_defaultPbrMaterial,
214
212
  czm_depthClamp : czm_depthClamp,
215
213
  czm_eastNorthUpToEyeCoordinates : czm_eastNorthUpToEyeCoordinates,
216
214
  czm_ellipsoidContainsPoint : czm_ellipsoidContainsPoint,
@@ -235,6 +233,7 @@ export default {
235
233
  czm_lineDistance : czm_lineDistance,
236
234
  czm_linearToSrgb : czm_linearToSrgb,
237
235
  czm_luminance : czm_luminance,
236
+ czm_maximumComponent : czm_maximumComponent,
238
237
  czm_metersPerPixel : czm_metersPerPixel,
239
238
  czm_modelToWindowCoordinates : czm_modelToWindowCoordinates,
240
239
  czm_multiplyWithColorBalance : czm_multiplyWithColorBalance,
@@ -242,8 +241,6 @@ export default {
242
241
  czm_octDecode : czm_octDecode,
243
242
  czm_packDepth : czm_packDepth,
244
243
  czm_pbrLighting : czm_pbrLighting,
245
- czm_pbrMetallicRoughnessMaterial : czm_pbrMetallicRoughnessMaterial,
246
- czm_pbrSpecularGlossinessMaterial : czm_pbrSpecularGlossinessMaterial,
247
244
  czm_phong : czm_phong,
248
245
  czm_planeDistance : czm_planeDistance,
249
246
  czm_pointAlongRay : czm_pointAlongRay,
@@ -266,6 +263,7 @@ export default {
266
263
  czm_translateRelativeToEye : czm_translateRelativeToEye,
267
264
  czm_translucentPhong : czm_translucentPhong,
268
265
  czm_transpose : czm_transpose,
266
+ czm_unpackClippingExtents : czm_unpackClippingExtents,
269
267
  czm_unpackDepth : czm_unpackDepth,
270
268
  czm_unpackFloat : czm_unpackFloat,
271
269
  czm_unpackUint : czm_unpackUint,
@@ -0,0 +1,37 @@
1
+ float getSignedDistance(vec2 uv, highp sampler2D clippingDistance) {
2
+ float signedDistance = texture(clippingDistance, uv).r;
3
+ return (signedDistance - 0.5) * 2.0;
4
+ }
5
+
6
+ void czm_clipPolygons(highp sampler2D clippingDistance, int extentsLength, vec2 clippingPosition, int regionIndex) {
7
+ // Position is completely outside of polygons bounds
8
+ vec2 rectUv = clippingPosition;
9
+ if (regionIndex < 0 || rectUv.x <= 0.0 || rectUv.y <= 0.0 || rectUv.x >= 1.0 || rectUv.y >= 1.0) {
10
+ #ifdef CLIPPING_INVERSE
11
+ discard;
12
+ #endif
13
+ return;
14
+ }
15
+
16
+ vec2 clippingDistanceTextureDimensions = vec2(textureSize(clippingDistance, 0));
17
+ vec2 sampleOffset = max(1.0 / clippingDistanceTextureDimensions, vec2(0.005));
18
+ float dimension = float(extentsLength);
19
+ if (extentsLength > 2) {
20
+ dimension = ceil(log2(float(extentsLength)));
21
+ }
22
+
23
+ vec2 textureOffset = vec2(mod(float(regionIndex), dimension), floor(float(regionIndex) / dimension)) / dimension;
24
+ vec2 uv = textureOffset + rectUv / dimension;
25
+
26
+ float signedDistance = getSignedDistance(uv, clippingDistance);
27
+
28
+ #ifdef CLIPPING_INVERSE
29
+ if (signedDistance > 0.0) {
30
+ discard;
31
+ }
32
+ #else
33
+ if (signedDistance < 0.0) {
34
+ discard;
35
+ }
36
+ #endif
37
+ }
@@ -0,0 +1,39 @@
1
+ //This file is automatically rebuilt by the Cesium build process.
2
+ export default "float getSignedDistance(vec2 uv, highp sampler2D clippingDistance) {\n\
3
+ float signedDistance = texture(clippingDistance, uv).r;\n\
4
+ return (signedDistance - 0.5) * 2.0;\n\
5
+ }\n\
6
+ \n\
7
+ void czm_clipPolygons(highp sampler2D clippingDistance, int extentsLength, vec2 clippingPosition, int regionIndex) {\n\
8
+ // Position is completely outside of polygons bounds\n\
9
+ vec2 rectUv = clippingPosition;\n\
10
+ if (regionIndex < 0 || rectUv.x <= 0.0 || rectUv.y <= 0.0 || rectUv.x >= 1.0 || rectUv.y >= 1.0) {\n\
11
+ #ifdef CLIPPING_INVERSE \n\
12
+ discard;\n\
13
+ #endif\n\
14
+ return;\n\
15
+ }\n\
16
+ \n\
17
+ vec2 clippingDistanceTextureDimensions = vec2(textureSize(clippingDistance, 0));\n\
18
+ vec2 sampleOffset = max(1.0 / clippingDistanceTextureDimensions, vec2(0.005));\n\
19
+ float dimension = float(extentsLength);\n\
20
+ if (extentsLength > 2) {\n\
21
+ dimension = ceil(log2(float(extentsLength)));\n\
22
+ }\n\
23
+ \n\
24
+ vec2 textureOffset = vec2(mod(float(regionIndex), dimension), floor(float(regionIndex) / dimension)) / dimension;\n\
25
+ vec2 uv = textureOffset + rectUv / dimension;\n\
26
+ \n\
27
+ float signedDistance = getSignedDistance(uv, clippingDistance);\n\
28
+ \n\
29
+ #ifdef CLIPPING_INVERSE\n\
30
+ if (signedDistance > 0.0) {\n\
31
+ discard;\n\
32
+ }\n\
33
+ #else\n\
34
+ if (signedDistance < 0.0) {\n\
35
+ discard;\n\
36
+ }\n\
37
+ #endif\n\
38
+ }\n\
39
+ ";
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Find the maximum component of a vector.
3
+ *
4
+ * @name czm_maximumComponent
5
+ * @glslFunction
6
+ *
7
+ * @param {vec2|vec3|vec4} v The input vector.
8
+ * @returns {float} The value of the largest component.
9
+ */
10
+ float czm_maximumComponent(vec2 v)
11
+ {
12
+ return max(v.x, v.y);
13
+ }
14
+ float czm_maximumComponent(vec3 v)
15
+ {
16
+ return max(max(v.x, v.y), v.z);
17
+ }
18
+ float czm_maximumComponent(vec4 v)
19
+ {
20
+ return max(max(max(v.x, v.y), v.z), v.w);
21
+ }
@@ -0,0 +1,23 @@
1
+ //This file is automatically rebuilt by the Cesium build process.
2
+ export default "/**\n\
3
+ * Find the maximum component of a vector.\n\
4
+ *\n\
5
+ * @name czm_maximumComponent\n\
6
+ * @glslFunction\n\
7
+ *\n\
8
+ * @param {vec2|vec3|vec4} v The input vector.\n\
9
+ * @returns {float} The value of the largest component.\n\
10
+ */\n\
11
+ float czm_maximumComponent(vec2 v)\n\
12
+ {\n\
13
+ return max(v.x, v.y);\n\
14
+ }\n\
15
+ float czm_maximumComponent(vec3 v)\n\
16
+ {\n\
17
+ return max(max(v.x, v.y), v.z);\n\
18
+ }\n\
19
+ float czm_maximumComponent(vec4 v)\n\
20
+ {\n\
21
+ return max(max(max(v.x, v.y), v.z), v.w);\n\
22
+ }\n\
23
+ ";
@@ -5,9 +5,42 @@ vec3 lambertianDiffuse(vec3 diffuseColor)
5
5
 
6
6
  vec3 fresnelSchlick2(vec3 f0, vec3 f90, float VdotH)
7
7
  {
8
- return f0 + (f90 - f0) * pow(clamp(1.0 - VdotH, 0.0, 1.0), 5.0);
8
+ float versine = 1.0 - VdotH;
9
+ // pow(versine, 5.0) is slow. See https://stackoverflow.com/a/68793086/10082269
10
+ float versineSquared = versine * versine;
11
+ return f0 + (f90 - f0) * versineSquared * versineSquared * versine;
9
12
  }
10
13
 
14
+ #ifdef USE_ANISOTROPY
15
+ /**
16
+ * @param {float} roughness Material roughness (along the anisotropy bitangent)
17
+ * @param {float} tangentialRoughness Anisotropic roughness (along the anisotropy tangent)
18
+ * @param {vec3} lightDirection The direction from the fragment to the light source, transformed to tangent-bitangent-normal coordinates
19
+ * @param {vec3} viewDirection The direction from the fragment to the camera, transformed to tangent-bitangent-normal coordinates
20
+ */
21
+ float smithVisibilityGGX_anisotropic(float roughness, float tangentialRoughness, vec3 lightDirection, vec3 viewDirection)
22
+ {
23
+ vec3 roughnessScale = vec3(tangentialRoughness, roughness, 1.0);
24
+ float GGXV = lightDirection.z * length(roughnessScale * viewDirection);
25
+ float GGXL = viewDirection.z * length(roughnessScale * lightDirection);
26
+ float v = 0.5 / (GGXV + GGXL);
27
+ return clamp(v, 0.0, 1.0);
28
+ }
29
+
30
+ /**
31
+ * @param {float} roughness Material roughness (along the anisotropy bitangent)
32
+ * @param {float} tangentialRoughness Anisotropic roughness (along the anisotropy tangent)
33
+ * @param {vec3} halfwayDirection The unit vector halfway between light and view directions, transformed to tangent-bitangent-normal coordinates
34
+ */
35
+ float GGX_anisotropic(float roughness, float tangentialRoughness, vec3 halfwayDirection)
36
+ {
37
+ float roughnessSquared = roughness * tangentialRoughness;
38
+ vec3 f = halfwayDirection * vec3(roughness, tangentialRoughness, roughnessSquared);
39
+ float w2 = roughnessSquared / dot(f, f);
40
+ return roughnessSquared * w2 * w2 / czm_pi;
41
+ }
42
+ #endif
43
+
11
44
  float smithVisibilityG1(float NdotV, float roughness)
12
45
  {
13
46
  // this is the k value for direct lighting.
@@ -16,14 +49,34 @@ float smithVisibilityG1(float NdotV, float roughness)
16
49
  return NdotV / (NdotV * (1.0 - k) + k);
17
50
  }
18
51
 
52
+ /**
53
+ * Estimate the geometric self-shadowing of the microfacets in a surface,
54
+ * using the Schlick GGX approximation of a Smith visibility function.
55
+ *
56
+ * @param {float} roughness The roughness of the material.
57
+ * @param {float} NdotL The cosine of the angle between the surface normal and the direction to the light source.
58
+ * @param {float} NdotV The cosine of the angle between the surface normal and the direction to the camera.
59
+ */
19
60
  float smithVisibilityGGX(float roughness, float NdotL, float NdotV)
20
61
  {
62
+ // Avoid divide-by-zero errors
63
+ NdotL = clamp(NdotL, 0.001, 1.0);
64
+ NdotV += 0.001;
21
65
  return (
22
66
  smithVisibilityG1(NdotL, roughness) *
23
67
  smithVisibilityG1(NdotV, roughness)
24
- );
68
+ ) / (4.0 * NdotL * NdotV);
25
69
  }
26
70
 
71
+ /**
72
+ * Estimate the fraction of the microfacets in a surface that are aligned with
73
+ * the halfway vector, which is aligned halfway between the directions from
74
+ * the fragment to the camera and from the fragment to the light source.
75
+ *
76
+ * @param {float} roughness The roughness of the material.
77
+ * @param {float} NdotH The cosine of the angle between the surface normal and the halfway vector.
78
+ * @return {float} The fraction of microfacets aligned to the halfway vector.
79
+ */
27
80
  float GGX(float roughness, float NdotH)
28
81
  {
29
82
  float roughnessSquared = roughness * roughness;
@@ -31,69 +84,80 @@ float GGX(float roughness, float NdotH)
31
84
  return roughnessSquared / (czm_pi * f * f);
32
85
  }
33
86
 
87
+ /**
88
+ * Compute the strength of the specular reflection due to direct lighting.
89
+ *
90
+ * @param {vec3} normal The surface normal.
91
+ * @param {vec3} lightDirection The unit vector pointing from the fragment to the light source.
92
+ * @param {vec3} viewDirection The unit vector pointing from the fragment to the camera.
93
+ * @param {vec3} halfwayDirection The unit vector pointing from the fragment to halfway between the light source and the camera.
94
+ * @param {float} roughness The roughness of the material.
95
+ * @return {float} The strength of the specular reflection.
96
+ */
97
+ float computeDirectSpecularStrength(vec3 normal, vec3 lightDirection, vec3 viewDirection, vec3 halfwayDirection, float roughness)
98
+ {
99
+ float NdotL = dot(normal, lightDirection);
100
+ float NdotV = abs(dot(normal, viewDirection));
101
+ float G = smithVisibilityGGX(roughness, NdotL, NdotV);
102
+ float NdotH = clamp(dot(normal, halfwayDirection), 0.0, 1.0);
103
+ float D = GGX(roughness, NdotH);
104
+ return G * D;
105
+ }
106
+
34
107
  /**
35
108
  * Compute the diffuse and specular contributions using physically based
36
109
  * rendering. This function only handles direct lighting.
37
110
  * <p>
38
111
  * This function only handles the lighting calculations. Metallic/roughness
39
- * and specular/glossy must be handled separately. See {@czm_pbrMetallicRoughnessMaterial}, {@czm_pbrSpecularGlossinessMaterial} and {@czm_defaultPbrMaterial}
112
+ * and specular/glossy must be handled separately. See {@MaterialStageFS}
40
113
  * </p>
41
114
  *
42
- * @name czm_pbrlighting
115
+ * @name czm_pbrLighting
43
116
  * @glslFunction
44
117
  *
45
- * @param {vec3} positionEC The position of the fragment in eye coordinates
118
+ * @param {vec3} viewDirectionEC Unit vector pointing from the fragment to the eye position
46
119
  * @param {vec3} normalEC The surface normal in eye coordinates
47
120
  * @param {vec3} lightDirectionEC Unit vector pointing to the light source in eye coordinates.
48
- * @param {vec3} lightColorHdr radiance of the light source. This is a HDR value.
49
- * @param {czm_pbrParameters} The computed PBR parameters.
121
+ * @param {czm_modelMaterial} The material properties.
50
122
  * @return {vec3} The computed HDR color
51
- *
52
- * @example
53
- * czm_pbrParameters pbrParameters = czm_pbrMetallicRoughnessMaterial(
54
- * baseColor,
55
- * metallic,
56
- * roughness
57
- * );
58
- * vec3 color = czm_pbrlighting(
59
- * positionEC,
60
- * normalEC,
61
- * lightDirectionEC,
62
- * lightColorHdr,
63
- * pbrParameters);
64
123
  */
65
- vec3 czm_pbrLighting(
66
- vec3 positionEC,
67
- vec3 normalEC,
68
- vec3 lightDirectionEC,
69
- vec3 lightColorHdr,
70
- czm_pbrParameters pbrParameters
71
- )
124
+ vec3 czm_pbrLighting(vec3 viewDirectionEC, vec3 normalEC, vec3 lightDirectionEC, czm_modelMaterial material)
72
125
  {
73
- vec3 v = -normalize(positionEC);
74
- vec3 l = normalize(lightDirectionEC);
75
- vec3 h = normalize(v + l);
76
- vec3 n = normalEC;
77
- float NdotL = clamp(dot(n, l), 0.001, 1.0);
78
- float NdotV = abs(dot(n, v)) + 0.001;
79
- float NdotH = clamp(dot(n, h), 0.0, 1.0);
80
- float LdotH = clamp(dot(l, h), 0.0, 1.0);
81
- float VdotH = clamp(dot(v, h), 0.0, 1.0);
126
+ vec3 halfwayDirectionEC = normalize(viewDirectionEC + lightDirectionEC);
127
+ float VdotH = clamp(dot(viewDirectionEC, halfwayDirectionEC), 0.0, 1.0);
128
+ float NdotL = clamp(dot(normalEC, lightDirectionEC), 0.001, 1.0);
82
129
 
83
- vec3 f0 = pbrParameters.f0;
84
- float reflectance = max(max(f0.r, f0.g), f0.b);
130
+ vec3 f0 = material.specular;
131
+ float reflectance = czm_maximumComponent(f0);
132
+ // Typical dielectrics will have reflectance 0.04, so f90 will be 1.0.
133
+ // In this case, at grazing angle, all incident energy is reflected.
85
134
  vec3 f90 = vec3(clamp(reflectance * 25.0, 0.0, 1.0));
86
135
  vec3 F = fresnelSchlick2(f0, f90, VdotH);
87
136
 
88
- float alpha = pbrParameters.roughness;
89
- float G = smithVisibilityGGX(alpha, NdotL, NdotV);
90
- float D = GGX(alpha, NdotH);
91
- vec3 specularContribution = F * G * D / (4.0 * NdotL * NdotV);
137
+ #if defined(USE_SPECULAR)
138
+ F *= material.specularWeight;
139
+ #endif
140
+
141
+ float alpha = material.roughness;
142
+ #ifdef USE_ANISOTROPY
143
+ mat3 tbn = mat3(material.anisotropicT, material.anisotropicB, normalEC);
144
+ vec3 lightDirection = lightDirectionEC * tbn;
145
+ vec3 viewDirection = viewDirectionEC * tbn;
146
+ vec3 halfwayDirection = halfwayDirectionEC * tbn;
147
+ float anisotropyStrength = material.anisotropyStrength;
148
+ float tangentialRoughness = mix(alpha, 1.0, anisotropyStrength * anisotropyStrength);
149
+ float G = smithVisibilityGGX_anisotropic(alpha, tangentialRoughness, lightDirection, viewDirection);
150
+ float D = GGX_anisotropic(alpha, tangentialRoughness, halfwayDirection);
151
+ vec3 specularContribution = F * G * D;
152
+ #else
153
+ float specularStrength = computeDirectSpecularStrength(normalEC, lightDirectionEC, viewDirectionEC, halfwayDirectionEC, alpha);
154
+ vec3 specularContribution = F * specularStrength;
155
+ #endif
92
156
 
93
- vec3 diffuseColor = pbrParameters.diffuseColor;
157
+ vec3 diffuseColor = material.diffuse;
94
158
  // F here represents the specular contribution
95
159
  vec3 diffuseContribution = (1.0 - F) * lambertianDiffuse(diffuseColor);
96
160
 
97
161
  // Lo = (diffuse + specular) * Li * NdotL
98
- return (diffuseContribution + specularContribution) * NdotL * lightColorHdr;
162
+ return (diffuseContribution + specularContribution) * NdotL;
99
163
  }