@cesium/engine 10.0.0 → 11.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/Workers/{chunk-AA4GZKOT.js → chunk-2EDC3QGH.js} +1 -1
- package/Build/Workers/{chunk-DKVHRNFY.js → chunk-2MKRG7L7.js} +5 -5
- package/Build/Workers/{chunk-X23FRWHJ.js → chunk-2RZYNSMR.js} +6 -6
- package/Build/Workers/{chunk-TO2PVHKI.js → chunk-4NBRIKB3.js} +2 -2
- package/Build/Workers/{chunk-GRAT5GE7.js → chunk-4TK5YR6Q.js} +5 -5
- package/Build/Workers/{chunk-XD445VDH.js → chunk-54VC7SCM.js} +7 -7
- package/Build/Workers/{chunk-G3YR53LY.js → chunk-5IY5BXCT.js} +13 -13
- package/Build/Workers/{chunk-O3JCMSS3.js → chunk-6FFGOENI.js} +54 -7
- package/Build/Workers/{chunk-7XGC6YB2.js → chunk-6PJIHPQB.js} +13 -13
- package/Build/Workers/{chunk-GR3CDLCP.js → chunk-6ZREIBKS.js} +7 -7
- package/Build/Workers/{chunk-4MSUJ4I7.js → chunk-AI3O7UN2.js} +6 -6
- package/Build/Workers/{chunk-COYFZ5VA.js → chunk-AS7P4BHI.js} +6 -6
- package/Build/Workers/{chunk-JYAHOGGL.js → chunk-AUM45VEG.js} +16 -15
- package/Build/Workers/{chunk-BDFNKFOE.js → chunk-BBO6BGLC.js} +13 -13
- package/Build/Workers/{chunk-AVI4IUWC.js → chunk-BH5ZEN4I.js} +10 -10
- package/Build/Workers/{chunk-4BAE4PWO.js → chunk-BJ3WF5RW.js} +6 -6
- package/Build/Workers/{chunk-Q55ECN3Y.js → chunk-BUOFSNFW.js} +1 -1
- package/Build/Workers/{chunk-QX5XS4LC.js → chunk-BZXF3GNX.js} +2 -2
- package/Build/Workers/{chunk-PYHLO636.js → chunk-DJXXI7UF.js} +5 -5
- package/Build/Workers/{chunk-LCLJJ2MZ.js → chunk-DVAIU7A4.js} +17 -17
- package/Build/Workers/{chunk-SYCPRK3D.js → chunk-FJT3ERV7.js} +9 -9
- package/Build/Workers/{chunk-L6RTJ3RE.js → chunk-GOHDOWU5.js} +14 -14
- package/Build/Workers/{chunk-MSKXMXJI.js → chunk-HA6TZ3XT.js} +4 -4
- package/Build/Workers/{chunk-PCP4YQST.js → chunk-HBZSCVZC.js} +11 -11
- package/Build/Workers/{chunk-5S7OLEPK.js → chunk-HC7RYWPZ.js} +12 -12
- package/Build/Workers/{chunk-VE7BFUIX.js → chunk-HFMJM3SX.js} +1 -1
- package/Build/Workers/{chunk-OOK53QUQ.js → chunk-HFPMX5L2.js} +1 -1
- package/Build/Workers/{chunk-VFBNELXB.js → chunk-HO2NTC7I.js} +6 -6
- package/Build/Workers/{chunk-DOXCPOG4.js → chunk-HZPMWR4H.js} +7 -7
- package/Build/Workers/{chunk-I2RC4XVN.js → chunk-IBG5FVXC.js} +4 -4
- package/Build/Workers/{chunk-LEABCTLP.js → chunk-IXLNNST6.js} +4 -4
- package/Build/Workers/{chunk-4YSNMHZ4.js → chunk-JYUCC5NV.js} +6 -6
- package/Build/Workers/{chunk-BCL4PHHT.js → chunk-KFW4UNQH.js} +10 -10
- package/Build/Workers/{chunk-R6B7UCQB.js → chunk-KKAEXHDY.js} +2 -2
- package/Build/Workers/{chunk-BJF5LOWE.js → chunk-L6FARMF6.js} +7 -7
- package/Build/Workers/{chunk-C2CGMAIU.js → chunk-N3BIL6WA.js} +13 -13
- package/Build/Workers/{chunk-STBBMQGG.js → chunk-O5SSW3B3.js} +6 -6
- package/Build/Workers/{chunk-S3PI2KFM.js → chunk-OC4MYPVW.js} +2 -2
- package/Build/Workers/{chunk-MDHQR3ZS.js → chunk-OOA6GXKD.js} +7 -7
- package/Build/Workers/{chunk-AD5HBJ2F.js → chunk-OSCHEWSG.js} +7 -7
- package/Build/Workers/{chunk-NTXTUNEF.js → chunk-QGT2GMOK.js} +4 -4
- package/Build/Workers/{chunk-VO3ACQB2.js → chunk-RFQYEYAL.js} +17 -17
- package/Build/Workers/{chunk-KUN2ZA5X.js → chunk-RJF5ZP76.js} +4 -4
- package/Build/Workers/{chunk-QD4KM3GO.js → chunk-SIZXFNJY.js} +6 -5
- package/Build/Workers/{chunk-FXIHSF7O.js → chunk-SRZJCF7G.js} +9 -9
- package/Build/Workers/{chunk-T77JILCU.js → chunk-T4MB73MC.js} +2 -2
- package/Build/Workers/{chunk-3WUV74WM.js → chunk-TTI2SUWJ.js} +2 -2
- package/Build/Workers/{chunk-QMLTCCYG.js → chunk-VHJ5ESXF.js} +1 -1
- package/Build/Workers/{chunk-2J3JKXCP.js → chunk-VSFFJGTA.js} +9 -5
- package/Build/Workers/{chunk-DGS5QNIO.js → chunk-WQRXRDCZ.js} +11 -11
- package/Build/Workers/{chunk-OORVMGDU.js → chunk-WXDGOYTT.js} +12 -7
- package/Build/Workers/{chunk-RJYML24O.js → chunk-XLCZE6DD.js} +423 -448
- 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 +24 -24
- package/Build/Workers/createCircleOutlineGeometry.js +17 -17
- package/Build/Workers/createCoplanarPolygonGeometry.js +31 -31
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +29 -29
- package/Build/Workers/createCorridorGeometry.js +27 -27
- package/Build/Workers/createCorridorOutlineGeometry.js +26 -26
- 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 +20 -20
- package/Build/Workers/createPlaneGeometry.js +14 -14
- package/Build/Workers/createPlaneOutlineGeometry.js +13 -13
- package/Build/Workers/createPolygonGeometry.js +30 -30
- package/Build/Workers/createPolygonOutlineGeometry.js +28 -28
- package/Build/Workers/createPolylineGeometry.js +23 -23
- package/Build/Workers/createPolylineVolumeGeometry.js +29 -29
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +25 -25
- package/Build/Workers/createRectangleGeometry.js +25 -25
- package/Build/Workers/createRectangleOutlineGeometry.js +18 -18
- package/Build/Workers/createSimplePolylineGeometry.js +21 -21
- 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 +24 -20
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +17 -17
- package/Build/Workers/createWallGeometry.js +22 -22
- package/Build/Workers/createWallOutlineGeometry.js +21 -21
- package/Build/Workers/decodeDraco.js +11 -11
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +28 -5
- package/Build/Workers/decodeI3S.js +10 -10
- package/Build/Workers/transcodeKTX2.js +20 -22
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +20 -20
- package/Source/Core/CompressedTextureBuffer.js +11 -0
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/KTX2Transcoder.js +9 -16
- package/Source/Core/PixelFormat.js +1 -15
- package/Source/Core/Simon1994PlanetaryPositions.js +2 -1
- package/Source/Core/Transforms.js +137 -2
- package/Source/DataSources/BillboardGraphics.js +16 -0
- package/Source/DataSources/BillboardVisualizer.js +7 -0
- package/Source/DataSources/CallbackProperty.js +8 -2
- package/Source/DataSources/CheckerboardMaterialProperty.js +7 -1
- package/Source/DataSources/ColorMaterialProperty.js +7 -1
- package/Source/DataSources/CompositeMaterialProperty.js +5 -4
- package/Source/DataSources/CompositePositionProperty.js +7 -1
- package/Source/DataSources/CompositeProperty.js +5 -5
- package/Source/DataSources/ConstantPositionProperty.js +7 -1
- package/Source/DataSources/Entity.js +1 -1
- package/Source/DataSources/GridMaterialProperty.js +7 -1
- package/Source/DataSources/ImageMaterialProperty.js +8 -1
- package/Source/DataSources/MaterialProperty.js +7 -1
- package/Source/DataSources/NodeTransformationProperty.js +7 -1
- package/Source/DataSources/PathVisualizer.js +4 -4
- package/Source/DataSources/PointGraphics.js +17 -0
- package/Source/DataSources/PointVisualizer.js +12 -0
- package/Source/DataSources/PolylineArrowMaterialProperty.js +7 -1
- package/Source/DataSources/PolylineDashMaterialProperty.js +7 -1
- package/Source/DataSources/PolylineGlowMaterialProperty.js +7 -1
- package/Source/DataSources/PolylineOutlineMaterialProperty.js +7 -1
- package/Source/DataSources/PositionProperty.js +5 -8
- package/Source/DataSources/PositionPropertyArray.js +7 -1
- package/Source/DataSources/Property.js +1 -1
- package/Source/DataSources/PropertyArray.js +5 -5
- package/Source/DataSources/PropertyBag.js +5 -4
- package/Source/DataSources/ReferenceProperty.js +7 -1
- package/Source/DataSources/SampledPositionProperty.js +7 -1
- package/Source/DataSources/SampledProperty.js +6 -4
- package/Source/DataSources/ScaledPositionProperty.js +6 -0
- package/Source/DataSources/StripeMaterialProperty.js +7 -1
- package/Source/DataSources/TerrainOffsetProperty.js +9 -0
- package/Source/DataSources/TimeIntervalCollectionPositionProperty.js +7 -1
- package/Source/DataSources/TimeIntervalCollectionProperty.js +5 -5
- package/Source/DataSources/VelocityOrientationProperty.js +6 -1
- package/Source/DataSources/VelocityVectorProperty.js +3 -5
- package/Source/Renderer/AutomaticUniforms.js +3 -18
- package/Source/Renderer/Context.js +15 -0
- package/Source/Renderer/CubeMap.js +326 -348
- package/Source/Renderer/CubeMapFace.js +26 -48
- package/Source/Renderer/PixelDatatype.js +23 -0
- package/Source/Renderer/Sampler.js +7 -13
- package/Source/Renderer/ShaderProgram.js +7 -0
- package/Source/Renderer/Texture.js +396 -332
- package/Source/Renderer/UniformState.js +8 -33
- package/Source/Renderer/demodernizeShader.js +2 -0
- package/Source/Renderer/loadCubeMap.js +3 -8
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Billboard.js +29 -2
- package/Source/Scene/BillboardCollection.js +49 -0
- package/Source/Scene/BingMapsImageryProvider.js +10 -1
- package/Source/Scene/CameraEventAggregator.js +49 -5
- package/Source/Scene/Globe.js +1 -1
- package/Source/Scene/GlobeSurfaceShaderSet.js +29 -24
- package/Source/Scene/GlobeSurfaceTileProvider.js +5 -3
- package/Source/Scene/ImageBasedLighting.js +36 -36
- package/Source/Scene/Label.js +2 -2
- package/Source/Scene/Material.js +24 -2
- package/Source/Scene/Model/ImageBasedLightingPipelineStage.js +7 -15
- package/Source/Scene/Model/Model.js +1 -1
- package/Source/Scene/PointPrimitive.js +28 -2
- package/Source/Scene/PointPrimitiveCollection.js +22 -9
- package/Source/Scene/PostProcessStageCollection.js +45 -15
- package/Source/Scene/PostProcessStageLibrary.js +26 -0
- package/Source/Scene/Scene.js +20 -22
- package/Source/Scene/SceneTransforms.js +0 -62
- package/Source/Scene/ScreenSpaceCameraController.js +11 -4
- package/Source/Scene/SkyBox.js +13 -19
- package/Source/Scene/SpecularEnvironmentCubeMap.js +240 -0
- package/Source/Scene/Tonemapper.js +35 -23
- package/Source/Scene/VoxelPrimitive.js +0 -29
- package/Source/Scene/VoxelRenderResources.js +0 -3
- package/Source/Shaders/BillboardCollectionFS.glsl +4 -0
- package/Source/Shaders/BillboardCollectionFS.js +4 -0
- package/Source/Shaders/BillboardCollectionVS.glsl +3 -1
- package/Source/Shaders/BillboardCollectionVS.js +3 -1
- package/Source/Shaders/BrdfLutGeneratorFS.glsl +30 -13
- package/Source/Shaders/BrdfLutGeneratorFS.js +30 -13
- package/Source/Shaders/Builtin/CzmBuiltins.js +2 -2
- package/Source/Shaders/Builtin/Functions/pbrLighting.glsl +42 -41
- package/Source/Shaders/Builtin/Functions/pbrLighting.js +42 -41
- package/Source/Shaders/Builtin/Functions/pbrNeutralTonemapping.glsl +23 -0
- package/Source/Shaders/Builtin/Functions/pbrNeutralTonemapping.js +25 -0
- package/Source/Shaders/Builtin/Functions/textureCube.glsl +21 -2
- package/Source/Shaders/Builtin/Functions/textureCube.js +21 -2
- package/Source/Shaders/Builtin/Structs/materialInput.glsl +2 -0
- package/Source/Shaders/Builtin/Structs/materialInput.js +2 -0
- package/Source/Shaders/GlobeFS.glsl +10 -4
- package/Source/Shaders/GlobeFS.js +10 -4
- package/Source/Shaders/Materials/WaterMaskMaterial.glsl +15 -0
- package/Source/Shaders/Materials/WaterMaskMaterial.js +17 -0
- package/Source/Shaders/Model/AtmosphereStageFS.glsl +1 -1
- package/Source/Shaders/Model/AtmosphereStageFS.js +1 -1
- package/Source/Shaders/Model/ImageBasedLightingStageFS.glsl +57 -46
- package/Source/Shaders/Model/ImageBasedLightingStageFS.js +57 -46
- package/Source/Shaders/Model/LightingStageFS.glsl +8 -7
- package/Source/Shaders/Model/LightingStageFS.js +8 -7
- package/Source/Shaders/Model/MaterialStageFS.glsl +10 -14
- package/Source/Shaders/Model/MaterialStageFS.js +10 -14
- package/Source/Shaders/PointPrimitiveCollectionFS.glsl +4 -0
- package/Source/Shaders/PointPrimitiveCollectionFS.js +4 -0
- package/Source/Shaders/PointPrimitiveCollectionVS.glsl +9 -7
- package/Source/Shaders/PointPrimitiveCollectionVS.js +9 -7
- package/Source/Shaders/PostProcessStages/AcesTonemappingStage.glsl +4 -0
- package/Source/Shaders/PostProcessStages/AcesTonemappingStage.js +4 -0
- package/Source/Shaders/PostProcessStages/FilmicTonemapping.glsl +4 -0
- package/Source/Shaders/PostProcessStages/FilmicTonemapping.js +4 -0
- package/Source/Shaders/PostProcessStages/ModifiedReinhardTonemapping.glsl +4 -0
- package/Source/Shaders/PostProcessStages/ModifiedReinhardTonemapping.js +4 -0
- package/Source/Shaders/PostProcessStages/PbrNeutralTonemapping.glsl +25 -0
- package/Source/Shaders/PostProcessStages/PbrNeutralTonemapping.js +27 -0
- package/Source/Shaders/PostProcessStages/ReinhardTonemapping.glsl +4 -0
- package/Source/Shaders/PostProcessStages/ReinhardTonemapping.js +4 -0
- package/Source/Shaders/SkyAtmosphereFS.glsl +1 -1
- package/Source/Shaders/SkyAtmosphereFS.js +1 -1
- package/Source/Widget/CesiumWidget.js +1 -1
- package/index.d.ts +191 -106
- package/index.js +133 -134
- package/package.json +4 -4
- package/Source/Scene/OctahedralProjectedCubeMap.js +0 -445
- package/Source/Shaders/Builtin/Functions/sampleOctahedralProjection.glsl +0 -78
- package/Source/Shaders/Builtin/Functions/sampleOctahedralProjection.js +0 -80
- package/Source/Shaders/OctahedralProjectionAtlasFS.glsl +0 -89
- package/Source/Shaders/OctahedralProjectionAtlasFS.js +0 -91
- package/Source/Shaders/OctahedralProjectionFS.glsl +0 -14
- package/Source/Shaders/OctahedralProjectionFS.js +0 -16
- package/Source/Shaders/OctahedralProjectionVS.glsl +0 -10
- package/Source/Shaders/OctahedralProjectionVS.js +0 -12
|
@@ -6,12 +6,31 @@
|
|
|
6
6
|
* @glslFunction
|
|
7
7
|
*
|
|
8
8
|
* @param {samplerCube} sampler The sampler.
|
|
9
|
-
* @param {vec3} p The
|
|
9
|
+
* @param {vec3} p The coordinate at which to sample the texture.
|
|
10
10
|
*/
|
|
11
11
|
vec4 czm_textureCube(samplerCube sampler, vec3 p) {
|
|
12
12
|
#if __VERSION__ == 300
|
|
13
13
|
return texture(sampler, p);
|
|
14
|
-
#else
|
|
14
|
+
#else
|
|
15
15
|
return textureCube(sampler, p);
|
|
16
16
|
#endif
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A wrapper around the textureLod (WebGL2) / textureCube (WebGL1)
|
|
21
|
+
* function to allow for WebGL 1 support in fragment shaders.
|
|
22
|
+
*
|
|
23
|
+
* @name czm_textureCubeLod
|
|
24
|
+
* @glslFunction
|
|
25
|
+
*
|
|
26
|
+
* @param {samplerCube} sampler The sampler.
|
|
27
|
+
* @param {vec3} p The coordinate at which to sample the texture.
|
|
28
|
+
* @param {float} lod The mipmap level from which to sample.
|
|
29
|
+
*/
|
|
30
|
+
vec4 czm_textureCube(samplerCube sampler, vec3 p, float lod) {
|
|
31
|
+
#if __VERSION__ == 300
|
|
32
|
+
return textureLod(sampler, p, lod);
|
|
33
|
+
#elif defined(GL_EXT_shader_texture_lod)
|
|
34
|
+
return textureCubeLodEXT(sampler, p, lod);
|
|
35
|
+
#endif
|
|
17
36
|
}
|
|
@@ -7,12 +7,31 @@ export default "/**\n\
|
|
|
7
7
|
* @glslFunction\n\
|
|
8
8
|
*\n\
|
|
9
9
|
* @param {samplerCube} sampler The sampler.\n\
|
|
10
|
-
* @param {vec3} p The
|
|
10
|
+
* @param {vec3} p The coordinate at which to sample the texture.\n\
|
|
11
11
|
*/\n\
|
|
12
12
|
vec4 czm_textureCube(samplerCube sampler, vec3 p) {\n\
|
|
13
13
|
#if __VERSION__ == 300\n\
|
|
14
14
|
return texture(sampler, p);\n\
|
|
15
|
-
#else
|
|
15
|
+
#else\n\
|
|
16
16
|
return textureCube(sampler, p);\n\
|
|
17
17
|
#endif\n\
|
|
18
|
+
}\n\
|
|
19
|
+
\n\
|
|
20
|
+
/**\n\
|
|
21
|
+
* A wrapper around the textureLod (WebGL2) / textureCube (WebGL1)\n\
|
|
22
|
+
* function to allow for WebGL 1 support in fragment shaders.\n\
|
|
23
|
+
*\n\
|
|
24
|
+
* @name czm_textureCubeLod\n\
|
|
25
|
+
* @glslFunction\n\
|
|
26
|
+
*\n\
|
|
27
|
+
* @param {samplerCube} sampler The sampler.\n\
|
|
28
|
+
* @param {vec3} p The coordinate at which to sample the texture.\n\
|
|
29
|
+
* @param {float} lod The mipmap level from which to sample.\n\
|
|
30
|
+
*/\n\
|
|
31
|
+
vec4 czm_textureCube(samplerCube sampler, vec3 p, float lod) {\n\
|
|
32
|
+
#if __VERSION__ == 300\n\
|
|
33
|
+
return textureLod(sampler, p, lod);\n\
|
|
34
|
+
#elif defined(GL_EXT_shader_texture_lod)\n\
|
|
35
|
+
return textureCubeLodEXT(sampler, p, lod);\n\
|
|
36
|
+
#endif\n\
|
|
18
37
|
}";
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* @property {float} height The height of the terrain in meters above or below the ellipsoid. Only available for globe materials.
|
|
14
14
|
* @property {float} slope The slope of the terrain in radians. 0 is flat; pi/2 is vertical. Only available for globe materials.
|
|
15
15
|
* @property {float} aspect The aspect of the terrain in radians. 0 is East, pi/2 is North, pi is West, 3pi/2 is South. Only available for globe materials.
|
|
16
|
+
* @property {float} waterMask The value of the water mask. 0 is land, 1 is water. Only available for globe materials.
|
|
16
17
|
*/
|
|
17
18
|
struct czm_materialInput
|
|
18
19
|
{
|
|
@@ -25,4 +26,5 @@ struct czm_materialInput
|
|
|
25
26
|
float height;
|
|
26
27
|
float slope;
|
|
27
28
|
float aspect;
|
|
29
|
+
float waterMask;
|
|
28
30
|
};
|
|
@@ -14,6 +14,7 @@ export default "/**\n\
|
|
|
14
14
|
* @property {float} height The height of the terrain in meters above or below the ellipsoid. Only available for globe materials.\n\
|
|
15
15
|
* @property {float} slope The slope of the terrain in radians. 0 is flat; pi/2 is vertical. Only available for globe materials.\n\
|
|
16
16
|
* @property {float} aspect The aspect of the terrain in radians. 0 is East, pi/2 is North, pi is West, 3pi/2 is South. Only available for globe materials.\n\
|
|
17
|
+
* @property {float} waterMask The value of the water mask. 0 is land, 1 is water. Only available for globe materials.\n\
|
|
17
18
|
*/\n\
|
|
18
19
|
struct czm_materialInput\n\
|
|
19
20
|
{\n\
|
|
@@ -26,5 +27,6 @@ struct czm_materialInput\n\
|
|
|
26
27
|
float height;\n\
|
|
27
28
|
float slope;\n\
|
|
28
29
|
float aspect;\n\
|
|
30
|
+
float waterMask;\n\
|
|
29
31
|
};\n\
|
|
30
32
|
";
|
|
@@ -49,7 +49,7 @@ uniform vec4 u_colorsToAlpha[TEXTURE_UNITS];
|
|
|
49
49
|
uniform vec4 u_dayTextureTexCoordsRectangle[TEXTURE_UNITS];
|
|
50
50
|
#endif
|
|
51
51
|
|
|
52
|
-
#
|
|
52
|
+
#if defined(HAS_WATER_MASK) && (defined(SHOW_REFLECTIVE_OCEAN) || defined(APPLY_MATERIAL))
|
|
53
53
|
uniform sampler2D u_waterMask;
|
|
54
54
|
uniform vec4 u_waterMaskTranslationAndScale;
|
|
55
55
|
uniform float u_zoomedOutOceanSpecularIntensity;
|
|
@@ -362,7 +362,7 @@ void main()
|
|
|
362
362
|
float fade = 0.0;
|
|
363
363
|
#endif
|
|
364
364
|
|
|
365
|
-
#
|
|
365
|
+
#if defined(HAS_WATER_MASK) && (defined(SHOW_REFLECTIVE_OCEAN) || defined(APPLY_MATERIAL))
|
|
366
366
|
vec2 waterMaskTranslation = u_waterMaskTranslationAndScale.xy;
|
|
367
367
|
vec2 waterMaskScale = u_waterMaskTranslationAndScale.zw;
|
|
368
368
|
vec2 waterMaskTextureCoordinates = v_textureCoordinates.xy * waterMaskScale + waterMaskTranslation;
|
|
@@ -370,6 +370,7 @@ void main()
|
|
|
370
370
|
|
|
371
371
|
float mask = texture(u_waterMask, waterMaskTextureCoordinates).r;
|
|
372
372
|
|
|
373
|
+
#ifdef SHOW_REFLECTIVE_OCEAN
|
|
373
374
|
if (mask > 0.0)
|
|
374
375
|
{
|
|
375
376
|
mat3 enuToEye = czm_eastNorthUpToEyeCoordinates(v_positionMC, normalEC);
|
|
@@ -381,6 +382,7 @@ void main()
|
|
|
381
382
|
|
|
382
383
|
color = computeWaterColor(v_positionEC, textureCoordinates, enuToEye, color, mask, fade);
|
|
383
384
|
}
|
|
385
|
+
#endif
|
|
384
386
|
#endif
|
|
385
387
|
|
|
386
388
|
#ifdef APPLY_MATERIAL
|
|
@@ -392,6 +394,10 @@ void main()
|
|
|
392
394
|
materialInput.slope = v_slope;
|
|
393
395
|
materialInput.height = v_height;
|
|
394
396
|
materialInput.aspect = v_aspect;
|
|
397
|
+
#ifdef HAS_WATER_MASK
|
|
398
|
+
materialInput.waterMask = mask;
|
|
399
|
+
#endif
|
|
400
|
+
|
|
395
401
|
czm_material material = czm_getMaterial(materialInput);
|
|
396
402
|
vec4 materialColor = vec4(material.diffuse, material.alpha);
|
|
397
403
|
color = alphaBlend(materialColor, color);
|
|
@@ -422,7 +428,7 @@ void main()
|
|
|
422
428
|
#ifdef ENABLE_CLIPPING_POLYGONS
|
|
423
429
|
vec2 clippingPosition = v_clippingPosition;
|
|
424
430
|
int regionIndex = v_regionIndex;
|
|
425
|
-
clipPolygons(u_clippingDistance, CLIPPING_POLYGON_REGIONS_LENGTH, clippingPosition, regionIndex);
|
|
431
|
+
clipPolygons(u_clippingDistance, CLIPPING_POLYGON_REGIONS_LENGTH, clippingPosition, regionIndex);
|
|
426
432
|
#endif
|
|
427
433
|
|
|
428
434
|
#ifdef HIGHLIGHT_FILL_TILE
|
|
@@ -489,7 +495,7 @@ void main()
|
|
|
489
495
|
#endif
|
|
490
496
|
|
|
491
497
|
#ifndef HDR
|
|
492
|
-
fogColor.rgb =
|
|
498
|
+
fogColor.rgb = czm_pbrNeutralTonemapping(fogColor.rgb);
|
|
493
499
|
fogColor.rgb = czm_inverseGamma(fogColor.rgb);
|
|
494
500
|
#endif
|
|
495
501
|
|
|
@@ -50,7 +50,7 @@ uniform vec4 u_colorsToAlpha[TEXTURE_UNITS];\n\
|
|
|
50
50
|
uniform vec4 u_dayTextureTexCoordsRectangle[TEXTURE_UNITS];\n\
|
|
51
51
|
#endif\n\
|
|
52
52
|
\n\
|
|
53
|
-
#
|
|
53
|
+
#if defined(HAS_WATER_MASK) && (defined(SHOW_REFLECTIVE_OCEAN) || defined(APPLY_MATERIAL))\n\
|
|
54
54
|
uniform sampler2D u_waterMask;\n\
|
|
55
55
|
uniform vec4 u_waterMaskTranslationAndScale;\n\
|
|
56
56
|
uniform float u_zoomedOutOceanSpecularIntensity;\n\
|
|
@@ -363,7 +363,7 @@ void main()\n\
|
|
|
363
363
|
float fade = 0.0;\n\
|
|
364
364
|
#endif\n\
|
|
365
365
|
\n\
|
|
366
|
-
#
|
|
366
|
+
#if defined(HAS_WATER_MASK) && (defined(SHOW_REFLECTIVE_OCEAN) || defined(APPLY_MATERIAL))\n\
|
|
367
367
|
vec2 waterMaskTranslation = u_waterMaskTranslationAndScale.xy;\n\
|
|
368
368
|
vec2 waterMaskScale = u_waterMaskTranslationAndScale.zw;\n\
|
|
369
369
|
vec2 waterMaskTextureCoordinates = v_textureCoordinates.xy * waterMaskScale + waterMaskTranslation;\n\
|
|
@@ -371,6 +371,7 @@ void main()\n\
|
|
|
371
371
|
\n\
|
|
372
372
|
float mask = texture(u_waterMask, waterMaskTextureCoordinates).r;\n\
|
|
373
373
|
\n\
|
|
374
|
+
#ifdef SHOW_REFLECTIVE_OCEAN\n\
|
|
374
375
|
if (mask > 0.0)\n\
|
|
375
376
|
{\n\
|
|
376
377
|
mat3 enuToEye = czm_eastNorthUpToEyeCoordinates(v_positionMC, normalEC);\n\
|
|
@@ -382,6 +383,7 @@ void main()\n\
|
|
|
382
383
|
\n\
|
|
383
384
|
color = computeWaterColor(v_positionEC, textureCoordinates, enuToEye, color, mask, fade);\n\
|
|
384
385
|
}\n\
|
|
386
|
+
#endif\n\
|
|
385
387
|
#endif\n\
|
|
386
388
|
\n\
|
|
387
389
|
#ifdef APPLY_MATERIAL\n\
|
|
@@ -393,6 +395,10 @@ void main()\n\
|
|
|
393
395
|
materialInput.slope = v_slope;\n\
|
|
394
396
|
materialInput.height = v_height;\n\
|
|
395
397
|
materialInput.aspect = v_aspect;\n\
|
|
398
|
+
#ifdef HAS_WATER_MASK\n\
|
|
399
|
+
materialInput.waterMask = mask;\n\
|
|
400
|
+
#endif\n\
|
|
401
|
+
\n\
|
|
396
402
|
czm_material material = czm_getMaterial(materialInput);\n\
|
|
397
403
|
vec4 materialColor = vec4(material.diffuse, material.alpha);\n\
|
|
398
404
|
color = alphaBlend(materialColor, color);\n\
|
|
@@ -423,7 +429,7 @@ void main()\n\
|
|
|
423
429
|
#ifdef ENABLE_CLIPPING_POLYGONS\n\
|
|
424
430
|
vec2 clippingPosition = v_clippingPosition;\n\
|
|
425
431
|
int regionIndex = v_regionIndex;\n\
|
|
426
|
-
clipPolygons(u_clippingDistance, CLIPPING_POLYGON_REGIONS_LENGTH, clippingPosition, regionIndex)
|
|
432
|
+
clipPolygons(u_clippingDistance, CLIPPING_POLYGON_REGIONS_LENGTH, clippingPosition, regionIndex);\n\
|
|
427
433
|
#endif\n\
|
|
428
434
|
\n\
|
|
429
435
|
#ifdef HIGHLIGHT_FILL_TILE\n\
|
|
@@ -490,7 +496,7 @@ void main()\n\
|
|
|
490
496
|
#endif\n\
|
|
491
497
|
\n\
|
|
492
498
|
#ifndef HDR\n\
|
|
493
|
-
fogColor.rgb =
|
|
499
|
+
fogColor.rgb = czm_pbrNeutralTonemapping(fogColor.rgb);\n\
|
|
494
500
|
fogColor.rgb = czm_inverseGamma(fogColor.rgb);\n\
|
|
495
501
|
#endif\n\
|
|
496
502
|
\n\
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
uniform vec4 waterColor;
|
|
2
|
+
uniform vec4 landColor;
|
|
3
|
+
|
|
4
|
+
czm_material czm_getMaterial(czm_materialInput materialInput)
|
|
5
|
+
{
|
|
6
|
+
czm_material material = czm_getDefaultMaterial(materialInput);
|
|
7
|
+
|
|
8
|
+
vec4 outColor = mix(landColor, waterColor, materialInput.waterMask);
|
|
9
|
+
outColor = czm_gammaCorrect(outColor);
|
|
10
|
+
|
|
11
|
+
material.diffuse = outColor.rgb;
|
|
12
|
+
material.alpha = outColor.a;
|
|
13
|
+
|
|
14
|
+
return material;
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
+
export default "uniform vec4 waterColor;\n\
|
|
3
|
+
uniform vec4 landColor;\n\
|
|
4
|
+
\n\
|
|
5
|
+
czm_material czm_getMaterial(czm_materialInput materialInput)\n\
|
|
6
|
+
{\n\
|
|
7
|
+
czm_material material = czm_getDefaultMaterial(materialInput);\n\
|
|
8
|
+
\n\
|
|
9
|
+
vec4 outColor = mix(landColor, waterColor, materialInput.waterMask);\n\
|
|
10
|
+
outColor = czm_gammaCorrect(outColor);\n\
|
|
11
|
+
\n\
|
|
12
|
+
material.diffuse = outColor.rgb;\n\
|
|
13
|
+
material.alpha = outColor.a;\n\
|
|
14
|
+
\n\
|
|
15
|
+
return material;\n\
|
|
16
|
+
}\n\
|
|
17
|
+
";
|
|
@@ -52,7 +52,7 @@ void applyFog(inout vec4 color, vec4 groundAtmosphereColor, vec3 lightDirection,
|
|
|
52
52
|
|
|
53
53
|
// Tonemap if HDR rendering is disabled
|
|
54
54
|
#ifndef HDR
|
|
55
|
-
fogColor.rgb =
|
|
55
|
+
fogColor.rgb = czm_pbrNeutralTonemapping(fogColor.rgb);
|
|
56
56
|
fogColor.rgb = czm_inverseGamma(fogColor.rgb);
|
|
57
57
|
#endif
|
|
58
58
|
|
|
@@ -53,7 +53,7 @@ void applyFog(inout vec4 color, vec4 groundAtmosphereColor, vec3 lightDirection,
|
|
|
53
53
|
\n\
|
|
54
54
|
// Tonemap if HDR rendering is disabled\n\
|
|
55
55
|
#ifndef HDR\n\
|
|
56
|
-
fogColor.rgb =
|
|
56
|
+
fogColor.rgb = czm_pbrNeutralTonemapping(fogColor.rgb);\n\
|
|
57
57
|
fogColor.rgb = czm_inverseGamma(fogColor.rgb);\n\
|
|
58
58
|
#endif\n\
|
|
59
59
|
\n\
|
|
@@ -16,10 +16,10 @@ vec3 getProceduralSkyMetrics(vec3 positionWC, vec3 reflectionWC)
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* Compute the diffuse irradiance for a procedural sky lighting model
|
|
19
|
+
* Compute the diffuse irradiance for a procedural sky lighting model.
|
|
20
20
|
*
|
|
21
21
|
* @param {vec3} skyMetrics The dot products of the horizon and reflection directions with the nadir, and an atmosphere boundary distance.
|
|
22
|
-
* @return {vec3} The computed diffuse irradiance
|
|
22
|
+
* @return {vec3} The computed diffuse irradiance.
|
|
23
23
|
*/
|
|
24
24
|
vec3 getProceduralDiffuseIrradiance(vec3 skyMetrics)
|
|
25
25
|
{
|
|
@@ -30,10 +30,12 @@ vec3 getProceduralDiffuseIrradiance(vec3 skyMetrics)
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
* Compute the specular irradiance for a procedural sky lighting model
|
|
33
|
+
* Compute the specular irradiance for a procedural sky lighting model.
|
|
34
34
|
*
|
|
35
|
+
* @param {vec3} reflectionWC The reflection vector in world coordinates.
|
|
35
36
|
* @param {vec3} skyMetrics The dot products of the horizon and reflection directions with the nadir, and an atmosphere boundary distance.
|
|
36
|
-
* @
|
|
37
|
+
* @param {float} roughness The roughness of the material.
|
|
38
|
+
* @return {vec3} The computed specular irradiance.
|
|
37
39
|
*/
|
|
38
40
|
vec3 getProceduralSpecularIrradiance(vec3 reflectionWC, vec3 skyMetrics, float roughness)
|
|
39
41
|
{
|
|
@@ -42,7 +44,7 @@ vec3 getProceduralSpecularIrradiance(vec3 reflectionWC, vec3 skyMetrics, float r
|
|
|
42
44
|
reflectionWC = -normalize(czm_temeToPseudoFixed * reflectionWC);
|
|
43
45
|
reflectionWC.x = -reflectionWC.x;
|
|
44
46
|
|
|
45
|
-
float inverseRoughness = 1.
|
|
47
|
+
float inverseRoughness = 1.0 - roughness;
|
|
46
48
|
inverseRoughness *= inverseRoughness;
|
|
47
49
|
vec3 sceneSkyBox = czm_textureCube(czm_environmentMap, reflectionWC).rgb * inverseRoughness;
|
|
48
50
|
|
|
@@ -121,7 +123,7 @@ float getSunLuminance(vec3 positionWC, vec3 normalEC, vec3 lightDirectionEC)
|
|
|
121
123
|
) {
|
|
122
124
|
vec3 viewDirectionEC = -normalize(positionEC);
|
|
123
125
|
vec3 positionWC = vec3(czm_inverseView * vec4(positionEC, 1.0));
|
|
124
|
-
vec3 reflectionWC = normalize(czm_inverseViewRotation *
|
|
126
|
+
vec3 reflectionWC = normalize(czm_inverseViewRotation * reflect(viewDirectionEC, normalEC));
|
|
125
127
|
vec3 skyMetrics = getProceduralSkyMetrics(positionWC, reflectionWC);
|
|
126
128
|
|
|
127
129
|
float roughness = material.roughness;
|
|
@@ -150,7 +152,7 @@ float getSunLuminance(vec3 positionWC, vec3 normalEC, vec3 lightDirectionEC)
|
|
|
150
152
|
}
|
|
151
153
|
|
|
152
154
|
#ifdef DIFFUSE_IBL
|
|
153
|
-
vec3
|
|
155
|
+
vec3 sampleDiffuseEnvironment(vec3 cubeDir)
|
|
154
156
|
{
|
|
155
157
|
#ifdef CUSTOM_SPHERICAL_HARMONICS
|
|
156
158
|
return czm_sphericalHarmonics(cubeDir, model_sphericalHarmonicCoefficients);
|
|
@@ -164,20 +166,19 @@ vec3 computeDiffuseIBL(vec3 cubeDir)
|
|
|
164
166
|
vec3 sampleSpecularEnvironment(vec3 cubeDir, float roughness)
|
|
165
167
|
{
|
|
166
168
|
#ifdef CUSTOM_SPECULAR_IBL
|
|
167
|
-
float
|
|
168
|
-
|
|
169
|
-
return czm_sampleOctahedralProjection(model_specularEnvironmentMaps, model_specularEnvironmentMapsSize, cubeDir, lod, maxLod);
|
|
169
|
+
float lod = roughness * model_specularEnvironmentMapsMaximumLOD;
|
|
170
|
+
return czm_textureCube(model_specularEnvironmentMaps, cubeDir, lod).rgb;
|
|
170
171
|
#else
|
|
171
|
-
float
|
|
172
|
-
|
|
173
|
-
return czm_sampleOctahedralProjection(czm_specularEnvironmentMaps, czm_specularEnvironmentMapSize, cubeDir, lod, maxLod);
|
|
172
|
+
float lod = roughness * czm_specularEnvironmentMapsMaximumLOD;
|
|
173
|
+
return czm_textureCube(czm_specularEnvironmentMaps, cubeDir, lod).rgb;
|
|
174
174
|
#endif
|
|
175
175
|
}
|
|
176
|
-
vec3 computeSpecularIBL(vec3 cubeDir, float NdotV,
|
|
176
|
+
vec3 computeSpecularIBL(vec3 cubeDir, float NdotV, vec3 f0, float roughness)
|
|
177
177
|
{
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
vec3
|
|
178
|
+
// see https://bruop.github.io/ibl/ at Single Scattering Results
|
|
179
|
+
// Roughness dependent fresnel, from Fdez-Aguera
|
|
180
|
+
vec3 f90 = max(vec3(1.0 - roughness), f0);
|
|
181
|
+
vec3 F = fresnelSchlick2(f0, f90, NdotV);
|
|
181
182
|
|
|
182
183
|
vec2 brdfLut = texture(czm_brdfLut, vec2(NdotV, roughness)).rg;
|
|
183
184
|
vec3 specularSample = sampleSpecularEnvironment(cubeDir, roughness);
|
|
@@ -188,54 +189,64 @@ vec3 computeSpecularIBL(vec3 cubeDir, float NdotV, float VdotH, vec3 f0, float r
|
|
|
188
189
|
|
|
189
190
|
#if defined(DIFFUSE_IBL) || defined(SPECULAR_IBL)
|
|
190
191
|
/**
|
|
191
|
-
* Compute the light contributions from environment maps and spherical harmonic coefficients
|
|
192
|
+
* Compute the light contributions from environment maps and spherical harmonic coefficients.
|
|
193
|
+
* See Fdez-Aguera, https://www.jcgt.org/published/0008/01/03/paper.pdf, for explanation
|
|
194
|
+
* of the single- and multi-scattering terms.
|
|
192
195
|
*
|
|
193
|
-
* @param {vec3} viewDirectionEC Unit vector pointing from the fragment to the eye position
|
|
194
|
-
* @param {vec3} normalEC The surface normal in eye coordinates
|
|
195
|
-
* @param {vec3} lightDirectionEC Unit vector pointing to the light source in eye coordinates.
|
|
196
|
+
* @param {vec3} viewDirectionEC Unit vector pointing from the fragment to the eye position.
|
|
197
|
+
* @param {vec3} normalEC The surface normal in eye coordinates.
|
|
196
198
|
* @param {czm_modelMaterial} The material properties.
|
|
197
|
-
* @return {vec3} The computed HDR color
|
|
199
|
+
* @return {vec3} The computed HDR color.
|
|
198
200
|
*/
|
|
199
|
-
vec3 textureIBL(
|
|
200
|
-
vec3
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
201
|
+
vec3 textureIBL(vec3 viewDirectionEC, vec3 normalEC, czm_modelMaterial material) {
|
|
202
|
+
vec3 f0 = material.specular;
|
|
203
|
+
float roughness = material.roughness;
|
|
204
|
+
float specularWeight = 1.0;
|
|
205
|
+
#ifdef USE_SPECULAR
|
|
206
|
+
specularWeight = material.specularWeight;
|
|
207
|
+
#endif
|
|
208
|
+
float NdotV = clamp(dot(normalEC, viewDirectionEC), 0.0, 1.0);
|
|
209
|
+
|
|
210
|
+
// see https://bruop.github.io/ibl/ at Single Scattering Results
|
|
211
|
+
// Roughness dependent fresnel, from Fdez-Aguera
|
|
212
|
+
vec3 f90 = max(vec3(1.0 - roughness), f0);
|
|
213
|
+
vec3 singleScatterFresnel = fresnelSchlick2(f0, f90, NdotV);
|
|
214
|
+
|
|
215
|
+
vec2 brdfLut = texture(czm_brdfLut, vec2(NdotV, roughness)).rg;
|
|
216
|
+
vec3 FssEss = specularWeight * (singleScatterFresnel * brdfLut.x + brdfLut.y);
|
|
207
217
|
|
|
208
218
|
#ifdef DIFFUSE_IBL
|
|
209
|
-
vec3
|
|
219
|
+
vec3 normalMC = normalize(model_iblReferenceFrameMatrix * normalEC);
|
|
220
|
+
vec3 irradiance = sampleDiffuseEnvironment(normalMC);
|
|
221
|
+
|
|
222
|
+
vec3 averageFresnel = f0 + (1.0 - f0) / 21.0;
|
|
223
|
+
float Ems = specularWeight * (1.0 - brdfLut.x - brdfLut.y);
|
|
224
|
+
vec3 FmsEms = FssEss * averageFresnel * Ems / (1.0 - averageFresnel * Ems);
|
|
225
|
+
vec3 dielectricScattering = (1.0 - FssEss - FmsEms) * material.diffuse;
|
|
226
|
+
vec3 diffuseContribution = irradiance * (FmsEms + dielectricScattering);
|
|
210
227
|
#else
|
|
211
|
-
vec3 diffuseContribution = vec3(0.0);
|
|
228
|
+
vec3 diffuseContribution = vec3(0.0);
|
|
212
229
|
#endif
|
|
213
230
|
|
|
214
|
-
float roughness = material.roughness;
|
|
215
|
-
|
|
216
231
|
#ifdef USE_ANISOTROPY
|
|
217
|
-
//
|
|
232
|
+
// Bend normal to account for anisotropic distortion of specular reflection
|
|
218
233
|
vec3 anisotropyDirection = material.anisotropicB;
|
|
219
234
|
vec3 anisotropicTangent = cross(anisotropyDirection, viewDirectionEC);
|
|
220
235
|
vec3 anisotropicNormal = cross(anisotropicTangent, anisotropyDirection);
|
|
221
236
|
float bendFactor = 1.0 - material.anisotropyStrength * (1.0 - roughness);
|
|
222
237
|
float bendFactorPow4 = bendFactor * bendFactor * bendFactor * bendFactor;
|
|
223
238
|
vec3 bentNormal = normalize(mix(anisotropicNormal, normalEC, bendFactorPow4));
|
|
224
|
-
|
|
239
|
+
vec3 reflectEC = reflect(-viewDirectionEC, bentNormal);
|
|
240
|
+
#else
|
|
241
|
+
vec3 reflectEC = reflect(-viewDirectionEC, normalEC);
|
|
225
242
|
#endif
|
|
226
243
|
|
|
227
244
|
#ifdef SPECULAR_IBL
|
|
228
|
-
|
|
229
|
-
vec3
|
|
230
|
-
|
|
231
|
-
vec3 f0 = material.specular;
|
|
232
|
-
vec3 specularContribution = computeSpecularIBL(cubeDir, NdotV, VdotH, f0, roughness);
|
|
245
|
+
vec3 reflectMC = normalize(model_iblReferenceFrameMatrix * reflectEC);
|
|
246
|
+
vec3 radiance = sampleSpecularEnvironment(reflectMC, roughness);
|
|
247
|
+
vec3 specularContribution = radiance * FssEss;
|
|
233
248
|
#else
|
|
234
|
-
vec3 specularContribution = vec3(0.0);
|
|
235
|
-
#endif
|
|
236
|
-
|
|
237
|
-
#ifdef USE_SPECULAR
|
|
238
|
-
specularContribution *= material.specularWeight;
|
|
249
|
+
vec3 specularContribution = vec3(0.0);
|
|
239
250
|
#endif
|
|
240
251
|
|
|
241
252
|
return diffuseContribution + specularContribution;
|
|
@@ -17,10 +17,10 @@ vec3 getProceduralSkyMetrics(vec3 positionWC, vec3 reflectionWC)\n\
|
|
|
17
17
|
}\n\
|
|
18
18
|
\n\
|
|
19
19
|
/**\n\
|
|
20
|
-
* Compute the diffuse irradiance for a procedural sky lighting model
|
|
20
|
+
* Compute the diffuse irradiance for a procedural sky lighting model.\n\
|
|
21
21
|
*\n\
|
|
22
22
|
* @param {vec3} skyMetrics The dot products of the horizon and reflection directions with the nadir, and an atmosphere boundary distance.\n\
|
|
23
|
-
* @return {vec3} The computed diffuse irradiance
|
|
23
|
+
* @return {vec3} The computed diffuse irradiance.\n\
|
|
24
24
|
*/\n\
|
|
25
25
|
vec3 getProceduralDiffuseIrradiance(vec3 skyMetrics)\n\
|
|
26
26
|
{\n\
|
|
@@ -31,10 +31,12 @@ vec3 getProceduralDiffuseIrradiance(vec3 skyMetrics)\n\
|
|
|
31
31
|
}\n\
|
|
32
32
|
\n\
|
|
33
33
|
/**\n\
|
|
34
|
-
* Compute the specular irradiance for a procedural sky lighting model
|
|
34
|
+
* Compute the specular irradiance for a procedural sky lighting model.\n\
|
|
35
35
|
*\n\
|
|
36
|
+
* @param {vec3} reflectionWC The reflection vector in world coordinates.\n\
|
|
36
37
|
* @param {vec3} skyMetrics The dot products of the horizon and reflection directions with the nadir, and an atmosphere boundary distance.\n\
|
|
37
|
-
* @
|
|
38
|
+
* @param {float} roughness The roughness of the material.\n\
|
|
39
|
+
* @return {vec3} The computed specular irradiance.\n\
|
|
38
40
|
*/\n\
|
|
39
41
|
vec3 getProceduralSpecularIrradiance(vec3 reflectionWC, vec3 skyMetrics, float roughness)\n\
|
|
40
42
|
{\n\
|
|
@@ -43,7 +45,7 @@ vec3 getProceduralSpecularIrradiance(vec3 reflectionWC, vec3 skyMetrics, float r
|
|
|
43
45
|
reflectionWC = -normalize(czm_temeToPseudoFixed * reflectionWC);\n\
|
|
44
46
|
reflectionWC.x = -reflectionWC.x;\n\
|
|
45
47
|
\n\
|
|
46
|
-
float inverseRoughness = 1.
|
|
48
|
+
float inverseRoughness = 1.0 - roughness;\n\
|
|
47
49
|
inverseRoughness *= inverseRoughness;\n\
|
|
48
50
|
vec3 sceneSkyBox = czm_textureCube(czm_environmentMap, reflectionWC).rgb * inverseRoughness;\n\
|
|
49
51
|
\n\
|
|
@@ -122,7 +124,7 @@ float getSunLuminance(vec3 positionWC, vec3 normalEC, vec3 lightDirectionEC)\n\
|
|
|
122
124
|
) {\n\
|
|
123
125
|
vec3 viewDirectionEC = -normalize(positionEC);\n\
|
|
124
126
|
vec3 positionWC = vec3(czm_inverseView * vec4(positionEC, 1.0));\n\
|
|
125
|
-
vec3 reflectionWC = normalize(czm_inverseViewRotation *
|
|
127
|
+
vec3 reflectionWC = normalize(czm_inverseViewRotation * reflect(viewDirectionEC, normalEC));\n\
|
|
126
128
|
vec3 skyMetrics = getProceduralSkyMetrics(positionWC, reflectionWC);\n\
|
|
127
129
|
\n\
|
|
128
130
|
float roughness = material.roughness;\n\
|
|
@@ -151,7 +153,7 @@ float getSunLuminance(vec3 positionWC, vec3 normalEC, vec3 lightDirectionEC)\n\
|
|
|
151
153
|
}\n\
|
|
152
154
|
\n\
|
|
153
155
|
#ifdef DIFFUSE_IBL\n\
|
|
154
|
-
vec3
|
|
156
|
+
vec3 sampleDiffuseEnvironment(vec3 cubeDir)\n\
|
|
155
157
|
{\n\
|
|
156
158
|
#ifdef CUSTOM_SPHERICAL_HARMONICS\n\
|
|
157
159
|
return czm_sphericalHarmonics(cubeDir, model_sphericalHarmonicCoefficients); \n\
|
|
@@ -165,20 +167,19 @@ vec3 computeDiffuseIBL(vec3 cubeDir)\n\
|
|
|
165
167
|
vec3 sampleSpecularEnvironment(vec3 cubeDir, float roughness)\n\
|
|
166
168
|
{\n\
|
|
167
169
|
#ifdef CUSTOM_SPECULAR_IBL\n\
|
|
168
|
-
float
|
|
169
|
-
|
|
170
|
-
return czm_sampleOctahedralProjection(model_specularEnvironmentMaps, model_specularEnvironmentMapsSize, cubeDir, lod, maxLod);\n\
|
|
170
|
+
float lod = roughness * model_specularEnvironmentMapsMaximumLOD;\n\
|
|
171
|
+
return czm_textureCube(model_specularEnvironmentMaps, cubeDir, lod).rgb;\n\
|
|
171
172
|
#else\n\
|
|
172
|
-
float
|
|
173
|
-
|
|
174
|
-
return czm_sampleOctahedralProjection(czm_specularEnvironmentMaps, czm_specularEnvironmentMapSize, cubeDir, lod, maxLod);\n\
|
|
173
|
+
float lod = roughness * czm_specularEnvironmentMapsMaximumLOD;\n\
|
|
174
|
+
return czm_textureCube(czm_specularEnvironmentMaps, cubeDir, lod).rgb;\n\
|
|
175
175
|
#endif\n\
|
|
176
176
|
}\n\
|
|
177
|
-
vec3 computeSpecularIBL(vec3 cubeDir, float NdotV,
|
|
177
|
+
vec3 computeSpecularIBL(vec3 cubeDir, float NdotV, vec3 f0, float roughness)\n\
|
|
178
178
|
{\n\
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
vec3
|
|
179
|
+
// see https://bruop.github.io/ibl/ at Single Scattering Results\n\
|
|
180
|
+
// Roughness dependent fresnel, from Fdez-Aguera\n\
|
|
181
|
+
vec3 f90 = max(vec3(1.0 - roughness), f0);\n\
|
|
182
|
+
vec3 F = fresnelSchlick2(f0, f90, NdotV);\n\
|
|
182
183
|
\n\
|
|
183
184
|
vec2 brdfLut = texture(czm_brdfLut, vec2(NdotV, roughness)).rg;\n\
|
|
184
185
|
vec3 specularSample = sampleSpecularEnvironment(cubeDir, roughness);\n\
|
|
@@ -189,54 +190,64 @@ vec3 computeSpecularIBL(vec3 cubeDir, float NdotV, float VdotH, vec3 f0, float r
|
|
|
189
190
|
\n\
|
|
190
191
|
#if defined(DIFFUSE_IBL) || defined(SPECULAR_IBL)\n\
|
|
191
192
|
/**\n\
|
|
192
|
-
* Compute the light contributions from environment maps and spherical harmonic coefficients
|
|
193
|
+
* Compute the light contributions from environment maps and spherical harmonic coefficients.\n\
|
|
194
|
+
* See Fdez-Aguera, https://www.jcgt.org/published/0008/01/03/paper.pdf, for explanation\n\
|
|
195
|
+
* of the single- and multi-scattering terms.\n\
|
|
193
196
|
*\n\
|
|
194
|
-
* @param {vec3} viewDirectionEC Unit vector pointing from the fragment to the eye position
|
|
195
|
-
* @param {vec3} normalEC The surface normal in eye coordinates
|
|
196
|
-
* @param {vec3} lightDirectionEC Unit vector pointing to the light source in eye coordinates.\n\
|
|
197
|
+
* @param {vec3} viewDirectionEC Unit vector pointing from the fragment to the eye position.\n\
|
|
198
|
+
* @param {vec3} normalEC The surface normal in eye coordinates.\n\
|
|
197
199
|
* @param {czm_modelMaterial} The material properties.\n\
|
|
198
|
-
* @return {vec3} The computed HDR color
|
|
200
|
+
* @return {vec3} The computed HDR color.\n\
|
|
199
201
|
*/\n\
|
|
200
|
-
vec3 textureIBL(\n\
|
|
201
|
-
vec3
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
202
|
+
vec3 textureIBL(vec3 viewDirectionEC, vec3 normalEC, czm_modelMaterial material) {\n\
|
|
203
|
+
vec3 f0 = material.specular;\n\
|
|
204
|
+
float roughness = material.roughness;\n\
|
|
205
|
+
float specularWeight = 1.0;\n\
|
|
206
|
+
#ifdef USE_SPECULAR\n\
|
|
207
|
+
specularWeight = material.specularWeight;\n\
|
|
208
|
+
#endif\n\
|
|
209
|
+
float NdotV = clamp(dot(normalEC, viewDirectionEC), 0.0, 1.0);\n\
|
|
210
|
+
\n\
|
|
211
|
+
// see https://bruop.github.io/ibl/ at Single Scattering Results\n\
|
|
212
|
+
// Roughness dependent fresnel, from Fdez-Aguera\n\
|
|
213
|
+
vec3 f90 = max(vec3(1.0 - roughness), f0);\n\
|
|
214
|
+
vec3 singleScatterFresnel = fresnelSchlick2(f0, f90, NdotV);\n\
|
|
215
|
+
\n\
|
|
216
|
+
vec2 brdfLut = texture(czm_brdfLut, vec2(NdotV, roughness)).rg;\n\
|
|
217
|
+
vec3 FssEss = specularWeight * (singleScatterFresnel * brdfLut.x + brdfLut.y);\n\
|
|
208
218
|
\n\
|
|
209
219
|
#ifdef DIFFUSE_IBL\n\
|
|
210
|
-
vec3
|
|
220
|
+
vec3 normalMC = normalize(model_iblReferenceFrameMatrix * normalEC);\n\
|
|
221
|
+
vec3 irradiance = sampleDiffuseEnvironment(normalMC);\n\
|
|
222
|
+
\n\
|
|
223
|
+
vec3 averageFresnel = f0 + (1.0 - f0) / 21.0;\n\
|
|
224
|
+
float Ems = specularWeight * (1.0 - brdfLut.x - brdfLut.y);\n\
|
|
225
|
+
vec3 FmsEms = FssEss * averageFresnel * Ems / (1.0 - averageFresnel * Ems);\n\
|
|
226
|
+
vec3 dielectricScattering = (1.0 - FssEss - FmsEms) * material.diffuse;\n\
|
|
227
|
+
vec3 diffuseContribution = irradiance * (FmsEms + dielectricScattering);\n\
|
|
211
228
|
#else\n\
|
|
212
|
-
vec3 diffuseContribution = vec3(0.0)
|
|
229
|
+
vec3 diffuseContribution = vec3(0.0);\n\
|
|
213
230
|
#endif\n\
|
|
214
|
-
\n\
|
|
215
|
-
float roughness = material.roughness;\n\
|
|
216
231
|
\n\
|
|
217
232
|
#ifdef USE_ANISOTROPY\n\
|
|
218
|
-
//
|
|
233
|
+
// Bend normal to account for anisotropic distortion of specular reflection\n\
|
|
219
234
|
vec3 anisotropyDirection = material.anisotropicB;\n\
|
|
220
235
|
vec3 anisotropicTangent = cross(anisotropyDirection, viewDirectionEC);\n\
|
|
221
236
|
vec3 anisotropicNormal = cross(anisotropicTangent, anisotropyDirection);\n\
|
|
222
237
|
float bendFactor = 1.0 - material.anisotropyStrength * (1.0 - roughness);\n\
|
|
223
238
|
float bendFactorPow4 = bendFactor * bendFactor * bendFactor * bendFactor;\n\
|
|
224
239
|
vec3 bentNormal = normalize(mix(anisotropicNormal, normalEC, bendFactorPow4));\n\
|
|
225
|
-
|
|
240
|
+
vec3 reflectEC = reflect(-viewDirectionEC, bentNormal);\n\
|
|
241
|
+
#else\n\
|
|
242
|
+
vec3 reflectEC = reflect(-viewDirectionEC, normalEC);\n\
|
|
226
243
|
#endif\n\
|
|
227
244
|
\n\
|
|
228
245
|
#ifdef SPECULAR_IBL\n\
|
|
229
|
-
|
|
230
|
-
vec3
|
|
231
|
-
|
|
232
|
-
vec3 f0 = material.specular;\n\
|
|
233
|
-
vec3 specularContribution = computeSpecularIBL(cubeDir, NdotV, VdotH, f0, roughness);\n\
|
|
246
|
+
vec3 reflectMC = normalize(model_iblReferenceFrameMatrix * reflectEC);\n\
|
|
247
|
+
vec3 radiance = sampleSpecularEnvironment(reflectMC, roughness);\n\
|
|
248
|
+
vec3 specularContribution = radiance * FssEss;\n\
|
|
234
249
|
#else\n\
|
|
235
|
-
vec3 specularContribution = vec3(0.0)
|
|
236
|
-
#endif\n\
|
|
237
|
-
\n\
|
|
238
|
-
#ifdef USE_SPECULAR\n\
|
|
239
|
-
specularContribution *= material.specularWeight;\n\
|
|
250
|
+
vec3 specularContribution = vec3(0.0);\n\
|
|
240
251
|
#endif\n\
|
|
241
252
|
\n\
|
|
242
253
|
return diffuseContribution + specularContribution;\n\
|