@cesium/engine 9.1.0 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Build/ThirdParty/Workers/pako_deflate.min.js +108 -210
- package/Build/ThirdParty/Workers/pako_inflate.min.js +466 -568
- package/Build/ThirdParty/Workers/z-worker-pako.js +54 -104
- package/Build/Workers/{chunk-TMMOULW3.js → chunk-2J3JKXCP.js} +5 -5
- package/Build/Workers/{chunk-ZDP32RQI.js → chunk-3WUV74WM.js} +95 -155
- package/Build/Workers/{chunk-FOZQIHZK.js → chunk-4BAE4PWO.js} +6 -6
- package/Build/Workers/{chunk-CYAJYEKW.js → chunk-4MSUJ4I7.js} +8 -8
- package/Build/Workers/{chunk-KPY4F4BW.js → chunk-4YSNMHZ4.js} +6 -6
- package/Build/Workers/{chunk-66E3H2KU.js → chunk-5S7OLEPK.js} +12 -12
- package/Build/Workers/{chunk-4AJGCQFX.js → chunk-7XGC6YB2.js} +14 -14
- package/Build/Workers/{chunk-BDUJXBVF.js → chunk-AA4GZKOT.js} +3 -5
- package/Build/Workers/{chunk-7LPEGKOF.js → chunk-AD5HBJ2F.js} +11 -8
- package/Build/Workers/{chunk-XHLDDE65.js → chunk-AVI4IUWC.js} +11 -11
- package/Build/Workers/{chunk-MWYZ64MH.js → chunk-BCL4PHHT.js} +10 -10
- package/Build/Workers/{chunk-PWF3YJJ5.js → chunk-BDFNKFOE.js} +13 -13
- package/Build/Workers/{chunk-7VZNXIKG.js → chunk-BJF5LOWE.js} +7 -7
- package/Build/Workers/{chunk-3S2MFY4B.js → chunk-C2CGMAIU.js} +13 -13
- package/Build/Workers/{chunk-UAJEGIWA.js → chunk-COYFZ5VA.js} +6 -6
- package/Build/Workers/{chunk-ZWPIM77Q.js → chunk-DGS5QNIO.js} +13 -13
- package/Build/Workers/{chunk-V7JB576Q.js → chunk-DKVHRNFY.js} +5 -5
- package/Build/Workers/{chunk-NI2R52QD.js → chunk-DOXCPOG4.js} +11 -9
- package/Build/Workers/{chunk-XWML5Y7N.js → chunk-FXIHSF7O.js} +9 -9
- package/Build/Workers/{chunk-LW7WGHEU.js → chunk-G3YR53LY.js} +13 -13
- package/Build/Workers/{chunk-34DGOKCO.js → chunk-GR3CDLCP.js} +7 -7
- package/Build/Workers/{chunk-AOIKO5Y7.js → chunk-GRAT5GE7.js} +5 -5
- package/Build/Workers/{chunk-AOFMPKUB.js → chunk-I2RC4XVN.js} +4 -4
- package/Build/Workers/{chunk-PK7TEP3J.js → chunk-JYAHOGGL.js} +15 -15
- package/Build/Workers/{chunk-4KIUON73.js → chunk-KUN2ZA5X.js} +4 -4
- package/Build/Workers/{chunk-POLFRINT.js → chunk-L6RTJ3RE.js} +14 -14
- package/Build/Workers/{chunk-LVJCR7DH.js → chunk-LCLJJ2MZ.js} +18 -18
- package/Build/Workers/{chunk-3RZK5NNV.js → chunk-LEABCTLP.js} +4 -4
- package/Build/Workers/{chunk-QKF7XXEQ.js → chunk-MDHQR3ZS.js} +10 -8
- package/Build/Workers/{chunk-4PHPQRSH.js → chunk-MSKXMXJI.js} +5 -6
- package/Build/Workers/{chunk-GIFJ77E4.js → chunk-NTXTUNEF.js} +4 -4
- package/Build/Workers/{chunk-I5TDPPC4.js → chunk-O3JCMSS3.js} +17 -17
- package/Build/Workers/{chunk-PEABJLCK.js → chunk-OOK53QUQ.js} +1 -1
- package/Build/Workers/{chunk-PS6AEMBR.js → chunk-OORVMGDU.js} +7 -7
- package/Build/Workers/{chunk-JI2445T5.js → chunk-PCP4YQST.js} +11 -11
- package/Build/Workers/{chunk-C5CE4OG6.js → chunk-PYHLO636.js} +42 -13
- package/Build/Workers/{chunk-S4XDCPKD.js → chunk-Q55ECN3Y.js} +1 -1
- package/Build/Workers/{chunk-WWP3I7R5.js → chunk-QD4KM3GO.js} +5 -5
- package/Build/Workers/{chunk-YLZTCEBJ.js → chunk-QMLTCCYG.js} +1 -1
- package/Build/Workers/{chunk-IBXGK4WV.js → chunk-QX5XS4LC.js} +2 -2
- package/Build/Workers/{chunk-RL73GOEF.js → chunk-R6B7UCQB.js} +2 -2
- package/Build/Workers/{chunk-RR7EOKGZ.js → chunk-RJYML24O.js} +48 -85
- package/Build/Workers/{chunk-U4IMCOF5.js → chunk-S3PI2KFM.js} +2 -2
- package/Build/Workers/{chunk-6HCAQOVK.js → chunk-STBBMQGG.js} +6 -6
- package/Build/Workers/{chunk-CE6GTZ4I.js → chunk-SYCPRK3D.js} +10 -10
- package/Build/Workers/{chunk-WFICTTOE.js → chunk-T77JILCU.js} +2 -2
- package/Build/Workers/{chunk-ZC4AGBZK.js → chunk-TO2PVHKI.js} +2 -2
- package/Build/Workers/{chunk-UCPPWV64.js → chunk-VE7BFUIX.js} +1 -1
- package/Build/Workers/{chunk-2CSEEWHN.js → chunk-VFBNELXB.js} +7 -7
- package/Build/Workers/{chunk-A6NCZSL3.js → chunk-VO3ACQB2.js} +19 -19
- package/Build/Workers/{chunk-WEGCQ5DY.js → chunk-X23FRWHJ.js} +6 -6
- package/Build/Workers/{chunk-G7CJQKKD.js → chunk-XD445VDH.js} +7 -7
- package/Build/Workers/combineGeometry.js +22 -22
- package/Build/Workers/createBoxGeometry.js +16 -16
- package/Build/Workers/createBoxOutlineGeometry.js +14 -14
- package/Build/Workers/createCircleGeometry.js +29 -25
- package/Build/Workers/createCircleOutlineGeometry.js +17 -17
- package/Build/Workers/createCoplanarPolygonGeometry.js +32 -32
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +29 -29
- package/Build/Workers/createCorridorGeometry.js +29 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +27 -27
- package/Build/Workers/createCylinderGeometry.js +18 -18
- package/Build/Workers/createCylinderOutlineGeometry.js +16 -16
- package/Build/Workers/createEllipseGeometry.js +24 -24
- package/Build/Workers/createEllipseOutlineGeometry.js +17 -17
- package/Build/Workers/createEllipsoidGeometry.js +17 -17
- package/Build/Workers/createEllipsoidOutlineGeometry.js +16 -16
- package/Build/Workers/createFrustumGeometry.js +16 -16
- package/Build/Workers/createFrustumOutlineGeometry.js +16 -16
- package/Build/Workers/createGeometry.js +22 -22
- package/Build/Workers/createGroundPolylineGeometry.js +24 -24
- package/Build/Workers/createPlaneGeometry.js +14 -14
- package/Build/Workers/createPlaneOutlineGeometry.js +13 -13
- package/Build/Workers/createPolygonGeometry.js +32 -32
- package/Build/Workers/createPolygonOutlineGeometry.js +29 -29
- package/Build/Workers/createPolylineGeometry.js +24 -24
- package/Build/Workers/createPolylineVolumeGeometry.js +30 -30
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +26 -26
- package/Build/Workers/createRectangleGeometry.js +27 -27
- package/Build/Workers/createRectangleOutlineGeometry.js +19 -19
- package/Build/Workers/createSimplePolylineGeometry.js +22 -22
- package/Build/Workers/createSphereGeometry.js +17 -17
- package/Build/Workers/createSphereOutlineGeometry.js +16 -16
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +13 -13
- package/Build/Workers/createVectorTileGeometries.js +22 -22
- package/Build/Workers/createVectorTilePoints.js +12 -12
- package/Build/Workers/createVectorTilePolygons.js +20 -20
- package/Build/Workers/createVectorTilePolylines.js +13 -13
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +20 -20
- package/Build/Workers/createVerticesFromHeightmap.js +21 -21
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +17 -17
- package/Build/Workers/createWallGeometry.js +23 -23
- package/Build/Workers/createWallOutlineGeometry.js +22 -22
- package/Build/Workers/decodeDraco.js +11 -11
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +12 -19
- package/Build/Workers/decodeI3S.js +10 -10
- package/Build/Workers/transcodeKTX2.js +43 -79
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +20 -20
- package/Source/Core/ApproximateTerrainHeights.js +4 -4
- package/Source/Core/ArcGISTiledElevationTerrainProvider.js +12 -8
- package/Source/Core/BoundingRectangle.js +2 -0
- package/Source/Core/BoundingSphere.js +4 -2
- package/Source/Core/Cartesian3.js +13 -10
- package/Source/Core/Cartographic.js +11 -8
- package/Source/Core/CesiumTerrainProvider.js +3 -2
- package/Source/Core/CircleGeometry.js +6 -2
- package/Source/Core/CircleOutlineGeometry.js +1 -1
- package/Source/Core/CoplanarPolygonGeometry.js +3 -3
- package/Source/Core/CorridorGeometry.js +4 -4
- package/Source/Core/CorridorOutlineGeometry.js +2 -2
- package/Source/Core/Credit.js +3 -2
- package/Source/Core/CustomHeightmapTerrainProvider.js +17 -3
- package/Source/Core/EllipseGeometry.js +4 -4
- package/Source/Core/EllipseOutlineGeometry.js +2 -2
- package/Source/Core/Ellipsoid.js +34 -0
- package/Source/Core/EllipsoidGeodesic.js +2 -2
- package/Source/Core/EllipsoidRhumbLine.js +4 -4
- package/Source/Core/EllipsoidTangentPlane.js +3 -3
- package/Source/Core/EllipsoidTerrainProvider.js +3 -3
- package/Source/Core/GeographicProjection.js +4 -3
- package/Source/Core/GeographicTilingScheme.js +3 -3
- package/Source/Core/GeometryPipeline.js +2 -2
- package/Source/Core/GoogleEarthEnterpriseTerrainProvider.js +1 -1
- package/Source/Core/GoogleMaps.js +1 -1
- package/Source/Core/GroundPolylineGeometry.js +1 -1
- package/Source/Core/HeightmapTessellator.js +2 -2
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/Math.js +0 -5
- package/Source/Core/Occluder.js +3 -3
- package/Source/Core/OrientedBoundingBox.js +2 -2
- package/Source/Core/PolygonGeometry.js +4 -4
- package/Source/Core/PolygonGeometryLibrary.js +1 -1
- package/Source/Core/PolygonOutlineGeometry.js +3 -3
- package/Source/Core/PolygonPipeline.js +2 -2
- package/Source/Core/PolylineGeometry.js +2 -2
- package/Source/Core/PolylinePipeline.js +6 -6
- package/Source/Core/PolylineVolumeGeometry.js +2 -2
- package/Source/Core/PolylineVolumeOutlineGeometry.js +2 -2
- package/Source/Core/Rectangle.js +6 -6
- package/Source/Core/RectangleGeometry.js +6 -6
- package/Source/Core/RectangleGeometryLibrary.js +3 -0
- package/Source/Core/RectangleOutlineGeometry.js +2 -2
- package/Source/Core/Simon1994PlanetaryPositions.js +3 -2
- package/Source/Core/SimplePolylineGeometry.js +2 -2
- package/Source/Core/Stereographic.js +2 -2
- package/Source/Core/TaskProcessor.js +19 -3
- package/Source/Core/Transforms.js +17 -17
- package/Source/Core/VRTheWorldTerrainProvider.js +2 -2
- package/Source/Core/WallGeometry.js +3 -3
- package/Source/Core/WallOutlineGeometry.js +3 -3
- package/Source/Core/WebMercatorTilingScheme.js +3 -3
- package/Source/Core/createWorldTerrainAsync.js +2 -0
- package/Source/Core/sampleTerrain.js +3 -3
- package/Source/DataSources/BoxGeometryUpdater.js +2 -2
- package/Source/DataSources/CylinderGeometryUpdater.js +2 -2
- package/Source/DataSources/CzmlDataSource.js +8 -8
- package/Source/DataSources/EllipsoidGeometryUpdater.js +3 -3
- package/Source/DataSources/EntityCluster.js +1 -1
- package/Source/DataSources/EntityView.js +2 -2
- package/Source/DataSources/KmlDataSource.js +4 -4
- package/Source/DataSources/ModelVisualizer.js +1 -2
- package/Source/DataSources/PolygonGeometryUpdater.js +1 -1
- package/Source/DataSources/PolylineGeometryUpdater.js +3 -2
- package/Source/DataSources/RectangleGeometryUpdater.js +1 -1
- package/Source/DataSources/ScaledPositionProperty.js +2 -2
- package/Source/DataSources/TerrainOffsetProperty.js +3 -7
- package/Source/DataSources/VelocityOrientationProperty.js +2 -2
- package/Source/DataSources/exportKml.js +2 -2
- package/Source/Renderer/UniformState.js +1 -1
- package/Source/Scene/ArcGisMapServerImageryProvider.js +2 -2
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Billboard.js +8 -6
- package/Source/Scene/BingMapsImageryProvider.js +1 -1
- package/Source/Scene/Camera.js +16 -10
- package/Source/Scene/Cesium3DTileset.js +1 -1
- package/Source/Scene/ClippingPolygon.js +2 -2
- package/Source/Scene/ClippingPolygonCollection.js +1 -1
- package/Source/Scene/CreditDisplay.js +94 -104
- package/Source/Scene/Globe.js +16 -13
- package/Source/Scene/GltfLoader.js +458 -435
- package/Source/Scene/GltfLoaderUtil.js +5 -16
- package/Source/Scene/GltfPipeline/forEachTextureInMaterial.js +23 -7
- package/Source/Scene/GltfStructuralMetadataLoader.js +11 -9
- package/Source/Scene/GoogleEarthEnterpriseImageryProvider.js +1 -1
- package/Source/Scene/GoogleEarthEnterpriseMapsProvider.js +1 -1
- package/Source/Scene/GridImageryProvider.js +2 -2
- package/Source/Scene/ImageryLayerCollection.js +2 -2
- package/Source/Scene/Label.js +1 -1
- package/Source/Scene/MapboxImageryProvider.js +1 -1
- package/Source/Scene/MapboxStyleImageryProvider.js +1 -1
- package/Source/Scene/MetadataSemantic.js +4 -4
- package/Source/Scene/Model/AlphaPipelineStage.js +1 -1
- package/Source/Scene/Model/GeometryPipelineStage.js +15 -43
- package/Source/Scene/Model/ImageBasedLightingPipelineStage.js +7 -0
- package/Source/Scene/Model/InstancingPipelineStage.js +3 -3
- package/Source/Scene/Model/LightingPipelineStage.js +2 -4
- package/Source/Scene/Model/MaterialPipelineStage.js +395 -29
- package/Source/Scene/Model/Model.js +15 -7
- package/Source/Scene/Model/ModelSceneGraph.js +1 -1
- package/Source/Scene/Model/ModelUtility.js +3 -0
- package/Source/Scene/Model/SceneMode2DPipelineStage.js +3 -3
- package/Source/Scene/Model/VerticalExaggerationPipelineStage.js +4 -6
- package/Source/Scene/Model/pickModel.js +2 -2
- package/Source/Scene/ModelComponents.js +178 -1
- package/Source/Scene/PickDepth.js +23 -15
- package/Source/Scene/Picking.js +4 -13
- package/Source/Scene/PointPrimitive.js +5 -2
- package/Source/Scene/ResourceCache.js +41 -50
- package/Source/Scene/ResourceCacheKey.js +41 -53
- package/Source/Scene/Scene.js +39 -31
- package/Source/Scene/SceneTransforms.js +78 -20
- package/Source/Scene/SceneTransitioner.js +2 -2
- package/Source/Scene/ScreenSpaceCameraController.js +29 -19
- package/Source/Scene/SkyBox.js +26 -0
- package/Source/Scene/Sun.js +1 -1
- package/Source/Shaders/Builtin/CzmBuiltins.js +4 -10
- package/Source/Shaders/Builtin/Functions/ellipsoidTextureCoordinates.glsl +10 -0
- package/Source/Shaders/Builtin/Functions/{ellipsoidWgs84TextureCoordinates.js → ellipsoidTextureCoordinates.js} +3 -3
- package/Source/Shaders/Builtin/Functions/maximumComponent.glsl +21 -0
- package/Source/Shaders/Builtin/Functions/maximumComponent.js +23 -0
- package/Source/Shaders/Builtin/Functions/pbrLighting.glsl +108 -44
- package/Source/Shaders/Builtin/Functions/pbrLighting.js +108 -44
- package/Source/Shaders/Builtin/Structs/materialInput.glsl +1 -1
- package/Source/Shaders/Builtin/Structs/materialInput.js +1 -1
- package/Source/Shaders/Builtin/Structs/modelMaterial.glsl +16 -0
- package/Source/Shaders/Builtin/Structs/modelMaterial.js +16 -0
- package/Source/Shaders/EllipsoidFS.glsl +1 -1
- package/Source/Shaders/EllipsoidFS.js +1 -1
- package/Source/Shaders/GlobeFS.glsl +3 -3
- package/Source/Shaders/GlobeFS.js +3 -3
- package/Source/Shaders/Model/ImageBasedLightingStageFS.glsl +211 -133
- package/Source/Shaders/Model/ImageBasedLightingStageFS.js +212 -133
- package/Source/Shaders/Model/LightingStageFS.glsl +113 -48
- package/Source/Shaders/Model/LightingStageFS.js +113 -48
- package/Source/Shaders/Model/MaterialStageFS.glsl +407 -136
- package/Source/Shaders/Model/MaterialStageFS.js +407 -136
- package/Source/Widget/CesiumWidget.css +0 -5
- package/Source/Widget/CesiumWidget.js +29 -28
- package/index.d.ts +184 -116
- package/index.js +92 -95
- package/package.json +2 -2
- package/Source/Shaders/Builtin/Functions/defaultPbrMaterial.glsl +0 -16
- package/Source/Shaders/Builtin/Functions/defaultPbrMaterial.js +0 -18
- package/Source/Shaders/Builtin/Functions/ellipsoidWgs84TextureCoordinates.glsl +0 -10
- package/Source/Shaders/Builtin/Functions/pbrMetallicRoughnessMaterial.glsl +0 -37
- package/Source/Shaders/Builtin/Functions/pbrMetallicRoughnessMaterial.js +0 -39
- package/Source/Shaders/Builtin/Functions/pbrSpecularGlossinessMaterial.glsl +0 -30
- package/Source/Shaders/Builtin/Functions/pbrSpecularGlossinessMaterial.js +0 -32
- package/Source/Shaders/Builtin/Structs/pbrParameters.glsl +0 -16
- package/Source/Shaders/Builtin/Structs/pbrParameters.js +0 -18
|
@@ -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
|
|
21
|
-
|
|
20
|
+
#ifdef HAS_NORMAL_TEXTURE\n\
|
|
21
|
+
vec2 getNormalTexCoords()\n\
|
|
22
22
|
{\n\
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
vec3
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
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
|
-
|
|
97
|
+
#if defined(HAS_NORMAL_TEXTURE) && !defined(HAS_WIREFRAME)\n\
|
|
98
|
+
vec3 getNormalFromTexture(ProcessedAttributes attributes, vec3 geometryNormal)\n\
|
|
67
99
|
{\n\
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
#
|
|
87
|
-
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
102
|
-
|
|
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
|
-
|
|
105
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
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
|
-
|
|
192
|
+
#ifdef HAS_EMISSIVE_TEXTURE_TRANSFORM\n\
|
|
119
193
|
emissiveTexCoords = computeTextureTransform(emissiveTexCoords, u_emissiveTextureTransform);\n\
|
|
120
|
-
|
|
194
|
+
#endif\n\
|
|
121
195
|
\n\
|
|
122
196
|
vec3 emissive = czm_srgbToLinear(texture(u_emissiveTexture, emissiveTexCoords).rgb);\n\
|
|
123
|
-
|
|
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
|
-
|
|
132
|
-
|
|
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
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
-
|
|
142
|
-
specular *=
|
|
143
|
-
|
|
217
|
+
#ifdef HAS_LEGACY_SPECULAR_FACTOR\n\
|
|
218
|
+
specular *= u_legacySpecularFactor;\n\
|
|
219
|
+
#endif\n\
|
|
144
220
|
\n\
|
|
145
|
-
|
|
221
|
+
#ifdef HAS_GLOSSINESS_FACTOR\n\
|
|
146
222
|
glossiness *= u_glossinessFactor;\n\
|
|
147
|
-
|
|
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
|
-
|
|
229
|
+
#endif\n\
|
|
154
230
|
\n\
|
|
155
|
-
|
|
231
|
+
#ifdef HAS_GLOSSINESS_FACTOR\n\
|
|
156
232
|
float glossiness = clamp(u_glossinessFactor, 0.0, 1.0);\n\
|
|
157
|
-
|
|
233
|
+
#else\n\
|
|
158
234
|
float glossiness = 1.0;\n\
|
|
159
|
-
#endif\n\
|
|
160
235
|
#endif\n\
|
|
236
|
+
#endif\n\
|
|
161
237
|
\n\
|
|
162
|
-
|
|
238
|
+
#ifdef HAS_DIFFUSE_TEXTURE\n\
|
|
163
239
|
vec2 diffuseTexCoords = TEXCOORD_DIFFUSE;\n\
|
|
164
|
-
|
|
240
|
+
#ifdef HAS_DIFFUSE_TEXTURE_TRANSFORM\n\
|
|
165
241
|
diffuseTexCoords = computeTextureTransform(diffuseTexCoords, u_diffuseTextureTransform);\n\
|
|
166
|
-
|
|
242
|
+
#endif\n\
|
|
167
243
|
\n\
|
|
168
244
|
vec4 diffuse = czm_srgbToLinear(texture(u_diffuseTexture, diffuseTexCoords));\n\
|
|
169
|
-
|
|
245
|
+
#ifdef HAS_DIFFUSE_FACTOR\n\
|
|
170
246
|
diffuse *= u_diffuseFactor;\n\
|
|
171
|
-
|
|
172
|
-
|
|
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
|
-
|
|
250
|
+
#else\n\
|
|
175
251
|
vec4 diffuse = vec4(1.0);\n\
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
|
|
187
|
-
material.
|
|
188
|
-
|
|
189
|
-
|
|
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
|
-
|
|
270
|
+
#ifdef HAS_METALLIC_ROUGHNESS_TEXTURE_TRANSFORM\n\
|
|
192
271
|
metallicRoughnessTexCoords = computeTextureTransform(metallicRoughnessTexCoords, u_metallicRoughnessTextureTransform);\n\
|
|
193
|
-
|
|
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
|
-
|
|
199
|
-
metalness
|
|
200
|
-
|
|
277
|
+
#ifdef HAS_METALLIC_FACTOR\n\
|
|
278
|
+
metalness = clamp(metalness * u_metallicFactor, 0.0, 1.0);\n\
|
|
279
|
+
#endif\n\
|
|
201
280
|
\n\
|
|
202
|
-
|
|
203
|
-
roughness
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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
|
-
|
|
287
|
+
#else\n\
|
|
209
288
|
float metalness = 1.0;\n\
|
|
210
|
-
|
|
289
|
+
#endif\n\
|
|
211
290
|
\n\
|
|
212
|
-
|
|
291
|
+
#ifdef HAS_ROUGHNESS_FACTOR\n\
|
|
213
292
|
float roughness = clamp(u_roughnessFactor, 0.04, 1.0);\n\
|
|
214
|
-
|
|
293
|
+
#else\n\
|
|
215
294
|
float roughness = 1.0;\n\
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
material.
|
|
224
|
-
|
|
225
|
-
|
|
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
|
";
|