@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
|
@@ -7,6 +7,7 @@ uniform vec4 u_highlightColor;
|
|
|
7
7
|
in vec2 v_textureCoordinates;
|
|
8
8
|
in vec4 v_pickColor;
|
|
9
9
|
in vec4 v_color;
|
|
10
|
+
in float v_splitDirection;
|
|
10
11
|
|
|
11
12
|
#ifdef SDF
|
|
12
13
|
in vec4 v_outlineColor;
|
|
@@ -86,6 +87,9 @@ vec4 getSDFColor(vec2 position, float outlineWidth, vec4 outlineColor, float smo
|
|
|
86
87
|
|
|
87
88
|
void main()
|
|
88
89
|
{
|
|
90
|
+
if (v_splitDirection < 0.0 && gl_FragCoord.x > czm_splitPosition) discard;
|
|
91
|
+
if (v_splitDirection > 0.0 && gl_FragCoord.x < czm_splitPosition) discard;
|
|
92
|
+
|
|
89
93
|
vec4 color = texture(u_atlas, v_textureCoordinates);
|
|
90
94
|
|
|
91
95
|
#ifdef SDF
|
|
@@ -8,6 +8,7 @@ uniform vec4 u_highlightColor;\n\
|
|
|
8
8
|
in vec2 v_textureCoordinates;\n\
|
|
9
9
|
in vec4 v_pickColor;\n\
|
|
10
10
|
in vec4 v_color;\n\
|
|
11
|
+
in float v_splitDirection;\n\
|
|
11
12
|
\n\
|
|
12
13
|
#ifdef SDF\n\
|
|
13
14
|
in vec4 v_outlineColor;\n\
|
|
@@ -87,6 +88,9 @@ vec4 getSDFColor(vec2 position, float outlineWidth, vec4 outlineColor, float smo
|
|
|
87
88
|
\n\
|
|
88
89
|
void main()\n\
|
|
89
90
|
{\n\
|
|
91
|
+
if (v_splitDirection < 0.0 && gl_FragCoord.x > czm_splitPosition) discard;\n\
|
|
92
|
+
if (v_splitDirection > 0.0 && gl_FragCoord.x < czm_splitPosition) discard;\n\
|
|
93
|
+
\n\
|
|
90
94
|
vec4 color = texture(u_atlas, v_textureCoordinates);\n\
|
|
91
95
|
\n\
|
|
92
96
|
#ifdef SDF\n\
|
|
@@ -11,6 +11,7 @@ in vec4 scaleByDistance; // near, nearScale, far, far
|
|
|
11
11
|
in vec4 pixelOffsetScaleByDistance; // near, nearScale, far, farScale
|
|
12
12
|
in vec4 compressedAttribute3; // distance display condition near, far, disableDepthTestDistance, dimensions
|
|
13
13
|
in vec2 sdf; // sdf outline color (rgb) and width (w)
|
|
14
|
+
in float splitDirection; // splitDirection
|
|
14
15
|
#if defined(VERTEX_DEPTH_CHECK) || defined(FRAGMENT_DEPTH_CHECK)
|
|
15
16
|
in vec4 textureCoordinateBoundsOrLabelTranslate; // the min and max x and y values for the texture coordinates
|
|
16
17
|
#endif
|
|
@@ -28,6 +29,7 @@ out mat2 v_rotationMatrix;
|
|
|
28
29
|
|
|
29
30
|
out vec4 v_pickColor;
|
|
30
31
|
out vec4 v_color;
|
|
32
|
+
out float v_splitDirection;
|
|
31
33
|
#ifdef SDF
|
|
32
34
|
out vec4 v_outlineColor;
|
|
33
35
|
out float v_outlineWidth;
|
|
@@ -430,5 +432,5 @@ if (lengthSq < disableDepthTestDistance) {
|
|
|
430
432
|
|
|
431
433
|
v_color = color;
|
|
432
434
|
v_color.a *= translucency;
|
|
433
|
-
|
|
435
|
+
v_splitDirection = splitDirection;
|
|
434
436
|
}
|
|
@@ -12,6 +12,7 @@ in vec4 scaleByDistance; // near, nearScale, far, far
|
|
|
12
12
|
in vec4 pixelOffsetScaleByDistance; // near, nearScale, far, farScale\n\
|
|
13
13
|
in vec4 compressedAttribute3; // distance display condition near, far, disableDepthTestDistance, dimensions\n\
|
|
14
14
|
in vec2 sdf; // sdf outline color (rgb) and width (w)\n\
|
|
15
|
+
in float splitDirection; // splitDirection\n\
|
|
15
16
|
#if defined(VERTEX_DEPTH_CHECK) || defined(FRAGMENT_DEPTH_CHECK)\n\
|
|
16
17
|
in vec4 textureCoordinateBoundsOrLabelTranslate; // the min and max x and y values for the texture coordinates\n\
|
|
17
18
|
#endif\n\
|
|
@@ -29,6 +30,7 @@ out mat2 v_rotationMatrix;\n\
|
|
|
29
30
|
\n\
|
|
30
31
|
out vec4 v_pickColor;\n\
|
|
31
32
|
out vec4 v_color;\n\
|
|
33
|
+
out float v_splitDirection;\n\
|
|
32
34
|
#ifdef SDF\n\
|
|
33
35
|
out vec4 v_outlineColor;\n\
|
|
34
36
|
out float v_outlineWidth;\n\
|
|
@@ -431,6 +433,6 @@ if (lengthSq < disableDepthTestDistance) {\n\
|
|
|
431
433
|
\n\
|
|
432
434
|
v_color = color;\n\
|
|
433
435
|
v_color.a *= translucency;\n\
|
|
434
|
-
|
|
436
|
+
v_splitDirection = splitDirection;\n\
|
|
435
437
|
}\n\
|
|
436
438
|
";
|
|
@@ -27,11 +27,11 @@ vec2 hammersley2D(int i, int N)
|
|
|
27
27
|
return vec2(float(i) / float(N), vdcRadicalInverse(i));
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
vec3 importanceSampleGGX(vec2 xi, float
|
|
30
|
+
vec3 importanceSampleGGX(vec2 xi, float alphaRoughness, vec3 N)
|
|
31
31
|
{
|
|
32
|
-
float
|
|
32
|
+
float alphaRoughnessSquared = alphaRoughness * alphaRoughness;
|
|
33
33
|
float phi = 2.0 * M_PI * xi.x;
|
|
34
|
-
float cosTheta = sqrt((1.0 - xi.y) / (1.0 + (
|
|
34
|
+
float cosTheta = sqrt((1.0 - xi.y) / (1.0 + (alphaRoughnessSquared - 1.0) * xi.y));
|
|
35
35
|
float sinTheta = sqrt(1.0 - cosTheta * cosTheta);
|
|
36
36
|
vec3 H = vec3(sinTheta * cos(phi), sinTheta * sin(phi), cosTheta);
|
|
37
37
|
vec3 upVector = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
|
|
@@ -40,15 +40,31 @@ vec3 importanceSampleGGX(vec2 xi, float roughness, vec3 N)
|
|
|
40
40
|
return tangentX * H.x + tangentY * H.y + N * H.z;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Estimate the geometric self-shadowing of the microfacets in a surface,
|
|
45
|
+
* using the Smith Joint GGX visibility function.
|
|
46
|
+
* Note: Vis = G / (4 * NdotL * NdotV)
|
|
47
|
+
* see Eric Heitz. 2014. Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs. Journal of Computer Graphics Techniques, 3
|
|
48
|
+
* see Real-Time Rendering. Page 331 to 336.
|
|
49
|
+
* see https://google.github.io/filament/Filament.md.html#materialsystem/specularbrdf/geometricshadowing(specularg)
|
|
50
|
+
*
|
|
51
|
+
* @param {float} alphaRoughness The roughness of the material, expressed as the square of perceptual roughness.
|
|
52
|
+
* @param {float} NdotL The cosine of the angle between the surface normal and the direction to the light source.
|
|
53
|
+
* @param {float} NdotV The cosine of the angle between the surface normal and the direction to the camera.
|
|
54
|
+
*/
|
|
55
|
+
float smithVisibilityGGX(float alphaRoughness, float NdotL, float NdotV)
|
|
44
56
|
{
|
|
45
|
-
|
|
46
|
-
}
|
|
57
|
+
float alphaRoughnessSq = alphaRoughness * alphaRoughness;
|
|
47
58
|
|
|
48
|
-
float
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
float GGXV = NdotL * sqrt(NdotV * NdotV * (1.0 - alphaRoughnessSq) + alphaRoughnessSq);
|
|
60
|
+
float GGXL = NdotV * sqrt(NdotL * NdotL * (1.0 - alphaRoughnessSq) + alphaRoughnessSq);
|
|
61
|
+
|
|
62
|
+
float GGX = GGXV + GGXL; // 2.0 if NdotL = NdotV = 1.0
|
|
63
|
+
if (GGX > 0.0)
|
|
64
|
+
{
|
|
65
|
+
return 0.5 / GGX; // 1/4 if NdotL = NdotV = 1.0
|
|
66
|
+
}
|
|
67
|
+
return 0.0;
|
|
52
68
|
}
|
|
53
69
|
|
|
54
70
|
vec2 integrateBrdf(float roughness, float NdotV)
|
|
@@ -57,18 +73,19 @@ vec2 integrateBrdf(float roughness, float NdotV)
|
|
|
57
73
|
float A = 0.0;
|
|
58
74
|
float B = 0.0;
|
|
59
75
|
const int NumSamples = 1024;
|
|
76
|
+
float alphaRoughness = roughness * roughness;
|
|
60
77
|
for (int i = 0; i < NumSamples; i++)
|
|
61
78
|
{
|
|
62
79
|
vec2 xi = hammersley2D(i, NumSamples);
|
|
63
|
-
vec3 H = importanceSampleGGX(xi,
|
|
80
|
+
vec3 H = importanceSampleGGX(xi, alphaRoughness, vec3(0.0, 0.0, 1.0));
|
|
64
81
|
vec3 L = 2.0 * dot(V, H) * H - V;
|
|
65
82
|
float NdotL = clamp(L.z, 0.0, 1.0);
|
|
66
83
|
float NdotH = clamp(H.z, 0.0, 1.0);
|
|
67
84
|
float VdotH = clamp(dot(V, H), 0.0, 1.0);
|
|
68
85
|
if (NdotL > 0.0)
|
|
69
86
|
{
|
|
70
|
-
float G =
|
|
71
|
-
float G_Vis = G * VdotH /
|
|
87
|
+
float G = smithVisibilityGGX(alphaRoughness, NdotL, NdotV);
|
|
88
|
+
float G_Vis = 4.0 * G * VdotH * NdotL / NdotH;
|
|
72
89
|
float Fc = pow(1.0 - VdotH, 5.0);
|
|
73
90
|
A += (1.0 - Fc) * G_Vis;
|
|
74
91
|
B += Fc * G_Vis;
|
|
@@ -28,11 +28,11 @@ vec2 hammersley2D(int i, int N)\n\
|
|
|
28
28
|
return vec2(float(i) / float(N), vdcRadicalInverse(i));\n\
|
|
29
29
|
}\n\
|
|
30
30
|
\n\
|
|
31
|
-
vec3 importanceSampleGGX(vec2 xi, float
|
|
31
|
+
vec3 importanceSampleGGX(vec2 xi, float alphaRoughness, vec3 N)\n\
|
|
32
32
|
{\n\
|
|
33
|
-
float
|
|
33
|
+
float alphaRoughnessSquared = alphaRoughness * alphaRoughness;\n\
|
|
34
34
|
float phi = 2.0 * M_PI * xi.x;\n\
|
|
35
|
-
float cosTheta = sqrt((1.0 - xi.y) / (1.0 + (
|
|
35
|
+
float cosTheta = sqrt((1.0 - xi.y) / (1.0 + (alphaRoughnessSquared - 1.0) * xi.y));\n\
|
|
36
36
|
float sinTheta = sqrt(1.0 - cosTheta * cosTheta);\n\
|
|
37
37
|
vec3 H = vec3(sinTheta * cos(phi), sinTheta * sin(phi), cosTheta);\n\
|
|
38
38
|
vec3 upVector = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n\
|
|
@@ -41,15 +41,31 @@ vec3 importanceSampleGGX(vec2 xi, float roughness, vec3 N)\n\
|
|
|
41
41
|
return tangentX * H.x + tangentY * H.y + N * H.z;\n\
|
|
42
42
|
}\n\
|
|
43
43
|
\n\
|
|
44
|
-
|
|
44
|
+
/**\n\
|
|
45
|
+
* Estimate the geometric self-shadowing of the microfacets in a surface,\n\
|
|
46
|
+
* using the Smith Joint GGX visibility function.\n\
|
|
47
|
+
* Note: Vis = G / (4 * NdotL * NdotV)\n\
|
|
48
|
+
* see Eric Heitz. 2014. Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs. Journal of Computer Graphics Techniques, 3\n\
|
|
49
|
+
* see Real-Time Rendering. Page 331 to 336.\n\
|
|
50
|
+
* see https://google.github.io/filament/Filament.md.html#materialsystem/specularbrdf/geometricshadowing(specularg)\n\
|
|
51
|
+
*\n\
|
|
52
|
+
* @param {float} alphaRoughness The roughness of the material, expressed as the square of perceptual roughness.\n\
|
|
53
|
+
* @param {float} NdotL The cosine of the angle between the surface normal and the direction to the light source.\n\
|
|
54
|
+
* @param {float} NdotV The cosine of the angle between the surface normal and the direction to the camera.\n\
|
|
55
|
+
*/\n\
|
|
56
|
+
float smithVisibilityGGX(float alphaRoughness, float NdotL, float NdotV)\n\
|
|
45
57
|
{\n\
|
|
46
|
-
|
|
47
|
-
}\n\
|
|
58
|
+
float alphaRoughnessSq = alphaRoughness * alphaRoughness;\n\
|
|
48
59
|
\n\
|
|
49
|
-
float
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
60
|
+
float GGXV = NdotL * sqrt(NdotV * NdotV * (1.0 - alphaRoughnessSq) + alphaRoughnessSq);\n\
|
|
61
|
+
float GGXL = NdotV * sqrt(NdotL * NdotL * (1.0 - alphaRoughnessSq) + alphaRoughnessSq);\n\
|
|
62
|
+
\n\
|
|
63
|
+
float GGX = GGXV + GGXL; // 2.0 if NdotL = NdotV = 1.0\n\
|
|
64
|
+
if (GGX > 0.0)\n\
|
|
65
|
+
{\n\
|
|
66
|
+
return 0.5 / GGX; // 1/4 if NdotL = NdotV = 1.0\n\
|
|
67
|
+
}\n\
|
|
68
|
+
return 0.0;\n\
|
|
53
69
|
}\n\
|
|
54
70
|
\n\
|
|
55
71
|
vec2 integrateBrdf(float roughness, float NdotV)\n\
|
|
@@ -58,18 +74,19 @@ vec2 integrateBrdf(float roughness, float NdotV)\n\
|
|
|
58
74
|
float A = 0.0;\n\
|
|
59
75
|
float B = 0.0;\n\
|
|
60
76
|
const int NumSamples = 1024;\n\
|
|
77
|
+
float alphaRoughness = roughness * roughness;\n\
|
|
61
78
|
for (int i = 0; i < NumSamples; i++)\n\
|
|
62
79
|
{\n\
|
|
63
80
|
vec2 xi = hammersley2D(i, NumSamples);\n\
|
|
64
|
-
vec3 H = importanceSampleGGX(xi,
|
|
81
|
+
vec3 H = importanceSampleGGX(xi, alphaRoughness, vec3(0.0, 0.0, 1.0));\n\
|
|
65
82
|
vec3 L = 2.0 * dot(V, H) * H - V;\n\
|
|
66
83
|
float NdotL = clamp(L.z, 0.0, 1.0);\n\
|
|
67
84
|
float NdotH = clamp(H.z, 0.0, 1.0);\n\
|
|
68
85
|
float VdotH = clamp(dot(V, H), 0.0, 1.0);\n\
|
|
69
86
|
if (NdotL > 0.0)\n\
|
|
70
87
|
{\n\
|
|
71
|
-
float G =
|
|
72
|
-
float G_Vis = G * VdotH /
|
|
88
|
+
float G = smithVisibilityGGX(alphaRoughness, NdotL, NdotV);\n\
|
|
89
|
+
float G_Vis = 4.0 * G * VdotH * NdotL / NdotH;\n\
|
|
73
90
|
float Fc = pow(1.0 - VdotH, 5.0);\n\
|
|
74
91
|
A += (1.0 - Fc) * G_Vis;\n\
|
|
75
92
|
B += Fc * G_Vis;\n\
|
|
@@ -103,6 +103,7 @@ import czm_nearFarScalar from './Functions/nearFarScalar.js'
|
|
|
103
103
|
import czm_octDecode from './Functions/octDecode.js'
|
|
104
104
|
import czm_packDepth from './Functions/packDepth.js'
|
|
105
105
|
import czm_pbrLighting from './Functions/pbrLighting.js'
|
|
106
|
+
import czm_pbrNeutralTonemapping from './Functions/pbrNeutralTonemapping.js'
|
|
106
107
|
import czm_phong from './Functions/phong.js'
|
|
107
108
|
import czm_planeDistance from './Functions/planeDistance.js'
|
|
108
109
|
import czm_pointAlongRay from './Functions/pointAlongRay.js'
|
|
@@ -112,7 +113,6 @@ import czm_readDepth from './Functions/readDepth.js'
|
|
|
112
113
|
import czm_readNonPerspective from './Functions/readNonPerspective.js'
|
|
113
114
|
import czm_reverseLogDepth from './Functions/reverseLogDepth.js'
|
|
114
115
|
import czm_round from './Functions/round.js'
|
|
115
|
-
import czm_sampleOctahedralProjection from './Functions/sampleOctahedralProjection.js'
|
|
116
116
|
import czm_saturation from './Functions/saturation.js'
|
|
117
117
|
import czm_shadowDepthCompare from './Functions/shadowDepthCompare.js'
|
|
118
118
|
import czm_shadowVisibility from './Functions/shadowVisibility.js'
|
|
@@ -241,6 +241,7 @@ export default {
|
|
|
241
241
|
czm_octDecode : czm_octDecode,
|
|
242
242
|
czm_packDepth : czm_packDepth,
|
|
243
243
|
czm_pbrLighting : czm_pbrLighting,
|
|
244
|
+
czm_pbrNeutralTonemapping : czm_pbrNeutralTonemapping,
|
|
244
245
|
czm_phong : czm_phong,
|
|
245
246
|
czm_planeDistance : czm_planeDistance,
|
|
246
247
|
czm_pointAlongRay : czm_pointAlongRay,
|
|
@@ -250,7 +251,6 @@ export default {
|
|
|
250
251
|
czm_readNonPerspective : czm_readNonPerspective,
|
|
251
252
|
czm_reverseLogDepth : czm_reverseLogDepth,
|
|
252
253
|
czm_round : czm_round,
|
|
253
|
-
czm_sampleOctahedralProjection : czm_sampleOctahedralProjection,
|
|
254
254
|
czm_saturation : czm_saturation,
|
|
255
255
|
czm_shadowDepthCompare : czm_shadowDepthCompare,
|
|
256
256
|
czm_shadowVisibility : czm_shadowVisibility,
|
|
@@ -13,14 +13,14 @@ vec3 fresnelSchlick2(vec3 f0, vec3 f90, float VdotH)
|
|
|
13
13
|
|
|
14
14
|
#ifdef USE_ANISOTROPY
|
|
15
15
|
/**
|
|
16
|
-
* @param {float}
|
|
16
|
+
* @param {float} bitangentRoughness Material roughness (along the anisotropy bitangent)
|
|
17
17
|
* @param {float} tangentialRoughness Anisotropic roughness (along the anisotropy tangent)
|
|
18
18
|
* @param {vec3} lightDirection The direction from the fragment to the light source, transformed to tangent-bitangent-normal coordinates
|
|
19
19
|
* @param {vec3} viewDirection The direction from the fragment to the camera, transformed to tangent-bitangent-normal coordinates
|
|
20
20
|
*/
|
|
21
|
-
float smithVisibilityGGX_anisotropic(float
|
|
21
|
+
float smithVisibilityGGX_anisotropic(float bitangentRoughness, float tangentialRoughness, vec3 lightDirection, vec3 viewDirection)
|
|
22
22
|
{
|
|
23
|
-
vec3 roughnessScale = vec3(tangentialRoughness,
|
|
23
|
+
vec3 roughnessScale = vec3(tangentialRoughness, bitangentRoughness, 1.0);
|
|
24
24
|
float GGXV = lightDirection.z * length(roughnessScale * viewDirection);
|
|
25
25
|
float GGXL = viewDirection.z * length(roughnessScale * lightDirection);
|
|
26
26
|
float v = 0.5 / (GGXV + GGXL);
|
|
@@ -28,44 +28,44 @@ float smithVisibilityGGX_anisotropic(float roughness, float tangentialRoughness,
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* @param {float}
|
|
31
|
+
* @param {float} bitangentRoughness Material roughness (along the anisotropy bitangent)
|
|
32
32
|
* @param {float} tangentialRoughness Anisotropic roughness (along the anisotropy tangent)
|
|
33
33
|
* @param {vec3} halfwayDirection The unit vector halfway between light and view directions, transformed to tangent-bitangent-normal coordinates
|
|
34
34
|
*/
|
|
35
|
-
float GGX_anisotropic(float
|
|
35
|
+
float GGX_anisotropic(float bitangentRoughness, float tangentialRoughness, vec3 halfwayDirection)
|
|
36
36
|
{
|
|
37
|
-
float roughnessSquared =
|
|
38
|
-
vec3 f = halfwayDirection * vec3(
|
|
37
|
+
float roughnessSquared = bitangentRoughness * tangentialRoughness;
|
|
38
|
+
vec3 f = halfwayDirection * vec3(bitangentRoughness, tangentialRoughness, roughnessSquared);
|
|
39
39
|
float w2 = roughnessSquared / dot(f, f);
|
|
40
40
|
return roughnessSquared * w2 * w2 / czm_pi;
|
|
41
41
|
}
|
|
42
42
|
#endif
|
|
43
43
|
|
|
44
|
-
float smithVisibilityG1(float NdotV, float roughness)
|
|
45
|
-
{
|
|
46
|
-
// this is the k value for direct lighting.
|
|
47
|
-
// for image based lighting it will be roughness^2 / 2
|
|
48
|
-
float k = (roughness + 1.0) * (roughness + 1.0) / 8.0;
|
|
49
|
-
return NdotV / (NdotV * (1.0 - k) + k);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
44
|
/**
|
|
53
45
|
* Estimate the geometric self-shadowing of the microfacets in a surface,
|
|
54
|
-
* using the
|
|
46
|
+
* using the Smith Joint GGX visibility function.
|
|
47
|
+
* Note: Vis = G / (4 * NdotL * NdotV)
|
|
48
|
+
* see Eric Heitz. 2014. Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs. Journal of Computer Graphics Techniques, 3
|
|
49
|
+
* see Real-Time Rendering. Page 331 to 336.
|
|
50
|
+
* see https://google.github.io/filament/Filament.md.html#materialsystem/specularbrdf/geometricshadowing(specularg)
|
|
55
51
|
*
|
|
56
|
-
* @param {float}
|
|
52
|
+
* @param {float} alphaRoughness The roughness of the material, expressed as the square of perceptual roughness.
|
|
57
53
|
* @param {float} NdotL The cosine of the angle between the surface normal and the direction to the light source.
|
|
58
54
|
* @param {float} NdotV The cosine of the angle between the surface normal and the direction to the camera.
|
|
59
55
|
*/
|
|
60
|
-
float smithVisibilityGGX(float
|
|
56
|
+
float smithVisibilityGGX(float alphaRoughness, float NdotL, float NdotV)
|
|
61
57
|
{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
NdotV
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
58
|
+
float alphaRoughnessSq = alphaRoughness * alphaRoughness;
|
|
59
|
+
|
|
60
|
+
float GGXV = NdotL * sqrt(NdotV * NdotV * (1.0 - alphaRoughnessSq) + alphaRoughnessSq);
|
|
61
|
+
float GGXL = NdotV * sqrt(NdotL * NdotL * (1.0 - alphaRoughnessSq) + alphaRoughnessSq);
|
|
62
|
+
|
|
63
|
+
float GGX = GGXV + GGXL;
|
|
64
|
+
if (GGX > 0.0)
|
|
65
|
+
{
|
|
66
|
+
return 0.5 / GGX;
|
|
67
|
+
}
|
|
68
|
+
return 0.0;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/**
|
|
@@ -73,15 +73,15 @@ float smithVisibilityGGX(float roughness, float NdotL, float NdotV)
|
|
|
73
73
|
* the halfway vector, which is aligned halfway between the directions from
|
|
74
74
|
* the fragment to the camera and from the fragment to the light source.
|
|
75
75
|
*
|
|
76
|
-
* @param {float}
|
|
76
|
+
* @param {float} alphaRoughness The roughness of the material, expressed as the square of perceptual roughness.
|
|
77
77
|
* @param {float} NdotH The cosine of the angle between the surface normal and the halfway vector.
|
|
78
78
|
* @return {float} The fraction of microfacets aligned to the halfway vector.
|
|
79
79
|
*/
|
|
80
|
-
float GGX(float
|
|
80
|
+
float GGX(float alphaRoughness, float NdotH)
|
|
81
81
|
{
|
|
82
|
-
float
|
|
83
|
-
float f = (NdotH *
|
|
84
|
-
return
|
|
82
|
+
float alphaRoughnessSquared = alphaRoughness * alphaRoughness;
|
|
83
|
+
float f = (NdotH * alphaRoughnessSquared - NdotH) * NdotH + 1.0;
|
|
84
|
+
return alphaRoughnessSquared / (czm_pi * f * f);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
/**
|
|
@@ -91,16 +91,16 @@ float GGX(float roughness, float NdotH)
|
|
|
91
91
|
* @param {vec3} lightDirection The unit vector pointing from the fragment to the light source.
|
|
92
92
|
* @param {vec3} viewDirection The unit vector pointing from the fragment to the camera.
|
|
93
93
|
* @param {vec3} halfwayDirection The unit vector pointing from the fragment to halfway between the light source and the camera.
|
|
94
|
-
* @param {float}
|
|
94
|
+
* @param {float} alphaRoughness The roughness of the material, expressed as the square of perceptual roughness.
|
|
95
95
|
* @return {float} The strength of the specular reflection.
|
|
96
96
|
*/
|
|
97
|
-
float computeDirectSpecularStrength(vec3 normal, vec3 lightDirection, vec3 viewDirection, vec3 halfwayDirection, float
|
|
97
|
+
float computeDirectSpecularStrength(vec3 normal, vec3 lightDirection, vec3 viewDirection, vec3 halfwayDirection, float alphaRoughness)
|
|
98
98
|
{
|
|
99
|
-
float NdotL = dot(normal, lightDirection);
|
|
100
|
-
float NdotV =
|
|
101
|
-
float G = smithVisibilityGGX(
|
|
99
|
+
float NdotL = clamp(dot(normal, lightDirection), 0.0, 1.0);
|
|
100
|
+
float NdotV = clamp(dot(normal, viewDirection), 0.0, 1.0);
|
|
101
|
+
float G = smithVisibilityGGX(alphaRoughness, NdotL, NdotV);
|
|
102
102
|
float NdotH = clamp(dot(normal, halfwayDirection), 0.0, 1.0);
|
|
103
|
-
float D = GGX(
|
|
103
|
+
float D = GGX(alphaRoughness, NdotH);
|
|
104
104
|
return G * D;
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -138,19 +138,20 @@ vec3 czm_pbrLighting(vec3 viewDirectionEC, vec3 normalEC, vec3 lightDirectionEC,
|
|
|
138
138
|
F *= material.specularWeight;
|
|
139
139
|
#endif
|
|
140
140
|
|
|
141
|
-
float
|
|
141
|
+
float alphaRoughness = material.roughness * material.roughness;
|
|
142
142
|
#ifdef USE_ANISOTROPY
|
|
143
143
|
mat3 tbn = mat3(material.anisotropicT, material.anisotropicB, normalEC);
|
|
144
144
|
vec3 lightDirection = lightDirectionEC * tbn;
|
|
145
145
|
vec3 viewDirection = viewDirectionEC * tbn;
|
|
146
146
|
vec3 halfwayDirection = halfwayDirectionEC * tbn;
|
|
147
147
|
float anisotropyStrength = material.anisotropyStrength;
|
|
148
|
-
float tangentialRoughness = mix(
|
|
149
|
-
float
|
|
150
|
-
float
|
|
148
|
+
float tangentialRoughness = mix(alphaRoughness, 1.0, anisotropyStrength * anisotropyStrength);
|
|
149
|
+
float bitangentRoughness = clamp(alphaRoughness, 0.001, 1.0);
|
|
150
|
+
float G = smithVisibilityGGX_anisotropic(bitangentRoughness, tangentialRoughness, lightDirection, viewDirection);
|
|
151
|
+
float D = GGX_anisotropic(bitangentRoughness, tangentialRoughness, halfwayDirection);
|
|
151
152
|
vec3 specularContribution = F * G * D;
|
|
152
153
|
#else
|
|
153
|
-
float specularStrength = computeDirectSpecularStrength(normalEC, lightDirectionEC, viewDirectionEC, halfwayDirectionEC,
|
|
154
|
+
float specularStrength = computeDirectSpecularStrength(normalEC, lightDirectionEC, viewDirectionEC, halfwayDirectionEC, alphaRoughness);
|
|
154
155
|
vec3 specularContribution = F * specularStrength;
|
|
155
156
|
#endif
|
|
156
157
|
|
|
@@ -14,14 +14,14 @@ vec3 fresnelSchlick2(vec3 f0, vec3 f90, float VdotH)\n\
|
|
|
14
14
|
\n\
|
|
15
15
|
#ifdef USE_ANISOTROPY\n\
|
|
16
16
|
/**\n\
|
|
17
|
-
* @param {float}
|
|
17
|
+
* @param {float} bitangentRoughness Material roughness (along the anisotropy bitangent)\n\
|
|
18
18
|
* @param {float} tangentialRoughness Anisotropic roughness (along the anisotropy tangent)\n\
|
|
19
19
|
* @param {vec3} lightDirection The direction from the fragment to the light source, transformed to tangent-bitangent-normal coordinates\n\
|
|
20
20
|
* @param {vec3} viewDirection The direction from the fragment to the camera, transformed to tangent-bitangent-normal coordinates\n\
|
|
21
21
|
*/\n\
|
|
22
|
-
float smithVisibilityGGX_anisotropic(float
|
|
22
|
+
float smithVisibilityGGX_anisotropic(float bitangentRoughness, float tangentialRoughness, vec3 lightDirection, vec3 viewDirection)\n\
|
|
23
23
|
{\n\
|
|
24
|
-
vec3 roughnessScale = vec3(tangentialRoughness,
|
|
24
|
+
vec3 roughnessScale = vec3(tangentialRoughness, bitangentRoughness, 1.0);\n\
|
|
25
25
|
float GGXV = lightDirection.z * length(roughnessScale * viewDirection);\n\
|
|
26
26
|
float GGXL = viewDirection.z * length(roughnessScale * lightDirection);\n\
|
|
27
27
|
float v = 0.5 / (GGXV + GGXL);\n\
|
|
@@ -29,44 +29,44 @@ float smithVisibilityGGX_anisotropic(float roughness, float tangentialRoughness,
|
|
|
29
29
|
}\n\
|
|
30
30
|
\n\
|
|
31
31
|
/**\n\
|
|
32
|
-
* @param {float}
|
|
32
|
+
* @param {float} bitangentRoughness Material roughness (along the anisotropy bitangent)\n\
|
|
33
33
|
* @param {float} tangentialRoughness Anisotropic roughness (along the anisotropy tangent)\n\
|
|
34
34
|
* @param {vec3} halfwayDirection The unit vector halfway between light and view directions, transformed to tangent-bitangent-normal coordinates\n\
|
|
35
35
|
*/\n\
|
|
36
|
-
float GGX_anisotropic(float
|
|
36
|
+
float GGX_anisotropic(float bitangentRoughness, float tangentialRoughness, vec3 halfwayDirection)\n\
|
|
37
37
|
{\n\
|
|
38
|
-
float roughnessSquared =
|
|
39
|
-
vec3 f = halfwayDirection * vec3(
|
|
38
|
+
float roughnessSquared = bitangentRoughness * tangentialRoughness;\n\
|
|
39
|
+
vec3 f = halfwayDirection * vec3(bitangentRoughness, tangentialRoughness, roughnessSquared);\n\
|
|
40
40
|
float w2 = roughnessSquared / dot(f, f);\n\
|
|
41
41
|
return roughnessSquared * w2 * w2 / czm_pi;\n\
|
|
42
42
|
}\n\
|
|
43
43
|
#endif\n\
|
|
44
44
|
\n\
|
|
45
|
-
float smithVisibilityG1(float NdotV, float roughness)\n\
|
|
46
|
-
{\n\
|
|
47
|
-
// this is the k value for direct lighting.\n\
|
|
48
|
-
// for image based lighting it will be roughness^2 / 2\n\
|
|
49
|
-
float k = (roughness + 1.0) * (roughness + 1.0) / 8.0;\n\
|
|
50
|
-
return NdotV / (NdotV * (1.0 - k) + k);\n\
|
|
51
|
-
}\n\
|
|
52
|
-
\n\
|
|
53
45
|
/**\n\
|
|
54
46
|
* Estimate the geometric self-shadowing of the microfacets in a surface,\n\
|
|
55
|
-
* using the
|
|
47
|
+
* using the Smith Joint GGX visibility function.\n\
|
|
48
|
+
* Note: Vis = G / (4 * NdotL * NdotV)\n\
|
|
49
|
+
* see Eric Heitz. 2014. Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs. Journal of Computer Graphics Techniques, 3\n\
|
|
50
|
+
* see Real-Time Rendering. Page 331 to 336.\n\
|
|
51
|
+
* see https://google.github.io/filament/Filament.md.html#materialsystem/specularbrdf/geometricshadowing(specularg)\n\
|
|
56
52
|
*\n\
|
|
57
|
-
* @param {float}
|
|
53
|
+
* @param {float} alphaRoughness The roughness of the material, expressed as the square of perceptual roughness.\n\
|
|
58
54
|
* @param {float} NdotL The cosine of the angle between the surface normal and the direction to the light source.\n\
|
|
59
55
|
* @param {float} NdotV The cosine of the angle between the surface normal and the direction to the camera.\n\
|
|
60
56
|
*/\n\
|
|
61
|
-
float smithVisibilityGGX(float
|
|
57
|
+
float smithVisibilityGGX(float alphaRoughness, float NdotL, float NdotV)\n\
|
|
62
58
|
{\n\
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
NdotV
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
59
|
+
float alphaRoughnessSq = alphaRoughness * alphaRoughness;\n\
|
|
60
|
+
\n\
|
|
61
|
+
float GGXV = NdotL * sqrt(NdotV * NdotV * (1.0 - alphaRoughnessSq) + alphaRoughnessSq);\n\
|
|
62
|
+
float GGXL = NdotV * sqrt(NdotL * NdotL * (1.0 - alphaRoughnessSq) + alphaRoughnessSq);\n\
|
|
63
|
+
\n\
|
|
64
|
+
float GGX = GGXV + GGXL;\n\
|
|
65
|
+
if (GGX > 0.0)\n\
|
|
66
|
+
{\n\
|
|
67
|
+
return 0.5 / GGX;\n\
|
|
68
|
+
}\n\
|
|
69
|
+
return 0.0;\n\
|
|
70
70
|
}\n\
|
|
71
71
|
\n\
|
|
72
72
|
/**\n\
|
|
@@ -74,15 +74,15 @@ float smithVisibilityGGX(float roughness, float NdotL, float NdotV)\n\
|
|
|
74
74
|
* the halfway vector, which is aligned halfway between the directions from\n\
|
|
75
75
|
* the fragment to the camera and from the fragment to the light source.\n\
|
|
76
76
|
*\n\
|
|
77
|
-
* @param {float}
|
|
77
|
+
* @param {float} alphaRoughness The roughness of the material, expressed as the square of perceptual roughness.\n\
|
|
78
78
|
* @param {float} NdotH The cosine of the angle between the surface normal and the halfway vector.\n\
|
|
79
79
|
* @return {float} The fraction of microfacets aligned to the halfway vector.\n\
|
|
80
80
|
*/\n\
|
|
81
|
-
float GGX(float
|
|
81
|
+
float GGX(float alphaRoughness, float NdotH)\n\
|
|
82
82
|
{\n\
|
|
83
|
-
float
|
|
84
|
-
float f = (NdotH *
|
|
85
|
-
return
|
|
83
|
+
float alphaRoughnessSquared = alphaRoughness * alphaRoughness;\n\
|
|
84
|
+
float f = (NdotH * alphaRoughnessSquared - NdotH) * NdotH + 1.0;\n\
|
|
85
|
+
return alphaRoughnessSquared / (czm_pi * f * f);\n\
|
|
86
86
|
}\n\
|
|
87
87
|
\n\
|
|
88
88
|
/**\n\
|
|
@@ -92,16 +92,16 @@ float GGX(float roughness, float NdotH)\n\
|
|
|
92
92
|
* @param {vec3} lightDirection The unit vector pointing from the fragment to the light source.\n\
|
|
93
93
|
* @param {vec3} viewDirection The unit vector pointing from the fragment to the camera.\n\
|
|
94
94
|
* @param {vec3} halfwayDirection The unit vector pointing from the fragment to halfway between the light source and the camera.\n\
|
|
95
|
-
* @param {float}
|
|
95
|
+
* @param {float} alphaRoughness The roughness of the material, expressed as the square of perceptual roughness.\n\
|
|
96
96
|
* @return {float} The strength of the specular reflection.\n\
|
|
97
97
|
*/\n\
|
|
98
|
-
float computeDirectSpecularStrength(vec3 normal, vec3 lightDirection, vec3 viewDirection, vec3 halfwayDirection, float
|
|
98
|
+
float computeDirectSpecularStrength(vec3 normal, vec3 lightDirection, vec3 viewDirection, vec3 halfwayDirection, float alphaRoughness)\n\
|
|
99
99
|
{\n\
|
|
100
|
-
float NdotL = dot(normal, lightDirection);\n\
|
|
101
|
-
float NdotV =
|
|
102
|
-
float G = smithVisibilityGGX(
|
|
100
|
+
float NdotL = clamp(dot(normal, lightDirection), 0.0, 1.0);\n\
|
|
101
|
+
float NdotV = clamp(dot(normal, viewDirection), 0.0, 1.0);\n\
|
|
102
|
+
float G = smithVisibilityGGX(alphaRoughness, NdotL, NdotV);\n\
|
|
103
103
|
float NdotH = clamp(dot(normal, halfwayDirection), 0.0, 1.0);\n\
|
|
104
|
-
float D = GGX(
|
|
104
|
+
float D = GGX(alphaRoughness, NdotH);\n\
|
|
105
105
|
return G * D;\n\
|
|
106
106
|
}\n\
|
|
107
107
|
\n\
|
|
@@ -139,19 +139,20 @@ vec3 czm_pbrLighting(vec3 viewDirectionEC, vec3 normalEC, vec3 lightDirectionEC,
|
|
|
139
139
|
F *= material.specularWeight;\n\
|
|
140
140
|
#endif\n\
|
|
141
141
|
\n\
|
|
142
|
-
float
|
|
142
|
+
float alphaRoughness = material.roughness * material.roughness;\n\
|
|
143
143
|
#ifdef USE_ANISOTROPY\n\
|
|
144
144
|
mat3 tbn = mat3(material.anisotropicT, material.anisotropicB, normalEC);\n\
|
|
145
145
|
vec3 lightDirection = lightDirectionEC * tbn;\n\
|
|
146
146
|
vec3 viewDirection = viewDirectionEC * tbn;\n\
|
|
147
147
|
vec3 halfwayDirection = halfwayDirectionEC * tbn;\n\
|
|
148
148
|
float anisotropyStrength = material.anisotropyStrength;\n\
|
|
149
|
-
float tangentialRoughness = mix(
|
|
150
|
-
float
|
|
151
|
-
float
|
|
149
|
+
float tangentialRoughness = mix(alphaRoughness, 1.0, anisotropyStrength * anisotropyStrength);\n\
|
|
150
|
+
float bitangentRoughness = clamp(alphaRoughness, 0.001, 1.0);\n\
|
|
151
|
+
float G = smithVisibilityGGX_anisotropic(bitangentRoughness, tangentialRoughness, lightDirection, viewDirection);\n\
|
|
152
|
+
float D = GGX_anisotropic(bitangentRoughness, tangentialRoughness, halfwayDirection);\n\
|
|
152
153
|
vec3 specularContribution = F * G * D;\n\
|
|
153
154
|
#else\n\
|
|
154
|
-
float specularStrength = computeDirectSpecularStrength(normalEC, lightDirectionEC, viewDirectionEC, halfwayDirectionEC,
|
|
155
|
+
float specularStrength = computeDirectSpecularStrength(normalEC, lightDirectionEC, viewDirectionEC, halfwayDirectionEC, alphaRoughness);\n\
|
|
155
156
|
vec3 specularContribution = F * specularStrength;\n\
|
|
156
157
|
#endif\n\
|
|
157
158
|
\n\
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// KhronosGroup https://github.com/KhronosGroup/ToneMapping/tree/main/PBR_Neutral
|
|
2
|
+
|
|
3
|
+
// Input color is non-negative and resides in the Linear Rec. 709 color space.
|
|
4
|
+
// Output color is also Linear Rec. 709, but in the [0, 1] range.
|
|
5
|
+
|
|
6
|
+
vec3 czm_pbrNeutralTonemapping(vec3 color) {
|
|
7
|
+
const float startCompression = 0.8 - 0.04;
|
|
8
|
+
const float desaturation = 0.15;
|
|
9
|
+
|
|
10
|
+
float x = min(color.r, min(color.g, color.b));
|
|
11
|
+
float offset = czm_branchFreeTernary(x < 0.08, x - 6.25 * x * x, 0.04);
|
|
12
|
+
color -= offset;
|
|
13
|
+
|
|
14
|
+
float peak = max(color.r, max(color.g, color.b));
|
|
15
|
+
if (peak < startCompression) return color;
|
|
16
|
+
|
|
17
|
+
const float d = 1.0 - startCompression;
|
|
18
|
+
float newPeak = 1.0 - d * d / (peak + d - startCompression);
|
|
19
|
+
color *= newPeak / peak;
|
|
20
|
+
|
|
21
|
+
float g = 1.0 - 1.0 / (desaturation * (peak - newPeak) + 1.0);
|
|
22
|
+
return mix(color, newPeak * vec3(1.0, 1.0, 1.0), g);
|
|
23
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
+
export default "// KhronosGroup https://github.com/KhronosGroup/ToneMapping/tree/main/PBR_Neutral\n\
|
|
3
|
+
\n\
|
|
4
|
+
// Input color is non-negative and resides in the Linear Rec. 709 color space.\n\
|
|
5
|
+
// Output color is also Linear Rec. 709, but in the [0, 1] range.\n\
|
|
6
|
+
\n\
|
|
7
|
+
vec3 czm_pbrNeutralTonemapping(vec3 color) {\n\
|
|
8
|
+
const float startCompression = 0.8 - 0.04;\n\
|
|
9
|
+
const float desaturation = 0.15;\n\
|
|
10
|
+
\n\
|
|
11
|
+
float x = min(color.r, min(color.g, color.b));\n\
|
|
12
|
+
float offset = czm_branchFreeTernary(x < 0.08, x - 6.25 * x * x, 0.04);\n\
|
|
13
|
+
color -= offset;\n\
|
|
14
|
+
\n\
|
|
15
|
+
float peak = max(color.r, max(color.g, color.b));\n\
|
|
16
|
+
if (peak < startCompression) return color;\n\
|
|
17
|
+
\n\
|
|
18
|
+
const float d = 1.0 - startCompression;\n\
|
|
19
|
+
float newPeak = 1.0 - d * d / (peak + d - startCompression);\n\
|
|
20
|
+
color *= newPeak / peak;\n\
|
|
21
|
+
\n\
|
|
22
|
+
float g = 1.0 - 1.0 / (desaturation * (peak - newPeak) + 1.0);\n\
|
|
23
|
+
return mix(color, newPeak * vec3(1.0, 1.0, 1.0), g);\n\
|
|
24
|
+
}\n\
|
|
25
|
+
";
|