@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.
Files changed (255) 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 +54 -104
  4. package/Build/Workers/{chunk-TMMOULW3.js → chunk-2J3JKXCP.js} +5 -5
  5. package/Build/Workers/{chunk-ZDP32RQI.js → chunk-3WUV74WM.js} +95 -155
  6. package/Build/Workers/{chunk-FOZQIHZK.js → chunk-4BAE4PWO.js} +6 -6
  7. package/Build/Workers/{chunk-CYAJYEKW.js → chunk-4MSUJ4I7.js} +8 -8
  8. package/Build/Workers/{chunk-KPY4F4BW.js → chunk-4YSNMHZ4.js} +6 -6
  9. package/Build/Workers/{chunk-66E3H2KU.js → chunk-5S7OLEPK.js} +12 -12
  10. package/Build/Workers/{chunk-4AJGCQFX.js → chunk-7XGC6YB2.js} +14 -14
  11. package/Build/Workers/{chunk-BDUJXBVF.js → chunk-AA4GZKOT.js} +3 -5
  12. package/Build/Workers/{chunk-7LPEGKOF.js → chunk-AD5HBJ2F.js} +11 -8
  13. package/Build/Workers/{chunk-XHLDDE65.js → chunk-AVI4IUWC.js} +11 -11
  14. package/Build/Workers/{chunk-MWYZ64MH.js → chunk-BCL4PHHT.js} +10 -10
  15. package/Build/Workers/{chunk-PWF3YJJ5.js → chunk-BDFNKFOE.js} +13 -13
  16. package/Build/Workers/{chunk-7VZNXIKG.js → chunk-BJF5LOWE.js} +7 -7
  17. package/Build/Workers/{chunk-3S2MFY4B.js → chunk-C2CGMAIU.js} +13 -13
  18. package/Build/Workers/{chunk-UAJEGIWA.js → chunk-COYFZ5VA.js} +6 -6
  19. package/Build/Workers/{chunk-ZWPIM77Q.js → chunk-DGS5QNIO.js} +13 -13
  20. package/Build/Workers/{chunk-V7JB576Q.js → chunk-DKVHRNFY.js} +5 -5
  21. package/Build/Workers/{chunk-NI2R52QD.js → chunk-DOXCPOG4.js} +11 -9
  22. package/Build/Workers/{chunk-XWML5Y7N.js → chunk-FXIHSF7O.js} +9 -9
  23. package/Build/Workers/{chunk-LW7WGHEU.js → chunk-G3YR53LY.js} +13 -13
  24. package/Build/Workers/{chunk-34DGOKCO.js → chunk-GR3CDLCP.js} +7 -7
  25. package/Build/Workers/{chunk-AOIKO5Y7.js → chunk-GRAT5GE7.js} +5 -5
  26. package/Build/Workers/{chunk-AOFMPKUB.js → chunk-I2RC4XVN.js} +4 -4
  27. package/Build/Workers/{chunk-PK7TEP3J.js → chunk-JYAHOGGL.js} +15 -15
  28. package/Build/Workers/{chunk-4KIUON73.js → chunk-KUN2ZA5X.js} +4 -4
  29. package/Build/Workers/{chunk-POLFRINT.js → chunk-L6RTJ3RE.js} +14 -14
  30. package/Build/Workers/{chunk-LVJCR7DH.js → chunk-LCLJJ2MZ.js} +18 -18
  31. package/Build/Workers/{chunk-3RZK5NNV.js → chunk-LEABCTLP.js} +4 -4
  32. package/Build/Workers/{chunk-QKF7XXEQ.js → chunk-MDHQR3ZS.js} +10 -8
  33. package/Build/Workers/{chunk-4PHPQRSH.js → chunk-MSKXMXJI.js} +5 -6
  34. package/Build/Workers/{chunk-GIFJ77E4.js → chunk-NTXTUNEF.js} +4 -4
  35. package/Build/Workers/{chunk-I5TDPPC4.js → chunk-O3JCMSS3.js} +17 -17
  36. package/Build/Workers/{chunk-PEABJLCK.js → chunk-OOK53QUQ.js} +1 -1
  37. package/Build/Workers/{chunk-PS6AEMBR.js → chunk-OORVMGDU.js} +7 -7
  38. package/Build/Workers/{chunk-JI2445T5.js → chunk-PCP4YQST.js} +11 -11
  39. package/Build/Workers/{chunk-C5CE4OG6.js → chunk-PYHLO636.js} +42 -13
  40. package/Build/Workers/{chunk-S4XDCPKD.js → chunk-Q55ECN3Y.js} +1 -1
  41. package/Build/Workers/{chunk-WWP3I7R5.js → chunk-QD4KM3GO.js} +5 -5
  42. package/Build/Workers/{chunk-YLZTCEBJ.js → chunk-QMLTCCYG.js} +1 -1
  43. package/Build/Workers/{chunk-IBXGK4WV.js → chunk-QX5XS4LC.js} +2 -2
  44. package/Build/Workers/{chunk-RL73GOEF.js → chunk-R6B7UCQB.js} +2 -2
  45. package/Build/Workers/{chunk-RR7EOKGZ.js → chunk-RJYML24O.js} +48 -85
  46. package/Build/Workers/{chunk-U4IMCOF5.js → chunk-S3PI2KFM.js} +2 -2
  47. package/Build/Workers/{chunk-6HCAQOVK.js → chunk-STBBMQGG.js} +6 -6
  48. package/Build/Workers/{chunk-CE6GTZ4I.js → chunk-SYCPRK3D.js} +10 -10
  49. package/Build/Workers/{chunk-WFICTTOE.js → chunk-T77JILCU.js} +2 -2
  50. package/Build/Workers/{chunk-ZC4AGBZK.js → chunk-TO2PVHKI.js} +2 -2
  51. package/Build/Workers/{chunk-UCPPWV64.js → chunk-VE7BFUIX.js} +1 -1
  52. package/Build/Workers/{chunk-2CSEEWHN.js → chunk-VFBNELXB.js} +7 -7
  53. package/Build/Workers/{chunk-A6NCZSL3.js → chunk-VO3ACQB2.js} +19 -19
  54. package/Build/Workers/{chunk-WEGCQ5DY.js → chunk-X23FRWHJ.js} +6 -6
  55. package/Build/Workers/{chunk-G7CJQKKD.js → chunk-XD445VDH.js} +7 -7
  56. package/Build/Workers/combineGeometry.js +22 -22
  57. package/Build/Workers/createBoxGeometry.js +16 -16
  58. package/Build/Workers/createBoxOutlineGeometry.js +14 -14
  59. package/Build/Workers/createCircleGeometry.js +29 -25
  60. package/Build/Workers/createCircleOutlineGeometry.js +17 -17
  61. package/Build/Workers/createCoplanarPolygonGeometry.js +32 -32
  62. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +29 -29
  63. package/Build/Workers/createCorridorGeometry.js +29 -29
  64. package/Build/Workers/createCorridorOutlineGeometry.js +27 -27
  65. package/Build/Workers/createCylinderGeometry.js +18 -18
  66. package/Build/Workers/createCylinderOutlineGeometry.js +16 -16
  67. package/Build/Workers/createEllipseGeometry.js +24 -24
  68. package/Build/Workers/createEllipseOutlineGeometry.js +17 -17
  69. package/Build/Workers/createEllipsoidGeometry.js +17 -17
  70. package/Build/Workers/createEllipsoidOutlineGeometry.js +16 -16
  71. package/Build/Workers/createFrustumGeometry.js +16 -16
  72. package/Build/Workers/createFrustumOutlineGeometry.js +16 -16
  73. package/Build/Workers/createGeometry.js +22 -22
  74. package/Build/Workers/createGroundPolylineGeometry.js +24 -24
  75. package/Build/Workers/createPlaneGeometry.js +14 -14
  76. package/Build/Workers/createPlaneOutlineGeometry.js +13 -13
  77. package/Build/Workers/createPolygonGeometry.js +32 -32
  78. package/Build/Workers/createPolygonOutlineGeometry.js +29 -29
  79. package/Build/Workers/createPolylineGeometry.js +24 -24
  80. package/Build/Workers/createPolylineVolumeGeometry.js +30 -30
  81. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +26 -26
  82. package/Build/Workers/createRectangleGeometry.js +27 -27
  83. package/Build/Workers/createRectangleOutlineGeometry.js +19 -19
  84. package/Build/Workers/createSimplePolylineGeometry.js +22 -22
  85. package/Build/Workers/createSphereGeometry.js +17 -17
  86. package/Build/Workers/createSphereOutlineGeometry.js +16 -16
  87. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  88. package/Build/Workers/createVectorTileClampedPolylines.js +13 -13
  89. package/Build/Workers/createVectorTileGeometries.js +22 -22
  90. package/Build/Workers/createVectorTilePoints.js +12 -12
  91. package/Build/Workers/createVectorTilePolygons.js +20 -20
  92. package/Build/Workers/createVectorTilePolylines.js +13 -13
  93. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +20 -20
  94. package/Build/Workers/createVerticesFromHeightmap.js +21 -21
  95. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +17 -17
  96. package/Build/Workers/createWallGeometry.js +23 -23
  97. package/Build/Workers/createWallOutlineGeometry.js +22 -22
  98. package/Build/Workers/decodeDraco.js +11 -11
  99. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +12 -19
  100. package/Build/Workers/decodeI3S.js +10 -10
  101. package/Build/Workers/transcodeKTX2.js +43 -79
  102. package/Build/Workers/transferTypedArrayTest.js +1 -1
  103. package/Build/Workers/upsampleQuantizedTerrainMesh.js +20 -20
  104. package/Source/Core/ApproximateTerrainHeights.js +4 -4
  105. package/Source/Core/ArcGISTiledElevationTerrainProvider.js +12 -8
  106. package/Source/Core/BoundingRectangle.js +2 -0
  107. package/Source/Core/BoundingSphere.js +4 -2
  108. package/Source/Core/Cartesian3.js +13 -10
  109. package/Source/Core/Cartographic.js +11 -8
  110. package/Source/Core/CesiumTerrainProvider.js +3 -2
  111. package/Source/Core/CircleGeometry.js +6 -2
  112. package/Source/Core/CircleOutlineGeometry.js +1 -1
  113. package/Source/Core/CoplanarPolygonGeometry.js +3 -3
  114. package/Source/Core/CorridorGeometry.js +4 -4
  115. package/Source/Core/CorridorOutlineGeometry.js +2 -2
  116. package/Source/Core/Credit.js +3 -2
  117. package/Source/Core/CustomHeightmapTerrainProvider.js +17 -3
  118. package/Source/Core/EllipseGeometry.js +4 -4
  119. package/Source/Core/EllipseOutlineGeometry.js +2 -2
  120. package/Source/Core/Ellipsoid.js +34 -0
  121. package/Source/Core/EllipsoidGeodesic.js +2 -2
  122. package/Source/Core/EllipsoidRhumbLine.js +4 -4
  123. package/Source/Core/EllipsoidTangentPlane.js +3 -3
  124. package/Source/Core/EllipsoidTerrainProvider.js +3 -3
  125. package/Source/Core/GeographicProjection.js +4 -3
  126. package/Source/Core/GeographicTilingScheme.js +3 -3
  127. package/Source/Core/GeometryPipeline.js +2 -2
  128. package/Source/Core/GoogleEarthEnterpriseTerrainProvider.js +1 -1
  129. package/Source/Core/GoogleMaps.js +1 -1
  130. package/Source/Core/GroundPolylineGeometry.js +1 -1
  131. package/Source/Core/HeightmapTessellator.js +2 -2
  132. package/Source/Core/Ion.js +1 -1
  133. package/Source/Core/Math.js +0 -5
  134. package/Source/Core/Occluder.js +3 -3
  135. package/Source/Core/OrientedBoundingBox.js +2 -2
  136. package/Source/Core/PolygonGeometry.js +4 -4
  137. package/Source/Core/PolygonGeometryLibrary.js +1 -1
  138. package/Source/Core/PolygonOutlineGeometry.js +3 -3
  139. package/Source/Core/PolygonPipeline.js +2 -2
  140. package/Source/Core/PolylineGeometry.js +2 -2
  141. package/Source/Core/PolylinePipeline.js +6 -6
  142. package/Source/Core/PolylineVolumeGeometry.js +2 -2
  143. package/Source/Core/PolylineVolumeOutlineGeometry.js +2 -2
  144. package/Source/Core/Rectangle.js +6 -6
  145. package/Source/Core/RectangleGeometry.js +6 -6
  146. package/Source/Core/RectangleGeometryLibrary.js +3 -0
  147. package/Source/Core/RectangleOutlineGeometry.js +2 -2
  148. package/Source/Core/Simon1994PlanetaryPositions.js +3 -2
  149. package/Source/Core/SimplePolylineGeometry.js +2 -2
  150. package/Source/Core/Stereographic.js +2 -2
  151. package/Source/Core/TaskProcessor.js +19 -3
  152. package/Source/Core/Transforms.js +17 -17
  153. package/Source/Core/VRTheWorldTerrainProvider.js +2 -2
  154. package/Source/Core/WallGeometry.js +3 -3
  155. package/Source/Core/WallOutlineGeometry.js +3 -3
  156. package/Source/Core/WebMercatorTilingScheme.js +3 -3
  157. package/Source/Core/createWorldTerrainAsync.js +2 -0
  158. package/Source/Core/sampleTerrain.js +3 -3
  159. package/Source/DataSources/BoxGeometryUpdater.js +2 -2
  160. package/Source/DataSources/CylinderGeometryUpdater.js +2 -2
  161. package/Source/DataSources/CzmlDataSource.js +8 -8
  162. package/Source/DataSources/EllipsoidGeometryUpdater.js +3 -3
  163. package/Source/DataSources/EntityCluster.js +1 -1
  164. package/Source/DataSources/EntityView.js +2 -2
  165. package/Source/DataSources/KmlDataSource.js +4 -4
  166. package/Source/DataSources/ModelVisualizer.js +1 -2
  167. package/Source/DataSources/PolygonGeometryUpdater.js +1 -1
  168. package/Source/DataSources/PolylineGeometryUpdater.js +3 -2
  169. package/Source/DataSources/RectangleGeometryUpdater.js +1 -1
  170. package/Source/DataSources/ScaledPositionProperty.js +2 -2
  171. package/Source/DataSources/TerrainOffsetProperty.js +3 -7
  172. package/Source/DataSources/VelocityOrientationProperty.js +2 -2
  173. package/Source/DataSources/exportKml.js +2 -2
  174. package/Source/Renderer/UniformState.js +1 -1
  175. package/Source/Scene/ArcGisMapServerImageryProvider.js +2 -2
  176. package/Source/Scene/ArcGisMapService.js +1 -1
  177. package/Source/Scene/Billboard.js +8 -6
  178. package/Source/Scene/BingMapsImageryProvider.js +1 -1
  179. package/Source/Scene/Camera.js +16 -10
  180. package/Source/Scene/Cesium3DTileset.js +1 -1
  181. package/Source/Scene/ClippingPolygon.js +2 -2
  182. package/Source/Scene/ClippingPolygonCollection.js +1 -1
  183. package/Source/Scene/CreditDisplay.js +94 -104
  184. package/Source/Scene/Globe.js +16 -13
  185. package/Source/Scene/GltfLoader.js +458 -435
  186. package/Source/Scene/GltfLoaderUtil.js +5 -16
  187. package/Source/Scene/GltfPipeline/forEachTextureInMaterial.js +23 -7
  188. package/Source/Scene/GltfStructuralMetadataLoader.js +11 -9
  189. package/Source/Scene/GoogleEarthEnterpriseImageryProvider.js +1 -1
  190. package/Source/Scene/GoogleEarthEnterpriseMapsProvider.js +1 -1
  191. package/Source/Scene/GridImageryProvider.js +2 -2
  192. package/Source/Scene/ImageryLayerCollection.js +2 -2
  193. package/Source/Scene/Label.js +1 -1
  194. package/Source/Scene/MapboxImageryProvider.js +1 -1
  195. package/Source/Scene/MapboxStyleImageryProvider.js +1 -1
  196. package/Source/Scene/MetadataSemantic.js +4 -4
  197. package/Source/Scene/Model/AlphaPipelineStage.js +1 -1
  198. package/Source/Scene/Model/GeometryPipelineStage.js +15 -43
  199. package/Source/Scene/Model/ImageBasedLightingPipelineStage.js +7 -0
  200. package/Source/Scene/Model/InstancingPipelineStage.js +3 -3
  201. package/Source/Scene/Model/LightingPipelineStage.js +2 -4
  202. package/Source/Scene/Model/MaterialPipelineStage.js +395 -29
  203. package/Source/Scene/Model/Model.js +15 -7
  204. package/Source/Scene/Model/ModelSceneGraph.js +1 -1
  205. package/Source/Scene/Model/ModelUtility.js +3 -0
  206. package/Source/Scene/Model/SceneMode2DPipelineStage.js +3 -3
  207. package/Source/Scene/Model/VerticalExaggerationPipelineStage.js +4 -6
  208. package/Source/Scene/Model/pickModel.js +2 -2
  209. package/Source/Scene/ModelComponents.js +178 -1
  210. package/Source/Scene/PickDepth.js +23 -15
  211. package/Source/Scene/Picking.js +4 -13
  212. package/Source/Scene/PointPrimitive.js +5 -2
  213. package/Source/Scene/ResourceCache.js +41 -50
  214. package/Source/Scene/ResourceCacheKey.js +41 -53
  215. package/Source/Scene/Scene.js +39 -31
  216. package/Source/Scene/SceneTransforms.js +78 -20
  217. package/Source/Scene/SceneTransitioner.js +2 -2
  218. package/Source/Scene/ScreenSpaceCameraController.js +29 -19
  219. package/Source/Scene/SkyBox.js +26 -0
  220. package/Source/Scene/Sun.js +1 -1
  221. package/Source/Shaders/Builtin/CzmBuiltins.js +4 -10
  222. package/Source/Shaders/Builtin/Functions/ellipsoidTextureCoordinates.glsl +10 -0
  223. package/Source/Shaders/Builtin/Functions/{ellipsoidWgs84TextureCoordinates.js → ellipsoidTextureCoordinates.js} +3 -3
  224. package/Source/Shaders/Builtin/Functions/maximumComponent.glsl +21 -0
  225. package/Source/Shaders/Builtin/Functions/maximumComponent.js +23 -0
  226. package/Source/Shaders/Builtin/Functions/pbrLighting.glsl +108 -44
  227. package/Source/Shaders/Builtin/Functions/pbrLighting.js +108 -44
  228. package/Source/Shaders/Builtin/Structs/materialInput.glsl +1 -1
  229. package/Source/Shaders/Builtin/Structs/materialInput.js +1 -1
  230. package/Source/Shaders/Builtin/Structs/modelMaterial.glsl +16 -0
  231. package/Source/Shaders/Builtin/Structs/modelMaterial.js +16 -0
  232. package/Source/Shaders/EllipsoidFS.glsl +1 -1
  233. package/Source/Shaders/EllipsoidFS.js +1 -1
  234. package/Source/Shaders/GlobeFS.glsl +3 -3
  235. package/Source/Shaders/GlobeFS.js +3 -3
  236. package/Source/Shaders/Model/ImageBasedLightingStageFS.glsl +211 -133
  237. package/Source/Shaders/Model/ImageBasedLightingStageFS.js +212 -133
  238. package/Source/Shaders/Model/LightingStageFS.glsl +113 -48
  239. package/Source/Shaders/Model/LightingStageFS.js +113 -48
  240. package/Source/Shaders/Model/MaterialStageFS.glsl +407 -136
  241. package/Source/Shaders/Model/MaterialStageFS.js +407 -136
  242. package/Source/Widget/CesiumWidget.css +0 -5
  243. package/Source/Widget/CesiumWidget.js +29 -28
  244. package/index.d.ts +184 -116
  245. package/index.js +92 -95
  246. package/package.json +2 -2
  247. package/Source/Shaders/Builtin/Functions/defaultPbrMaterial.glsl +0 -16
  248. package/Source/Shaders/Builtin/Functions/defaultPbrMaterial.js +0 -18
  249. package/Source/Shaders/Builtin/Functions/ellipsoidWgs84TextureCoordinates.glsl +0 -10
  250. package/Source/Shaders/Builtin/Functions/pbrMetallicRoughnessMaterial.glsl +0 -37
  251. package/Source/Shaders/Builtin/Functions/pbrMetallicRoughnessMaterial.js +0 -39
  252. package/Source/Shaders/Builtin/Functions/pbrSpecularGlossinessMaterial.glsl +0 -30
  253. package/Source/Shaders/Builtin/Functions/pbrSpecularGlossinessMaterial.js +0 -32
  254. package/Source/Shaders/Builtin/Structs/pbrParameters.glsl +0 -16
  255. package/Source/Shaders/Builtin/Structs/pbrParameters.js +0 -18
@@ -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
  }
@@ -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
- return f0 + (f90 - f0) * pow(clamp(1.0 - VdotH, 0.0, 1.0), 5.0);\n\
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 {@czm_pbrMetallicRoughnessMaterial}, {@czm_pbrSpecularGlossinessMaterial} and {@czm_defaultPbrMaterial}\n\
113
+ * and specular/glossy must be handled separately. See {@MaterialStageFS}\n\
41
114
  * </p>\n\
42
115
  *\n\
43
- * @name czm_pbrlighting\n\
116
+ * @name czm_pbrLighting\n\
44
117
  * @glslFunction\n\
45
118
  *\n\
46
- * @param {vec3} positionEC The position of the fragment in eye coordinates\n\
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 {vec3} lightColorHdr radiance of the light source. This is a HDR value.\n\
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 v = -normalize(positionEC);\n\
75
- vec3 l = normalize(lightDirectionEC);\n\
76
- vec3 h = normalize(v + l);\n\
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 = pbrParameters.f0;\n\
85
- float reflectance = max(max(f0.r, f0.g), f0.b);\n\
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
- float alpha = pbrParameters.roughness;\n\
90
- float G = smithVisibilityGGX(alpha, NdotL, NdotV);\n\
91
- float D = GGX(alpha, NdotH);\n\
92
- vec3 specularContribution = F * G * D / (4.0 * NdotL * NdotV);\n\
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 = pbrParameters.diffuseColor;\n\
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 * lightColorHdr;\n\
163
+ return (diffuseContribution + specularContribution) * NdotL;\n\
100
164
  }\n\
101
165
  ";
@@ -10,7 +10,7 @@
10
10
  * @property {vec3} normalEC Unperturbed surface normal in eye coordinates.
11
11
  * @property {mat3} tangentToEyeMatrix Matrix for converting a tangent space normal to eye space.
12
12
  * @property {vec3} positionToEyeEC Vector from the fragment to the eye in eye coordinates. The magnitude is the distance in meters from the fragment to the eye.
13
- * @property {float} height The height of the terrain in meters above or below the WGS84 ellipsoid. Only available for globe materials.
13
+ * @property {float} height The height of the terrain in meters above or below the ellipsoid. Only available for globe materials.
14
14
  * @property {float} slope The slope of the terrain in radians. 0 is flat; pi/2 is vertical. Only available for globe materials.
15
15
  * @property {float} aspect The aspect of the terrain in radians. 0 is East, pi/2 is North, pi is West, 3pi/2 is South. Only available for globe materials.
16
16
  */
@@ -11,7 +11,7 @@ export default "/**\n\
11
11
  * @property {vec3} normalEC Unperturbed surface normal in eye coordinates.\n\
12
12
  * @property {mat3} tangentToEyeMatrix Matrix for converting a tangent space normal to eye space.\n\
13
13
  * @property {vec3} positionToEyeEC Vector from the fragment to the eye in eye coordinates. The magnitude is the distance in meters from the fragment to the eye.\n\
14
- * @property {float} height The height of the terrain in meters above or below the WGS84 ellipsoid. Only available for globe materials.\n\
14
+ * @property {float} height The height of the terrain in meters above or below the ellipsoid. Only available for globe materials.\n\
15
15
  * @property {float} slope The slope of the terrain in radians. 0 is flat; pi/2 is vertical. Only available for globe materials.\n\
16
16
  * @property {float} aspect The aspect of the terrain in radians. 0 is East, pi/2 is North, pi is West, 3pi/2 is South. Only available for globe materials.\n\
17
17
  */\n\
@@ -10,6 +10,7 @@
10
10
  * @name czm_modelMaterial
11
11
  * @glslStruct
12
12
  *
13
+ * @property {vec4} baseColor The base color of the material.
13
14
  * @property {vec3} diffuse Incoming light that scatters evenly in all directions.
14
15
  * @property {float} alpha Alpha of this material. 0.0 is completely transparent; 1.0 is completely opaque.
15
16
  * @property {vec3} specular Color of reflected light at normal incidence in PBR materials. This is sometimes referred to as f0 in the literature.
@@ -19,6 +20,7 @@
19
20
  * @property {vec3} emissive Light emitted by the material equally in all directions. The default is vec3(0.0), which emits no light.
20
21
  */
21
22
  struct czm_modelMaterial {
23
+ vec4 baseColor;
22
24
  vec3 diffuse;
23
25
  float alpha;
24
26
  vec3 specular;
@@ -26,4 +28,18 @@ struct czm_modelMaterial {
26
28
  vec3 normalEC;
27
29
  float occlusion;
28
30
  vec3 emissive;
31
+ #ifdef USE_SPECULAR
32
+ float specularWeight;
33
+ #endif
34
+ #ifdef USE_ANISOTROPY
35
+ vec3 anisotropicT;
36
+ vec3 anisotropicB;
37
+ float anisotropyStrength;
38
+ #endif
39
+ #ifdef USE_CLEARCOAT
40
+ float clearcoatFactor;
41
+ float clearcoatRoughness;
42
+ vec3 clearcoatNormal;
43
+ // Add clearcoatF0 when KHR_materials_ior is implemented
44
+ #endif
29
45
  };
@@ -11,6 +11,7 @@ export default "/**\n\
11
11
  * @name czm_modelMaterial\n\
12
12
  * @glslStruct\n\
13
13
  *\n\
14
+ * @property {vec4} baseColor The base color of the material.\n\
14
15
  * @property {vec3} diffuse Incoming light that scatters evenly in all directions.\n\
15
16
  * @property {float} alpha Alpha of this material. 0.0 is completely transparent; 1.0 is completely opaque.\n\
16
17
  * @property {vec3} specular Color of reflected light at normal incidence in PBR materials. This is sometimes referred to as f0 in the literature.\n\
@@ -20,6 +21,7 @@ export default "/**\n\
20
21
  * @property {vec3} emissive Light emitted by the material equally in all directions. The default is vec3(0.0), which emits no light.\n\
21
22
  */\n\
22
23
  struct czm_modelMaterial {\n\
24
+ vec4 baseColor;\n\
23
25
  vec3 diffuse;\n\
24
26
  float alpha;\n\
25
27
  vec3 specular;\n\
@@ -27,5 +29,19 @@ struct czm_modelMaterial {\n\
27
29
  vec3 normalEC;\n\
28
30
  float occlusion;\n\
29
31
  vec3 emissive;\n\
32
+ #ifdef USE_SPECULAR\n\
33
+ float specularWeight;\n\
34
+ #endif\n\
35
+ #ifdef USE_ANISOTROPY\n\
36
+ vec3 anisotropicT;\n\
37
+ vec3 anisotropicB;\n\
38
+ float anisotropyStrength;\n\
39
+ #endif\n\
40
+ #ifdef USE_CLEARCOAT\n\
41
+ float clearcoatFactor;\n\
42
+ float clearcoatRoughness;\n\
43
+ vec3 clearcoatNormal;\n\
44
+ // Add clearcoatF0 when KHR_materials_ior is implemented\n\
45
+ #endif\n\
30
46
  };\n\
31
47
  ";
@@ -12,7 +12,7 @@ vec4 computeEllipsoidColor(czm_ray ray, float intersection, float side)
12
12
  vec3 normalMC = geodeticNormal * side; // normalized surface normal (always facing the viewer) in model coordinates
13
13
  vec3 normalEC = normalize(czm_normal * normalMC); // normalized surface normal in eye coordinates
14
14
 
15
- vec2 st = czm_ellipsoidWgs84TextureCoordinates(sphericalNormal);
15
+ vec2 st = czm_ellipsoidTextureCoordinates(sphericalNormal);
16
16
  vec3 positionToEyeEC = -positionEC;
17
17
 
18
18
  czm_materialInput materialInput;
@@ -13,7 +13,7 @@ vec4 computeEllipsoidColor(czm_ray ray, float intersection, float side)\n\
13
13
  vec3 normalMC = geodeticNormal * side; // normalized surface normal (always facing the viewer) in model coordinates\n\
14
14
  vec3 normalEC = normalize(czm_normal * normalMC); // normalized surface normal in eye coordinates\n\
15
15
  \n\
16
- vec2 st = czm_ellipsoidWgs84TextureCoordinates(sphericalNormal);\n\
16
+ vec2 st = czm_ellipsoidTextureCoordinates(sphericalNormal);\n\
17
17
  vec3 positionToEyeEC = -positionEC;\n\
18
18
  \n\
19
19
  czm_materialInput materialInput;\n\
@@ -207,7 +207,7 @@ vec4 sampleAndBlend(
207
207
 
208
208
  #ifdef APPLY_COLOR_TO_ALPHA
209
209
  vec3 colorDiff = abs(color.rgb - colorToAlpha.rgb);
210
- colorDiff.r = max(max(colorDiff.r, colorDiff.g), colorDiff.b);
210
+ colorDiff.r = czm_maximumComponent(colorDiff);
211
211
  alpha = czm_branchFreeTernary(colorDiff.r < colorToAlpha.a, 0.0, alpha);
212
212
  #endif
213
213
 
@@ -374,8 +374,8 @@ void main()
374
374
  {
375
375
  mat3 enuToEye = czm_eastNorthUpToEyeCoordinates(v_positionMC, normalEC);
376
376
 
377
- vec2 ellipsoidTextureCoordinates = czm_ellipsoidWgs84TextureCoordinates(normalMC);
378
- vec2 ellipsoidFlippedTextureCoordinates = czm_ellipsoidWgs84TextureCoordinates(normalMC.zyx);
377
+ vec2 ellipsoidTextureCoordinates = czm_ellipsoidTextureCoordinates(normalMC);
378
+ vec2 ellipsoidFlippedTextureCoordinates = czm_ellipsoidTextureCoordinates(normalMC.zyx);
379
379
 
380
380
  vec2 textureCoordinates = mix(ellipsoidTextureCoordinates, ellipsoidFlippedTextureCoordinates, czm_morphTime * smoothstep(0.9, 0.95, normalMC.z));
381
381
 
@@ -208,7 +208,7 @@ vec4 sampleAndBlend(\n\
208
208
  \n\
209
209
  #ifdef APPLY_COLOR_TO_ALPHA\n\
210
210
  vec3 colorDiff = abs(color.rgb - colorToAlpha.rgb);\n\
211
- colorDiff.r = max(max(colorDiff.r, colorDiff.g), colorDiff.b);\n\
211
+ colorDiff.r = czm_maximumComponent(colorDiff);\n\
212
212
  alpha = czm_branchFreeTernary(colorDiff.r < colorToAlpha.a, 0.0, alpha);\n\
213
213
  #endif\n\
214
214
  \n\
@@ -375,8 +375,8 @@ void main()\n\
375
375
  {\n\
376
376
  mat3 enuToEye = czm_eastNorthUpToEyeCoordinates(v_positionMC, normalEC);\n\
377
377
  \n\
378
- vec2 ellipsoidTextureCoordinates = czm_ellipsoidWgs84TextureCoordinates(normalMC);\n\
379
- vec2 ellipsoidFlippedTextureCoordinates = czm_ellipsoidWgs84TextureCoordinates(normalMC.zyx);\n\
378
+ vec2 ellipsoidTextureCoordinates = czm_ellipsoidTextureCoordinates(normalMC);\n\
379
+ vec2 ellipsoidFlippedTextureCoordinates = czm_ellipsoidTextureCoordinates(normalMC.zyx);\n\
380
380
  \n\
381
381
  vec2 textureCoordinates = mix(ellipsoidTextureCoordinates, ellipsoidFlippedTextureCoordinates, czm_morphTime * smoothstep(0.9, 0.95, normalMC.z));\n\
382
382
  \n\