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