@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
@@ -17,212 +17,483 @@ vec2 computeTextureTransform(vec2 texCoord, mat3 textureTransform)\n\
17
17
  return vec2(textureTransform * vec3(texCoord, 1.0));\n\
18
18
  }\n\
19
19
  \n\
20
- #ifdef HAS_NORMALS\n\
21
- vec3 computeNormal(ProcessedAttributes attributes)\n\
20
+ #ifdef HAS_NORMAL_TEXTURE\n\
21
+ vec2 getNormalTexCoords()\n\
22
22
  {\n\
23
- // Geometry normal. This is already normalized \n\
24
- vec3 ng = attributes.normalEC;\n\
23
+ vec2 texCoord = TEXCOORD_NORMAL;\n\
24
+ #ifdef HAS_NORMAL_TEXTURE_TRANSFORM\n\
25
+ texCoord = vec2(u_normalTextureTransform * vec3(texCoord, 1.0));\n\
26
+ #endif\n\
27
+ return texCoord;\n\
28
+ }\n\
29
+ #endif\n\
25
30
  \n\
26
- vec3 normal = ng;\n\
27
- #if defined(HAS_NORMAL_TEXTURE) && !defined(HAS_WIREFRAME)\n\
28
- vec2 normalTexCoords = TEXCOORD_NORMAL;\n\
29
- #ifdef HAS_NORMAL_TEXTURE_TRANSFORM\n\
30
- normalTexCoords = computeTextureTransform(normalTexCoords, u_normalTextureTransform);\n\
31
- #endif\n\
31
+ #if defined(HAS_NORMAL_TEXTURE) || defined(HAS_CLEARCOAT_NORMAL_TEXTURE)\n\
32
+ vec3 computeTangent(in vec3 position, in vec2 normalTexCoords)\n\
33
+ {\n\
34
+ vec2 tex_dx = dFdx(normalTexCoords);\n\
35
+ vec2 tex_dy = dFdy(normalTexCoords);\n\
36
+ float determinant = tex_dx.x * tex_dy.y - tex_dy.x * tex_dx.y;\n\
37
+ vec3 tangent = tex_dy.t * dFdx(position) - tex_dx.t * dFdy(position);\n\
38
+ return tangent / determinant;\n\
39
+ }\n\
40
+ #endif\n\
32
41
  \n\
33
- // If HAS_BITANGENTS is set, then HAS_TANGENTS is also set\n\
34
- #ifdef HAS_BITANGENTS\n\
35
- vec3 t = attributes.tangentEC;\n\
36
- vec3 b = attributes.bitangentEC;\n\
37
- mat3 tbn = mat3(t, b, ng);\n\
38
- vec3 n = texture(u_normalTexture, normalTexCoords).rgb;\n\
39
- normal = normalize(tbn * (2.0 * n - 1.0));\n\
40
- #elif (__VERSION__ == 300 || defined(GL_OES_standard_derivatives))\n\
41
- // If derivatives are available (not IE 10), compute tangents\n\
42
- vec3 positionEC = attributes.positionEC;\n\
43
- vec3 pos_dx = dFdx(positionEC);\n\
44
- vec3 pos_dy = dFdy(positionEC);\n\
45
- vec3 tex_dx = dFdx(vec3(normalTexCoords,0.0));\n\
46
- vec3 tex_dy = dFdy(vec3(normalTexCoords,0.0));\n\
47
- vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);\n\
48
- t = normalize(t - ng * dot(ng, t));\n\
49
- vec3 b = normalize(cross(ng, t));\n\
50
- mat3 tbn = mat3(t, b, ng);\n\
51
- vec3 n = texture(u_normalTexture, normalTexCoords).rgb;\n\
52
- normal = normalize(tbn * (2.0 * n - 1.0));\n\
42
+ #ifdef USE_ANISOTROPY\n\
43
+ struct NormalInfo {\n\
44
+ vec3 tangent;\n\
45
+ vec3 bitangent;\n\
46
+ vec3 normal;\n\
47
+ vec3 geometryNormal;\n\
48
+ };\n\
49
+ \n\
50
+ NormalInfo getNormalInfo(ProcessedAttributes attributes)\n\
51
+ {\n\
52
+ vec3 geometryNormal = attributes.normalEC;\n\
53
+ #ifdef HAS_NORMAL_TEXTURE\n\
54
+ vec2 normalTexCoords = getNormalTexCoords();\n\
55
+ #endif\n\
56
+ \n\
57
+ #ifdef HAS_BITANGENTS\n\
58
+ vec3 tangent = attributes.tangentEC;\n\
59
+ vec3 bitangent = attributes.bitangentEC;\n\
60
+ #else // Assume HAS_NORMAL_TEXTURE\n\
61
+ vec3 tangent = computeTangent(attributes.positionEC, normalTexCoords);\n\
62
+ tangent = normalize(tangent - geometryNormal * dot(geometryNormal, tangent));\n\
63
+ vec3 bitangent = normalize(cross(geometryNormal, tangent));\n\
64
+ #endif\n\
65
+ \n\
66
+ #ifdef HAS_NORMAL_TEXTURE\n\
67
+ mat3 tbn = mat3(tangent, bitangent, geometryNormal);\n\
68
+ vec3 normalSample = texture(u_normalTexture, normalTexCoords).rgb;\n\
69
+ normalSample = 2.0 * normalSample - 1.0;\n\
70
+ #ifdef HAS_NORMAL_TEXTURE_SCALE\n\
71
+ normalSample.xy *= u_normalTextureScale;\n\
53
72
  #endif\n\
73
+ vec3 normal = normalize(tbn * normalSample);\n\
74
+ #else\n\
75
+ vec3 normal = geometryNormal;\n\
54
76
  #endif\n\
55
77
  \n\
56
78
  #ifdef HAS_DOUBLE_SIDED_MATERIAL\n\
57
- if (czm_backFacing()) {\n\
58
- normal = -normal;\n\
59
- }\n\
79
+ if (czm_backFacing()) {\n\
80
+ tangent *= -1.0;\n\
81
+ bitangent *= -1.0;\n\
82
+ normal *= -1.0;\n\
83
+ geometryNormal *= -1.0;\n\
84
+ }\n\
60
85
  #endif\n\
61
86
  \n\
62
- return normal;\n\
87
+ NormalInfo normalInfo;\n\
88
+ normalInfo.tangent = tangent;\n\
89
+ normalInfo.bitangent = bitangent;\n\
90
+ normalInfo.normal = normal;\n\
91
+ normalInfo.geometryNormal = geometryNormal;\n\
92
+ \n\
93
+ return normalInfo;\n\
63
94
  }\n\
64
95
  #endif\n\
65
96
  \n\
66
- void materialStage(inout czm_modelMaterial material, ProcessedAttributes attributes, SelectedFeature feature)\n\
97
+ #if defined(HAS_NORMAL_TEXTURE) && !defined(HAS_WIREFRAME)\n\
98
+ vec3 getNormalFromTexture(ProcessedAttributes attributes, vec3 geometryNormal)\n\
67
99
  {\n\
68
- #ifdef HAS_NORMALS\n\
69
- material.normalEC = computeNormal(attributes);\n\
100
+ vec2 normalTexCoords = getNormalTexCoords();\n\
101
+ \n\
102
+ // If HAS_BITANGENTS is set, then HAS_TANGENTS is also set\n\
103
+ #ifdef HAS_BITANGENTS\n\
104
+ vec3 t = attributes.tangentEC;\n\
105
+ vec3 b = attributes.bitangentEC;\n\
106
+ #else\n\
107
+ vec3 t = computeTangent(attributes.positionEC, normalTexCoords);\n\
108
+ t = normalize(t - geometryNormal * dot(geometryNormal, t));\n\
109
+ vec3 b = normalize(cross(geometryNormal, t));\n\
70
110
  #endif\n\
71
111
  \n\
72
- vec4 baseColorWithAlpha = vec4(1.0);\n\
73
- // Regardless of whether we use PBR, set a base color\n\
74
- #ifdef HAS_BASE_COLOR_TEXTURE\n\
75
- vec2 baseColorTexCoords = TEXCOORD_BASE_COLOR;\n\
112
+ mat3 tbn = mat3(t, b, geometryNormal);\n\
113
+ vec3 normalSample = texture(u_normalTexture, normalTexCoords).rgb;\n\
114
+ normalSample = 2.0 * normalSample - 1.0;\n\
115
+ #ifdef HAS_NORMAL_TEXTURE_SCALE\n\
116
+ normalSample.xy *= u_normalTextureScale;\n\
117
+ #endif\n\
118
+ return normalize(tbn * normalSample);\n\
119
+ }\n\
120
+ #endif\n\
76
121
  \n\
77
- #ifdef HAS_BASE_COLOR_TEXTURE_TRANSFORM\n\
78
- baseColorTexCoords = computeTextureTransform(baseColorTexCoords, u_baseColorTextureTransform);\n\
79
- #endif\n\
122
+ #ifdef HAS_CLEARCOAT_NORMAL_TEXTURE\n\
123
+ vec3 getClearcoatNormalFromTexture(ProcessedAttributes attributes, vec3 geometryNormal)\n\
124
+ {\n\
125
+ vec2 normalTexCoords = TEXCOORD_CLEARCOAT_NORMAL;\n\
126
+ #ifdef HAS_CLEARCOAT_NORMAL_TEXTURE_TRANSFORM\n\
127
+ normalTexCoords = vec2(u_clearcoatNormalTextureTransform * vec3(normalTexCoords, 1.0));\n\
128
+ #endif\n\
80
129
  \n\
81
- baseColorWithAlpha = czm_srgbToLinear(texture(u_baseColorTexture, baseColorTexCoords));\n\
130
+ // If HAS_BITANGENTS is set, then HAS_TANGENTS is also set\n\
131
+ #ifdef HAS_BITANGENTS\n\
132
+ vec3 t = attributes.tangentEC;\n\
133
+ vec3 b = attributes.bitangentEC;\n\
134
+ #else\n\
135
+ vec3 t = computeTangent(attributes.positionEC, normalTexCoords);\n\
136
+ t = normalize(t - geometryNormal * dot(geometryNormal, t));\n\
137
+ vec3 b = normalize(cross(geometryNormal, t));\n\
138
+ #endif\n\
82
139
  \n\
83
- #ifdef HAS_BASE_COLOR_FACTOR\n\
84
- baseColorWithAlpha *= u_baseColorFactor;\n\
85
- #endif\n\
86
- #elif defined(HAS_BASE_COLOR_FACTOR)\n\
87
- baseColorWithAlpha = u_baseColorFactor;\n\
140
+ mat3 tbn = mat3(t, b, geometryNormal);\n\
141
+ vec3 normalSample = texture(u_clearcoatNormalTexture, normalTexCoords).rgb;\n\
142
+ normalSample = 2.0 * normalSample - 1.0;\n\
143
+ #ifdef HAS_CLEARCOAT_NORMAL_TEXTURE_SCALE\n\
144
+ normalSample.xy *= u_clearcoatNormalTextureScale;\n\
88
145
  #endif\n\
146
+ return normalize(tbn * normalSample);\n\
147
+ }\n\
148
+ #endif\n\
89
149
  \n\
90
- #ifdef HAS_POINT_CLOUD_COLOR_STYLE\n\
91
- baseColorWithAlpha = v_pointCloudColor;\n\
92
- #elif defined(HAS_COLOR_0)\n\
93
- vec4 color = attributes.color_0;\n\
94
- // .pnts files store colors in the sRGB color space\n\
95
- #ifdef HAS_SRGB_COLOR\n\
96
- color = czm_srgbToLinear(color);\n\
97
- #endif\n\
98
- baseColorWithAlpha *= color;\n\
150
+ #ifdef HAS_NORMALS\n\
151
+ vec3 computeNormal(ProcessedAttributes attributes)\n\
152
+ {\n\
153
+ // Geometry normal. This is already normalized \n\
154
+ vec3 normal = attributes.normalEC;\n\
155
+ \n\
156
+ #if defined(HAS_NORMAL_TEXTURE) && !defined(HAS_WIREFRAME)\n\
157
+ normal = getNormalFromTexture(attributes, normal);\n\
99
158
  #endif\n\
100
159
  \n\
101
- material.diffuse = baseColorWithAlpha.rgb;\n\
102
- material.alpha = baseColorWithAlpha.a;\n\
160
+ #ifdef HAS_DOUBLE_SIDED_MATERIAL\n\
161
+ if (czm_backFacing()) {\n\
162
+ normal = -normal;\n\
163
+ }\n\
164
+ #endif\n\
103
165
  \n\
104
- #ifdef USE_CPU_STYLING\n\
105
- material.diffuse = blend(material.diffuse, feature.color.rgb, model_colorBlend);\n\
166
+ return normal;\n\
167
+ }\n\
168
+ #endif\n\
169
+ \n\
170
+ #ifdef HAS_BASE_COLOR_TEXTURE\n\
171
+ vec4 getBaseColorFromTexture()\n\
172
+ {\n\
173
+ vec2 baseColorTexCoords = TEXCOORD_BASE_COLOR;\n\
174
+ #ifdef HAS_BASE_COLOR_TEXTURE_TRANSFORM\n\
175
+ baseColorTexCoords = computeTextureTransform(baseColorTexCoords, u_baseColorTextureTransform);\n\
106
176
  #endif\n\
107
177
  \n\
108
- #ifdef HAS_OCCLUSION_TEXTURE\n\
109
- vec2 occlusionTexCoords = TEXCOORD_OCCLUSION;\n\
110
- #ifdef HAS_OCCLUSION_TEXTURE_TRANSFORM\n\
111
- occlusionTexCoords = computeTextureTransform(occlusionTexCoords, u_occlusionTextureTransform);\n\
112
- #endif\n\
113
- material.occlusion = texture(u_occlusionTexture, occlusionTexCoords).r;\n\
178
+ vec4 baseColorWithAlpha = czm_srgbToLinear(texture(u_baseColorTexture, baseColorTexCoords));\n\
179
+ \n\
180
+ #ifdef HAS_BASE_COLOR_FACTOR\n\
181
+ baseColorWithAlpha *= u_baseColorFactor;\n\
114
182
  #endif\n\
115
183
  \n\
116
- #ifdef HAS_EMISSIVE_TEXTURE\n\
184
+ return baseColorWithAlpha;\n\
185
+ }\n\
186
+ #endif\n\
187
+ \n\
188
+ #ifdef HAS_EMISSIVE_TEXTURE\n\
189
+ vec3 getEmissiveFromTexture()\n\
190
+ {\n\
117
191
  vec2 emissiveTexCoords = TEXCOORD_EMISSIVE;\n\
118
- #ifdef HAS_EMISSIVE_TEXTURE_TRANSFORM\n\
192
+ #ifdef HAS_EMISSIVE_TEXTURE_TRANSFORM\n\
119
193
  emissiveTexCoords = computeTextureTransform(emissiveTexCoords, u_emissiveTextureTransform);\n\
120
- #endif\n\
194
+ #endif\n\
121
195
  \n\
122
196
  vec3 emissive = czm_srgbToLinear(texture(u_emissiveTexture, emissiveTexCoords).rgb);\n\
123
- #ifdef HAS_EMISSIVE_FACTOR\n\
197
+ #ifdef HAS_EMISSIVE_FACTOR\n\
124
198
  emissive *= u_emissiveFactor;\n\
125
- #endif\n\
126
- material.emissive = emissive;\n\
127
- #elif defined(HAS_EMISSIVE_FACTOR)\n\
128
- material.emissive = u_emissiveFactor;\n\
129
199
  #endif\n\
130
200
  \n\
131
- #if defined(LIGHTING_PBR) && defined(USE_SPECULAR_GLOSSINESS)\n\
132
- #ifdef HAS_SPECULAR_GLOSSINESS_TEXTURE\n\
201
+ return emissive;\n\
202
+ }\n\
203
+ #endif\n\
204
+ \n\
205
+ #if defined(LIGHTING_PBR) && defined(USE_SPECULAR_GLOSSINESS)\n\
206
+ void setSpecularGlossiness(inout czm_modelMaterial material)\n\
207
+ {\n\
208
+ #ifdef HAS_SPECULAR_GLOSSINESS_TEXTURE\n\
133
209
  vec2 specularGlossinessTexCoords = TEXCOORD_SPECULAR_GLOSSINESS;\n\
134
- #ifdef HAS_SPECULAR_GLOSSINESS_TEXTURE_TRANSFORM\n\
135
- specularGlossinessTexCoords = computeTextureTransform(specularGlossinessTexCoords, u_specularGlossinessTextureTransform);\n\
136
- #endif\n\
210
+ #ifdef HAS_SPECULAR_GLOSSINESS_TEXTURE_TRANSFORM\n\
211
+ specularGlossinessTexCoords = computeTextureTransform(specularGlossinessTexCoords, u_specularGlossinessTextureTransform);\n\
212
+ #endif\n\
137
213
  \n\
138
214
  vec4 specularGlossiness = czm_srgbToLinear(texture(u_specularGlossinessTexture, specularGlossinessTexCoords));\n\
139
215
  vec3 specular = specularGlossiness.rgb;\n\
140
216
  float glossiness = specularGlossiness.a;\n\
141
- #ifdef HAS_SPECULAR_FACTOR\n\
142
- specular *= u_specularFactor;\n\
143
- #endif\n\
217
+ #ifdef HAS_LEGACY_SPECULAR_FACTOR\n\
218
+ specular *= u_legacySpecularFactor;\n\
219
+ #endif\n\
144
220
  \n\
145
- #ifdef HAS_GLOSSINESS_FACTOR\n\
221
+ #ifdef HAS_GLOSSINESS_FACTOR\n\
146
222
  glossiness *= u_glossinessFactor;\n\
147
- #endif\n\
223
+ #endif\n\
224
+ #else\n\
225
+ #ifdef HAS_LEGACY_SPECULAR_FACTOR\n\
226
+ vec3 specular = clamp(u_legacySpecularFactor, vec3(0.0), vec3(1.0));\n\
148
227
  #else\n\
149
- #ifdef HAS_SPECULAR_FACTOR\n\
150
- vec3 specular = clamp(u_specularFactor, vec3(0.0), vec3(1.0));\n\
151
- #else\n\
152
228
  vec3 specular = vec3(1.0);\n\
153
- #endif\n\
229
+ #endif\n\
154
230
  \n\
155
- #ifdef HAS_GLOSSINESS_FACTOR\n\
231
+ #ifdef HAS_GLOSSINESS_FACTOR\n\
156
232
  float glossiness = clamp(u_glossinessFactor, 0.0, 1.0);\n\
157
- #else\n\
233
+ #else\n\
158
234
  float glossiness = 1.0;\n\
159
- #endif\n\
160
235
  #endif\n\
236
+ #endif\n\
161
237
  \n\
162
- #ifdef HAS_DIFFUSE_TEXTURE\n\
238
+ #ifdef HAS_DIFFUSE_TEXTURE\n\
163
239
  vec2 diffuseTexCoords = TEXCOORD_DIFFUSE;\n\
164
- #ifdef HAS_DIFFUSE_TEXTURE_TRANSFORM\n\
240
+ #ifdef HAS_DIFFUSE_TEXTURE_TRANSFORM\n\
165
241
  diffuseTexCoords = computeTextureTransform(diffuseTexCoords, u_diffuseTextureTransform);\n\
166
- #endif\n\
242
+ #endif\n\
167
243
  \n\
168
244
  vec4 diffuse = czm_srgbToLinear(texture(u_diffuseTexture, diffuseTexCoords));\n\
169
- #ifdef HAS_DIFFUSE_FACTOR\n\
245
+ #ifdef HAS_DIFFUSE_FACTOR\n\
170
246
  diffuse *= u_diffuseFactor;\n\
171
- #endif\n\
172
- #elif defined(HAS_DIFFUSE_FACTOR)\n\
247
+ #endif\n\
248
+ #elif defined(HAS_DIFFUSE_FACTOR)\n\
173
249
  vec4 diffuse = clamp(u_diffuseFactor, vec4(0.0), vec4(1.0));\n\
174
- #else\n\
250
+ #else\n\
175
251
  vec4 diffuse = vec4(1.0);\n\
176
- #endif\n\
177
- czm_pbrParameters parameters = czm_pbrSpecularGlossinessMaterial(\n\
178
- diffuse.rgb,\n\
179
- specular,\n\
180
- glossiness\n\
181
- );\n\
182
- material.diffuse = parameters.diffuseColor;\n\
252
+ #endif\n\
253
+ \n\
254
+ material.diffuse = diffuse.rgb * (1.0 - czm_maximumComponent(specular));\n\
183
255
  // the specular glossiness extension's alpha overrides anything set\n\
184
256
  // by the base material.\n\
185
257
  material.alpha = diffuse.a;\n\
186
- material.specular = parameters.f0;\n\
187
- material.roughness = parameters.roughness;\n\
188
- #elif defined(LIGHTING_PBR)\n\
189
- #ifdef HAS_METALLIC_ROUGHNESS_TEXTURE\n\
258
+ \n\
259
+ material.specular = specular;\n\
260
+ \n\
261
+ // glossiness is the opposite of roughness, but easier for artists to use.\n\
262
+ float roughness = 1.0 - glossiness;\n\
263
+ material.roughness = roughness * roughness;\n\
264
+ }\n\
265
+ #elif defined(LIGHTING_PBR)\n\
266
+ float setMetallicRoughness(inout czm_modelMaterial material)\n\
267
+ {\n\
268
+ #ifdef HAS_METALLIC_ROUGHNESS_TEXTURE\n\
190
269
  vec2 metallicRoughnessTexCoords = TEXCOORD_METALLIC_ROUGHNESS;\n\
191
- #ifdef HAS_METALLIC_ROUGHNESS_TEXTURE_TRANSFORM\n\
270
+ #ifdef HAS_METALLIC_ROUGHNESS_TEXTURE_TRANSFORM\n\
192
271
  metallicRoughnessTexCoords = computeTextureTransform(metallicRoughnessTexCoords, u_metallicRoughnessTextureTransform);\n\
193
- #endif\n\
272
+ #endif\n\
194
273
  \n\
195
274
  vec3 metallicRoughness = texture(u_metallicRoughnessTexture, metallicRoughnessTexCoords).rgb;\n\
196
275
  float metalness = clamp(metallicRoughness.b, 0.0, 1.0);\n\
197
276
  float roughness = clamp(metallicRoughness.g, 0.04, 1.0);\n\
198
- #ifdef HAS_METALLIC_FACTOR\n\
199
- metalness *= u_metallicFactor;\n\
200
- #endif\n\
277
+ #ifdef HAS_METALLIC_FACTOR\n\
278
+ metalness = clamp(metalness * u_metallicFactor, 0.0, 1.0);\n\
279
+ #endif\n\
201
280
  \n\
202
- #ifdef HAS_ROUGHNESS_FACTOR\n\
203
- roughness *= u_roughnessFactor;\n\
204
- #endif\n\
205
- #else\n\
206
- #ifdef HAS_METALLIC_FACTOR\n\
281
+ #ifdef HAS_ROUGHNESS_FACTOR\n\
282
+ roughness = clamp(roughness * u_roughnessFactor, 0.0, 1.0);\n\
283
+ #endif\n\
284
+ #else\n\
285
+ #ifdef HAS_METALLIC_FACTOR\n\
207
286
  float metalness = clamp(u_metallicFactor, 0.0, 1.0);\n\
208
- #else\n\
287
+ #else\n\
209
288
  float metalness = 1.0;\n\
210
- #endif\n\
289
+ #endif\n\
211
290
  \n\
212
- #ifdef HAS_ROUGHNESS_FACTOR\n\
291
+ #ifdef HAS_ROUGHNESS_FACTOR\n\
213
292
  float roughness = clamp(u_roughnessFactor, 0.04, 1.0);\n\
214
- #else\n\
293
+ #else\n\
215
294
  float roughness = 1.0;\n\
216
- #endif\n\
217
- #endif\n\
218
- czm_pbrParameters parameters = czm_pbrMetallicRoughnessMaterial(\n\
219
- material.diffuse,\n\
220
- metalness,\n\
221
- roughness\n\
222
- );\n\
223
- material.diffuse = parameters.diffuseColor;\n\
224
- material.specular = parameters.f0;\n\
225
- material.roughness = parameters.roughness;\n\
295
+ #endif\n\
296
+ #endif\n\
297
+ \n\
298
+ // dielectrics use f0 = 0.04, metals use albedo as f0\n\
299
+ const vec3 REFLECTANCE_DIELECTRIC = vec3(0.04);\n\
300
+ vec3 f0 = mix(REFLECTANCE_DIELECTRIC, material.baseColor.rgb, metalness);\n\
301
+ \n\
302
+ material.specular = f0;\n\
303
+ \n\
304
+ // diffuse only applies to dielectrics.\n\
305
+ material.diffuse = mix(material.baseColor.rgb, vec3(0.0), metalness);\n\
306
+ \n\
307
+ // roughness is authored as perceptual roughness\n\
308
+ // square it to get material roughness\n\
309
+ material.roughness = roughness * roughness;\n\
310
+ \n\
311
+ return metalness;\n\
312
+ }\n\
313
+ #ifdef USE_SPECULAR\n\
314
+ void setSpecular(inout czm_modelMaterial material, in float metalness)\n\
315
+ {\n\
316
+ #ifdef HAS_SPECULAR_TEXTURE\n\
317
+ vec2 specularTexCoords = TEXCOORD_SPECULAR;\n\
318
+ #ifdef HAS_SPECULAR_TEXTURE_TRANSFORM\n\
319
+ specularTexCoords = computeTextureTransform(specularTexCoords, u_specularTextureTransform);\n\
320
+ #endif\n\
321
+ float specularWeight = texture(u_specularTexture, specularTexCoords).a;\n\
322
+ #ifdef HAS_SPECULAR_FACTOR\n\
323
+ specularWeight *= u_specularFactor;\n\
324
+ #endif\n\
325
+ #else\n\
326
+ #ifdef HAS_SPECULAR_FACTOR\n\
327
+ float specularWeight = u_specularFactor;\n\
328
+ #else\n\
329
+ float specularWeight = 1.0;\n\
330
+ #endif\n\
331
+ #endif\n\
332
+ \n\
333
+ #ifdef HAS_SPECULAR_COLOR_TEXTURE\n\
334
+ vec2 specularColorTexCoords = TEXCOORD_SPECULAR_COLOR;\n\
335
+ #ifdef HAS_SPECULAR_COLOR_TEXTURE_TRANSFORM\n\
336
+ specularColorTexCoords = computeTextureTransform(specularColorTexCoords, u_specularColorTextureTransform);\n\
337
+ #endif\n\
338
+ vec3 specularColorSample = texture(u_specularColorTexture, specularColorTexCoords).rgb;\n\
339
+ vec3 specularColorFactor = czm_srgbToLinear(specularColorSample);\n\
340
+ #ifdef HAS_SPECULAR_COLOR_FACTOR\n\
341
+ specularColorFactor *= u_specularColorFactor;\n\
342
+ #endif\n\
343
+ #else\n\
344
+ #ifdef HAS_SPECULAR_COLOR_FACTOR\n\
345
+ vec3 specularColorFactor = u_specularColorFactor;\n\
346
+ #else\n\
347
+ vec3 specularColorFactor = vec3(1.0);\n\
348
+ #endif\n\
349
+ #endif\n\
350
+ material.specularWeight = specularWeight;\n\
351
+ vec3 f0 = material.specular;\n\
352
+ vec3 dielectricSpecularF0 = min(f0 * specularColorFactor, vec3(1.0));\n\
353
+ material.specular = mix(dielectricSpecularF0, material.baseColor.rgb, metalness);\n\
354
+ }\n\
355
+ #endif\n\
356
+ #ifdef USE_ANISOTROPY\n\
357
+ void setAnisotropy(inout czm_modelMaterial material, in NormalInfo normalInfo)\n\
358
+ {\n\
359
+ mat2 rotation = mat2(u_anisotropy.xy, -u_anisotropy.y, u_anisotropy.x);\n\
360
+ float anisotropyStrength = u_anisotropy.z;\n\
361
+ \n\
362
+ vec2 direction = vec2(1.0, 0.0);\n\
363
+ #ifdef HAS_ANISOTROPY_TEXTURE\n\
364
+ vec2 anisotropyTexCoords = TEXCOORD_ANISOTROPY;\n\
365
+ #ifdef HAS_ANISOTROPY_TEXTURE_TRANSFORM\n\
366
+ anisotropyTexCoords = computeTextureTransform(anisotropyTexCoords, u_anisotropyTextureTransform);\n\
367
+ #endif\n\
368
+ vec3 anisotropySample = texture(u_anisotropyTexture, anisotropyTexCoords).rgb;\n\
369
+ direction = anisotropySample.rg * 2.0 - vec2(1.0);\n\
370
+ anisotropyStrength *= anisotropySample.b;\n\
371
+ #endif\n\
372
+ \n\
373
+ direction = rotation * direction;\n\
374
+ mat3 tbn = mat3(normalInfo.tangent, normalInfo.bitangent, normalInfo.normal);\n\
375
+ vec3 anisotropicT = tbn * normalize(vec3(direction, 0.0));\n\
376
+ vec3 anisotropicB = cross(normalInfo.geometryNormal, anisotropicT);\n\
377
+ \n\
378
+ material.anisotropicT = anisotropicT;\n\
379
+ material.anisotropicB = anisotropicB;\n\
380
+ material.anisotropyStrength = anisotropyStrength;\n\
381
+ }\n\
382
+ #endif\n\
383
+ #ifdef USE_CLEARCOAT\n\
384
+ void setClearcoat(inout czm_modelMaterial material, in ProcessedAttributes attributes)\n\
385
+ {\n\
386
+ #ifdef HAS_CLEARCOAT_TEXTURE\n\
387
+ vec2 clearcoatTexCoords = TEXCOORD_CLEARCOAT;\n\
388
+ #ifdef HAS_CLEARCOAT_TEXTURE_TRANSFORM\n\
389
+ clearcoatTexCoords = computeTextureTransform(clearcoatTexCoords, u_clearcoatTextureTransform);\n\
390
+ #endif\n\
391
+ float clearcoatFactor = texture(u_clearcoatTexture, clearcoatTexCoords).r;\n\
392
+ #ifdef HAS_CLEARCOAT_FACTOR\n\
393
+ clearcoatFactor *= u_clearcoatFactor;\n\
394
+ #endif\n\
395
+ #else\n\
396
+ #ifdef HAS_CLEARCOAT_FACTOR\n\
397
+ float clearcoatFactor = u_clearcoatFactor;\n\
398
+ #else\n\
399
+ // PERFORMANCE_IDEA: this case should turn the whole extension off\n\
400
+ float clearcoatFactor = 0.0;\n\
401
+ #endif\n\
402
+ #endif\n\
403
+ \n\
404
+ #ifdef HAS_CLEARCOAT_ROUGHNESS_TEXTURE\n\
405
+ vec2 clearcoatRoughnessTexCoords = TEXCOORD_CLEARCOAT_ROUGHNESS;\n\
406
+ #ifdef HAS_CLEARCOAT_ROUGHNESS_TEXTURE_TRANSFORM\n\
407
+ clearcoatRoughnessTexCoords = computeTextureTransform(clearcoatRoughnessTexCoords, u_clearcoatRoughnessTextureTransform);\n\
408
+ #endif\n\
409
+ float clearcoatRoughness = texture(u_clearcoatRoughnessTexture, clearcoatRoughnessTexCoords).g;\n\
410
+ #ifdef HAS_CLEARCOAT_ROUGHNESS_FACTOR\n\
411
+ clearcoatRoughness *= u_clearcoatRoughnessFactor;\n\
412
+ #endif\n\
413
+ #else\n\
414
+ #ifdef HAS_CLEARCOAT_ROUGHNESS_FACTOR\n\
415
+ float clearcoatRoughness = u_clearcoatRoughnessFactor;\n\
416
+ #else\n\
417
+ float clearcoatRoughness = 0.0;\n\
418
+ #endif\n\
419
+ #endif\n\
420
+ \n\
421
+ material.clearcoatFactor = clearcoatFactor;\n\
422
+ // roughness is authored as perceptual roughness\n\
423
+ // square it to get material roughness\n\
424
+ material.clearcoatRoughness = clearcoatRoughness * clearcoatRoughness;\n\
425
+ #ifdef HAS_CLEARCOAT_NORMAL_TEXTURE\n\
426
+ material.clearcoatNormal = getClearcoatNormalFromTexture(attributes, attributes.normalEC);\n\
427
+ #else\n\
428
+ material.clearcoatNormal = attributes.normalEC;\n\
429
+ #endif\n\
430
+ }\n\
431
+ #endif\n\
432
+ #endif\n\
433
+ \n\
434
+ void materialStage(inout czm_modelMaterial material, ProcessedAttributes attributes, SelectedFeature feature)\n\
435
+ {\n\
436
+ #ifdef USE_ANISOTROPY\n\
437
+ NormalInfo normalInfo = getNormalInfo(attributes);\n\
438
+ material.normalEC = normalInfo.normal;\n\
439
+ #elif defined(HAS_NORMALS)\n\
440
+ material.normalEC = computeNormal(attributes);\n\
441
+ #endif\n\
442
+ \n\
443
+ vec4 baseColorWithAlpha = vec4(1.0);\n\
444
+ // Regardless of whether we use PBR, set a base color\n\
445
+ #ifdef HAS_BASE_COLOR_TEXTURE\n\
446
+ baseColorWithAlpha = getBaseColorFromTexture();\n\
447
+ #elif defined(HAS_BASE_COLOR_FACTOR)\n\
448
+ baseColorWithAlpha = u_baseColorFactor;\n\
449
+ #endif\n\
450
+ \n\
451
+ #ifdef HAS_POINT_CLOUD_COLOR_STYLE\n\
452
+ baseColorWithAlpha = v_pointCloudColor;\n\
453
+ #elif defined(HAS_COLOR_0)\n\
454
+ vec4 color = attributes.color_0;\n\
455
+ // .pnts files store colors in the sRGB color space\n\
456
+ #ifdef HAS_SRGB_COLOR\n\
457
+ color = czm_srgbToLinear(color);\n\
458
+ #endif\n\
459
+ baseColorWithAlpha *= color;\n\
460
+ #endif\n\
461
+ \n\
462
+ material.baseColor = baseColorWithAlpha;\n\
463
+ material.diffuse = baseColorWithAlpha.rgb;\n\
464
+ material.alpha = baseColorWithAlpha.a;\n\
465
+ \n\
466
+ #ifdef USE_CPU_STYLING\n\
467
+ material.diffuse = blend(material.diffuse, feature.color.rgb, model_colorBlend);\n\
468
+ #endif\n\
469
+ \n\
470
+ #ifdef HAS_OCCLUSION_TEXTURE\n\
471
+ vec2 occlusionTexCoords = TEXCOORD_OCCLUSION;\n\
472
+ #ifdef HAS_OCCLUSION_TEXTURE_TRANSFORM\n\
473
+ occlusionTexCoords = computeTextureTransform(occlusionTexCoords, u_occlusionTextureTransform);\n\
474
+ #endif\n\
475
+ material.occlusion = texture(u_occlusionTexture, occlusionTexCoords).r;\n\
476
+ #endif\n\
477
+ \n\
478
+ #ifdef HAS_EMISSIVE_TEXTURE\n\
479
+ material.emissive = getEmissiveFromTexture();\n\
480
+ #elif defined(HAS_EMISSIVE_FACTOR)\n\
481
+ material.emissive = u_emissiveFactor;\n\
482
+ #endif\n\
483
+ \n\
484
+ #if defined(LIGHTING_PBR) && defined(USE_SPECULAR_GLOSSINESS)\n\
485
+ setSpecularGlossiness(material);\n\
486
+ #elif defined(LIGHTING_PBR)\n\
487
+ float metalness = setMetallicRoughness(material);\n\
488
+ #ifdef USE_SPECULAR\n\
489
+ setSpecular(material, metalness);\n\
490
+ #endif\n\
491
+ #ifdef USE_ANISOTROPY\n\
492
+ setAnisotropy(material, normalInfo);\n\
493
+ #endif\n\
494
+ #ifdef USE_CLEARCOAT\n\
495
+ setClearcoat(material, attributes);\n\
496
+ #endif\n\
226
497
  #endif\n\
227
498
  }\n\
228
499
  ";
@@ -28,11 +28,6 @@
28
28
  padding-right: 5px;
29
29
  }
30
30
 
31
- .cesium-widget-credits a,
32
- .cesium-widget-credits a:visited {
33
- color: #fff;
34
- }
35
-
36
31
  .cesium-widget-errorPanel {
37
32
  position: absolute;
38
33
  top: 0;