@cesium/engine 22.2.0 → 23.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-YFEZPDAY.js → chunk-2GL2EUEE.js} +11 -11
- package/Build/Workers/{chunk-A3NUMZBG.js → chunk-2WI4HGJU.js} +6 -6
- package/Build/Workers/{chunk-3JB2X2PR.js → chunk-36LBFITA.js} +665 -366
- package/Build/Workers/{chunk-VSZ5DB2W.js → chunk-3B65YFXC.js} +1 -1
- package/Build/Workers/{chunk-PSHZAHFE.js → chunk-4LGFX2P5.js} +11 -11
- package/Build/Workers/{chunk-AMWXJ5A7.js → chunk-4UNQX2MP.js} +2 -2
- package/Build/Workers/{chunk-LDSQMLRC.js → chunk-52K3GJKG.js} +3 -3
- package/Build/Workers/{chunk-MSTAVM2N.js → chunk-56OHFSLH.js} +10 -10
- package/Build/Workers/{chunk-IWOSJVFQ.js → chunk-5A7YSAXT.js} +14 -14
- package/Build/Workers/{chunk-PMDPP22G.js → chunk-5JP5FG7U.js} +7 -7
- package/Build/Workers/{chunk-DIJ7IG5D.js → chunk-5R7SBUTW.js} +10 -10
- package/Build/Workers/chunk-5VKZVPO5.js +1829 -0
- package/Build/Workers/{chunk-L2FSBEW2.js → chunk-6FVFM2KB.js} +5 -5
- package/Build/Workers/{chunk-G6WQA27G.js → chunk-6SLGTBB2.js} +5 -5
- package/Build/Workers/{chunk-3HUEBDFC.js → chunk-7KRN6JPQ.js} +14 -14
- package/Build/Workers/{chunk-GMHDOQPH.js → chunk-AA33B6PU.js} +4 -4
- package/Build/Workers/{chunk-7CDQUIP5.js → chunk-AP6XWET5.js} +8 -8
- package/Build/Workers/{chunk-IVN5HSOI.js → chunk-APDKMX7W.js} +6 -6
- package/Build/Workers/{chunk-72LZ3FN6.js → chunk-ARCFIOKA.js} +12 -12
- package/Build/Workers/{chunk-UBJYWGMV.js → chunk-BNBD2YZK.js} +16 -16
- package/Build/Workers/{chunk-VGH2CSC7.js → chunk-DT5SJBKA.js} +29 -15
- package/Build/Workers/{chunk-ED4UXMYY.js → chunk-ESD4IEOU.js} +5 -5
- package/Build/Workers/{chunk-JFN2DQHY.js → chunk-FSDVXW7M.js} +5 -5
- package/Build/Workers/{chunk-JERDRSEI.js → chunk-G3YT7M7A.js} +1 -1
- package/Build/Workers/{chunk-NY3CWLIZ.js → chunk-GN5NEUDT.js} +8 -8
- package/Build/Workers/{chunk-O3GWUTWM.js → chunk-HYLEKKO5.js} +1 -1
- package/Build/Workers/{chunk-64PJ4MTB.js → chunk-HYTFXWMY.js} +7 -7
- package/Build/Workers/{chunk-FPRM6PCE.js → chunk-IFA7VHHP.js} +560 -306
- package/Build/Workers/{chunk-FM5XPC2E.js → chunk-IYVDOB5V.js} +4 -4
- package/Build/Workers/{chunk-P7ISUYLW.js → chunk-JUGY5AZN.js} +4 -4
- package/Build/Workers/{chunk-JONWM4IO.js → chunk-KPYU6YZG.js} +1 -1
- package/Build/Workers/{chunk-JUOSYFXT.js → chunk-L7RDJ4V7.js} +1 -1
- package/Build/Workers/{chunk-MWGB6DLR.js → chunk-LDQWNMEC.js} +1 -1
- package/Build/Workers/{chunk-C6FTHSJA.js → chunk-MQJG522T.js} +6 -6
- package/Build/Workers/{chunk-WH4HDRGN.js → chunk-MT5M7RLZ.js} +2 -2
- package/Build/Workers/{chunk-4ZQN7M7E.js → chunk-N4AWE7TZ.js} +10 -10
- package/Build/Workers/{chunk-SDUH3N6G.js → chunk-NAYRNPEP.js} +4 -4
- package/Build/Workers/{chunk-7OPRTZBT.js → chunk-NNHU33JK.js} +7 -7
- package/Build/Workers/{chunk-CQCEPC6N.js → chunk-NQCAZU7S.js} +13 -13
- package/Build/Workers/{chunk-35J4D6PX.js → chunk-NUYLNQKV.js} +2 -2
- package/Build/Workers/{chunk-I45CATZK.js → chunk-OC6X22PG.js} +9 -9
- package/Build/Workers/{chunk-7MGTX4WP.js → chunk-OHBM4YG4.js} +12 -12
- package/Build/Workers/{chunk-DCR62BCO.js → chunk-OMXN7YF4.js} +12 -12
- package/Build/Workers/{chunk-XPNY2VY3.js → chunk-OQ3EAJNW.js} +2 -2
- package/Build/Workers/{chunk-4I7BCCNU.js → chunk-OQBPOKPZ.js} +6 -6
- package/Build/Workers/{chunk-2JNPWPLE.js → chunk-PQVNT5CJ.js} +6 -6
- package/Build/Workers/{chunk-K64RQCRK.js → chunk-QA24Q62E.js} +17 -17
- package/Build/Workers/{chunk-K6BXEBAF.js → chunk-QQX7S5QT.js} +17 -17
- package/Build/Workers/{chunk-2YVTOY5Z.js → chunk-QTOHIXGF.js} +10 -10
- package/Build/Workers/{chunk-4MCPC4TE.js → chunk-R7M4XNPP.js} +8 -8
- package/Build/Workers/{chunk-C35SJ4QP.js → chunk-SGKTBHFQ.js} +13 -13
- package/Build/Workers/{chunk-BKYJBTHW.js → chunk-SQTRWKO2.js} +5 -5
- package/Build/Workers/{chunk-I4D5IP46.js → chunk-T43FXHNC.js} +7 -7
- package/Build/Workers/{chunk-QO6Z5UJE.js → chunk-UEEGWJJP.js} +2 -2
- package/Build/Workers/{chunk-ZUWF63QU.js → chunk-WKXDCVBO.js} +4 -4
- package/Build/Workers/{chunk-N5MNKWED.js → chunk-Y5AJSEEN.js} +2 -2
- package/Build/Workers/{chunk-V26Y7ZQL.js → chunk-ZIW5FCIW.js} +37 -27
- package/Build/Workers/combineGeometry.js +24 -24
- package/Build/Workers/createBoxGeometry.js +18 -18
- package/Build/Workers/createBoxOutlineGeometry.js +16 -16
- package/Build/Workers/createCircleGeometry.js +26 -26
- package/Build/Workers/createCircleOutlineGeometry.js +19 -19
- package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
- package/Build/Workers/createCorridorGeometry.js +29 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
- package/Build/Workers/createCylinderGeometry.js +20 -20
- package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
- package/Build/Workers/createEllipseGeometry.js +26 -26
- package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
- package/Build/Workers/createEllipsoidGeometry.js +19 -19
- package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
- package/Build/Workers/createFrustumGeometry.js +18 -18
- package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
- package/Build/Workers/createGeometry.js +24 -24
- package/Build/Workers/createGroundPolylineGeometry.js +22 -22
- package/Build/Workers/createPlaneGeometry.js +16 -16
- package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
- package/Build/Workers/createPolygonGeometry.js +32 -32
- package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
- package/Build/Workers/createPolylineGeometry.js +25 -25
- package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
- package/Build/Workers/createRectangleGeometry.js +27 -27
- package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
- package/Build/Workers/createSimplePolylineGeometry.js +23 -23
- package/Build/Workers/createSphereGeometry.js +19 -19
- package/Build/Workers/createSphereOutlineGeometry.js +18 -18
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
- package/Build/Workers/createVectorTileGeometries.js +24 -24
- package/Build/Workers/createVectorTilePoints.js +13 -13
- package/Build/Workers/createVectorTilePolygons.js +22 -22
- package/Build/Workers/createVectorTilePolylines.js +14 -14
- package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
- package/Build/Workers/createVerticesFromHeightmap.js +22 -22
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
- package/Build/Workers/createWallGeometry.js +24 -24
- package/Build/Workers/createWallOutlineGeometry.js +23 -23
- package/Build/Workers/decodeDraco.js +10 -10
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +10 -10
- package/Build/Workers/gaussianSplatSorter.js +4 -4
- package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
- package/Build/Workers/incrementallyBuildTerrainPicker.js +20 -12
- package/Build/Workers/transcodeKTX2.js +6 -6
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
- package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Source/Core/AttributeCompression.js +53 -6
- package/Source/Core/BoxGeometry.js +1 -1
- package/Source/Core/Cartesian2.js +689 -684
- package/Source/Core/Cartesian3.js +1044 -1043
- package/Source/Core/Cartesian4.js +816 -813
- package/Source/Core/CornerType.js +1 -1
- package/Source/Core/CorridorGeometry.js +1 -1
- package/Source/Core/FeatureDetection.js +1 -32
- package/Source/Core/Geometry.js +1 -1
- package/Source/Core/GoogleMaps.js +23 -2
- package/Source/Core/IntersectionTests.js +2 -2
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/OpenCageGeocoderService.js +2 -3
- package/Source/Core/PinBuilder.js +1 -1
- package/Source/Core/PolygonGeometry.js +1 -1
- package/Source/Core/PolylineGeometry.js +1 -1
- package/Source/Core/PolylineVolumeGeometry.js +1 -1
- package/Source/Core/RectangleGeometry.js +1 -1
- package/Source/Core/ScreenSpaceEventHandler.js +4 -8
- package/Source/Core/TerrainMesh.js +11 -8
- package/Source/Core/TerrainPicker.js +24 -7
- package/Source/Core/VideoSynchronizer.js +1 -1
- package/Source/Core/WallGeometry.js +1 -1
- package/Source/Core/globalTypes.js +16 -0
- package/Source/Core/writeTextToCanvas.js +40 -86
- package/Source/DataSources/BillboardGraphics.js +1 -1
- package/Source/DataSources/BoxGraphics.js +1 -1
- package/Source/DataSources/CallbackPositionProperty.js +1 -1
- package/Source/DataSources/CorridorGraphics.js +1 -1
- package/Source/DataSources/CzmlDataSource.js +1 -1
- package/Source/DataSources/EllipseGraphics.js +1 -1
- package/Source/DataSources/EllipsoidGraphics.js +1 -1
- package/Source/DataSources/Entity.js +1 -1
- package/Source/DataSources/EntityCluster.js +2 -2
- package/Source/DataSources/GeoJsonDataSource.js +2 -2
- package/Source/DataSources/GpxDataSource.js +1 -1
- package/Source/DataSources/KmlDataSource.js +1 -1
- package/Source/DataSources/KmlTour.js +1 -1
- package/Source/DataSources/LabelGraphics.js +1 -1
- package/Source/DataSources/ModelGraphics.js +1 -1
- package/Source/DataSources/PlaneGraphics.js +1 -1
- package/Source/DataSources/PolygonGraphics.js +1 -1
- package/Source/DataSources/PolylineGraphics.js +1 -1
- package/Source/DataSources/PolylineVolumeGraphics.js +1 -1
- package/Source/DataSources/RectangleGraphics.js +1 -1
- package/Source/DataSources/WallGraphics.js +1 -1
- package/Source/DataSources/exportKml.js +1 -1
- package/Source/Renderer/Context.js +11 -10
- package/Source/Renderer/ContextLimits.js +66 -33
- package/Source/Renderer/ShaderDestination.js +54 -13
- package/Source/Renderer/ShaderSource.js +19 -18
- package/Source/Renderer/Texture.js +1 -1
- package/Source/Renderer/Texture3D.js +166 -7
- package/Source/Renderer/TextureAtlas.js +2 -2
- package/Source/Scene/Appearance.js +1 -1
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Billboard.js +8 -5
- package/Source/Scene/BillboardCollection.js +65 -26
- package/Source/Scene/BillboardTexture.js +4 -1
- package/Source/Scene/BufferLoader.js +65 -74
- package/Source/Scene/Camera.js +13 -2
- package/Source/Scene/ClippingPlaneCollection.js +2 -2
- package/Source/Scene/CloudCollection.js +2 -2
- package/Source/Scene/CubeMapPanorama.js +351 -0
- package/Source/Scene/CumulusCloud.js +1 -1
- package/Source/Scene/DerivedCommand.js +8 -31
- package/Source/Scene/DracoLoader.js +79 -78
- package/Source/Scene/DynamicEnvironmentMapManager.js +41 -26
- package/Source/Scene/EquirectangularPanorama.js +264 -0
- package/Source/Scene/Fog.js +1 -1
- package/Source/Scene/FrameState.js +7 -0
- package/Source/Scene/GaussianSplatPrimitive.js +907 -168
- package/Source/Scene/Globe.js +3 -10
- package/Source/Scene/GlobeSurfaceShaderSet.js +36 -32
- package/Source/Scene/GltfBufferViewLoader.js +109 -118
- package/Source/Scene/GltfDracoLoader.js +167 -176
- package/Source/Scene/GltfImageLoader.js +91 -101
- package/Source/Scene/GltfIndexBufferLoader.js +228 -241
- package/Source/Scene/GltfJsonLoader.js +90 -99
- package/Source/Scene/GltfLoader.js +323 -324
- package/Source/Scene/GltfSpzLoader.js +127 -134
- package/Source/Scene/GltfStructuralMetadataLoader.js +181 -186
- package/Source/Scene/GltfTextureLoader.js +217 -231
- package/Source/Scene/GltfVertexBufferLoader.js +267 -276
- package/Source/Scene/GoogleStreetViewCubeMapPanoramaProvider.js +341 -0
- package/Source/Scene/ImageBasedLighting.js +2 -2
- package/Source/Scene/ImageryLayerCollection.js +2 -2
- package/Source/Scene/ImageryProvider.js +2 -2
- package/Source/Scene/Label.js +7 -5
- package/Source/Scene/LabelCollection.js +60 -2
- package/Source/Scene/Material.js +1 -1
- package/Source/Scene/MaterialAppearance.js +1 -1
- package/Source/Scene/Megatexture.js +174 -242
- package/Source/Scene/MetadataClassProperty.js +212 -7
- package/Source/Scene/MetadataComponentType.js +162 -127
- package/Source/Scene/MetadataSchemaLoader.js +60 -67
- package/Source/Scene/MetadataTable.js +14 -0
- package/Source/Scene/MetadataTableProperty.js +14 -0
- package/Source/Scene/Model/B3dmLoader.js +216 -224
- package/Source/Scene/Model/CustomShader.js +6 -1
- package/Source/Scene/Model/CustomShaderPipelineStage.js +122 -7
- package/Source/Scene/Model/GeoJsonLoader.js +53 -61
- package/Source/Scene/Model/GeometryPipelineStage.js +17 -3
- package/Source/Scene/Model/I3dmLoader.js +232 -240
- package/Source/Scene/Model/MaterialPipelineStage.js +17 -0
- package/Source/Scene/Model/MetadataPipelineStage.js +438 -22
- package/Source/Scene/Model/Model.js +1 -1
- package/Source/Scene/Model/PntsLoader.js +78 -89
- package/Source/Scene/ModelComponents.js +10 -0
- package/Source/Scene/Panorama.js +53 -0
- package/Source/Scene/PanoramaProvider.js +43 -0
- package/Source/Scene/ParticleSystem.js +2 -2
- package/Source/Scene/PointPrimitive.js +1 -1
- package/Source/Scene/PointPrimitiveCollection.js +14 -22
- package/Source/Scene/Polyline.js +0 -1
- package/Source/Scene/PolylineCollection.js +1 -4
- package/Source/Scene/PolylineColorAppearance.js +1 -6
- package/Source/Scene/PolylineMaterialAppearance.js +1 -6
- package/Source/Scene/PostProcessStageCollection.js +1 -1
- package/Source/Scene/PropertyTable.js +43 -0
- package/Source/Scene/PropertyTexture.js +1 -1
- package/Source/Scene/PropertyTextureProperty.js +0 -97
- package/Source/Scene/QuadtreePrimitive.js +6 -3
- package/Source/Scene/ResourceLoader.js +84 -92
- package/Source/Scene/Scene.js +12 -0
- package/Source/Scene/ShadowMap.js +1 -2
- package/Source/Scene/SkyBox.js +29 -164
- package/Source/Scene/StructuralMetadata.js +18 -3
- package/Source/Scene/Vector3DTileClampedPolylines.js +1 -5
- package/Source/Scene/Vector3DTilePolylines.js +1 -5
- package/Source/Scene/VoxelPrimitive.js +16 -33
- package/Source/Scene/VoxelRenderResources.js +1 -8
- package/Source/Scene/VoxelTraversal.js +16 -61
- package/Source/Scene/WebMapTileServiceImageryProvider.js +1 -1
- package/Source/Scene/createElevationBandMaterial.js +1 -1
- package/Source/Scene/parseStructuralMetadata.js +244 -0
- package/Source/Scene/processVoxelProperties.js +1 -1
- package/Source/Shaders/BillboardCollectionFS.glsl +66 -40
- package/Source/Shaders/BillboardCollectionFS.js +67 -40
- package/Source/Shaders/BillboardCollectionVS.glsl +22 -31
- package/Source/Shaders/BillboardCollectionVS.js +22 -31
- package/Source/Shaders/Builtin/CzmBuiltins.js +4 -0
- package/Source/Shaders/Builtin/Functions/columbusViewMorph.glsl +8 -1
- package/Source/Shaders/Builtin/Functions/columbusViewMorph.js +8 -1
- package/Source/Shaders/Builtin/Functions/decodeRGB8.glsl +22 -0
- package/Source/Shaders/Builtin/Functions/decodeRGB8.js +24 -0
- package/Source/Shaders/Builtin/Functions/unpackTexture.glsl +35 -0
- package/Source/Shaders/Builtin/Functions/unpackTexture.js +37 -0
- package/Source/Shaders/CubeMapPanoramaVS.glsl +11 -0
- package/Source/Shaders/CubeMapPanoramaVS.js +13 -0
- package/Source/Shaders/Model/MetadataStageFS.glsl +2 -1
- package/Source/Shaders/Model/MetadataStageFS.js +2 -1
- package/Source/Shaders/Model/MetadataStageVS.glsl +2 -1
- package/Source/Shaders/Model/MetadataStageVS.js +2 -1
- package/Source/Shaders/Model/ModelFS.glsl +9 -1
- package/Source/Shaders/Model/ModelFS.js +9 -1
- package/Source/Shaders/Model/ModelVS.glsl +4 -2
- package/Source/Shaders/Model/ModelVS.js +4 -2
- package/Source/Shaders/PointPrimitiveCollectionVS.glsl +8 -39
- package/Source/Shaders/PointPrimitiveCollectionVS.js +8 -39
- package/Source/Shaders/Voxels/IntersectionUtils.glsl +1 -1
- package/Source/Shaders/Voxels/IntersectionUtils.js +1 -1
- package/Source/Shaders/Voxels/Megatexture.glsl +15 -83
- package/Source/Shaders/Voxels/Megatexture.js +15 -83
- package/Source/Shaders/Voxels/Octree.glsl +6 -9
- package/Source/Shaders/Voxels/Octree.js +6 -9
- package/Source/Widget/CesiumWidget.js +1 -1
- package/Source/Workers/incrementallyBuildTerrainPicker.js +16 -2
- package/index.d.ts +582 -193
- package/index.js +91 -83
- package/package.json +2 -1
- package/Build/Workers/chunk-ZGWX2R5I.js +0 -1443
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Useful for reinterpreting texture data as higher-precision values.
|
|
3
|
+
* Only works correctly in WebGL 2, which supports the uint type and bitwise operations.
|
|
4
|
+
*
|
|
5
|
+
* @param {float|vec2|vec3|vec4} 1-4 values from a texture lookup (RGBA channels), normalized to [0.0, 1.0].
|
|
6
|
+
* @return {uint} Raw bits as an unsigned integer.
|
|
7
|
+
*/
|
|
8
|
+
uint czm_unpackTexture(float packedValue) {
|
|
9
|
+
float rounded = czm_round(packedValue * 255.0);
|
|
10
|
+
return uint(rounded);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
uint czm_unpackTexture(vec2 packedValue) {
|
|
14
|
+
vec2 rounded = czm_round(packedValue * 255.0);
|
|
15
|
+
uint byte0 = uint(rounded.x);
|
|
16
|
+
uint byte1 = uint(rounded.y);
|
|
17
|
+
return byte0 | (byte1 << 8);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
uint czm_unpackTexture(vec3 packedValue) {
|
|
21
|
+
vec3 rounded = czm_round(packedValue * 255.0);
|
|
22
|
+
uint byte0 = uint(rounded.x);
|
|
23
|
+
uint byte1 = uint(rounded.y);
|
|
24
|
+
uint byte2 = uint(rounded.z);
|
|
25
|
+
return byte0 | (byte1 << 8) | (byte2 << 16);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
uint czm_unpackTexture(vec4 packedValue) {
|
|
29
|
+
vec4 rounded = czm_round(packedValue * 255.0);
|
|
30
|
+
uint byte0 = uint(rounded.x);
|
|
31
|
+
uint byte1 = uint(rounded.y);
|
|
32
|
+
uint byte2 = uint(rounded.z);
|
|
33
|
+
uint byte3 = uint(rounded.w);
|
|
34
|
+
return byte0 | (byte1 << 8) | (byte2 << 16) | (byte3 << 24);
|
|
35
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
+
export default "/**\n\
|
|
3
|
+
* Useful for reinterpreting texture data as higher-precision values.\n\
|
|
4
|
+
* Only works correctly in WebGL 2, which supports the uint type and bitwise operations.\n\
|
|
5
|
+
*\n\
|
|
6
|
+
* @param {float|vec2|vec3|vec4} 1-4 values from a texture lookup (RGBA channels), normalized to [0.0, 1.0].\n\
|
|
7
|
+
* @return {uint} Raw bits as an unsigned integer.\n\
|
|
8
|
+
*/\n\
|
|
9
|
+
uint czm_unpackTexture(float packedValue) {\n\
|
|
10
|
+
float rounded = czm_round(packedValue * 255.0);\n\
|
|
11
|
+
return uint(rounded);\n\
|
|
12
|
+
}\n\
|
|
13
|
+
\n\
|
|
14
|
+
uint czm_unpackTexture(vec2 packedValue) {\n\
|
|
15
|
+
vec2 rounded = czm_round(packedValue * 255.0);\n\
|
|
16
|
+
uint byte0 = uint(rounded.x);\n\
|
|
17
|
+
uint byte1 = uint(rounded.y);\n\
|
|
18
|
+
return byte0 | (byte1 << 8);\n\
|
|
19
|
+
}\n\
|
|
20
|
+
\n\
|
|
21
|
+
uint czm_unpackTexture(vec3 packedValue) {\n\
|
|
22
|
+
vec3 rounded = czm_round(packedValue * 255.0);\n\
|
|
23
|
+
uint byte0 = uint(rounded.x);\n\
|
|
24
|
+
uint byte1 = uint(rounded.y);\n\
|
|
25
|
+
uint byte2 = uint(rounded.z);\n\
|
|
26
|
+
return byte0 | (byte1 << 8) | (byte2 << 16);\n\
|
|
27
|
+
}\n\
|
|
28
|
+
\n\
|
|
29
|
+
uint czm_unpackTexture(vec4 packedValue) {\n\
|
|
30
|
+
vec4 rounded = czm_round(packedValue * 255.0);\n\
|
|
31
|
+
uint byte0 = uint(rounded.x);\n\
|
|
32
|
+
uint byte1 = uint(rounded.y);\n\
|
|
33
|
+
uint byte2 = uint(rounded.z);\n\
|
|
34
|
+
uint byte3 = uint(rounded.w);\n\
|
|
35
|
+
return byte0 | (byte1 << 8) | (byte2 << 16) | (byte3 << 24);\n\
|
|
36
|
+
}\n\
|
|
37
|
+
";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
uniform mat3 u_cubeMapPanoramaTransform;
|
|
2
|
+
|
|
3
|
+
in vec3 position;
|
|
4
|
+
out vec3 v_texCoord;
|
|
5
|
+
|
|
6
|
+
void main()
|
|
7
|
+
{
|
|
8
|
+
vec3 p = czm_viewRotation * (u_cubeMapPanoramaTransform * (czm_entireFrustum.y * position));
|
|
9
|
+
gl_Position = czm_projection * vec4(p, 1.0);
|
|
10
|
+
v_texCoord = position.xyz;
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
+
export default "uniform mat3 u_cubeMapPanoramaTransform;\n\
|
|
3
|
+
\n\
|
|
4
|
+
in vec3 position;\n\
|
|
5
|
+
out vec3 v_texCoord;\n\
|
|
6
|
+
\n\
|
|
7
|
+
void main()\n\
|
|
8
|
+
{\n\
|
|
9
|
+
vec3 p = czm_viewRotation * (u_cubeMapPanoramaTransform * (czm_entireFrustum.y * position));\n\
|
|
10
|
+
gl_Position = czm_projection * vec4(p, 1.0);\n\
|
|
11
|
+
v_texCoord = position.xyz;\n\
|
|
12
|
+
}\n\
|
|
13
|
+
";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
void metadataStage(
|
|
2
|
+
FeatureIds featureIds,
|
|
2
3
|
out Metadata metadata,
|
|
3
4
|
out MetadataClass metadataClass,
|
|
4
5
|
out MetadataStatistics metadataStatistics,
|
|
5
6
|
ProcessedAttributes attributes
|
|
6
7
|
)
|
|
7
8
|
{
|
|
8
|
-
initializeMetadata(metadata, metadataClass, metadataStatistics, attributes);
|
|
9
|
+
initializeMetadata(featureIds, metadata, metadataClass, metadataStatistics, attributes);
|
|
9
10
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
//This file is automatically rebuilt by the Cesium build process.
|
|
2
2
|
export default "void metadataStage(\n\
|
|
3
|
+
FeatureIds featureIds,\n\
|
|
3
4
|
out Metadata metadata,\n\
|
|
4
5
|
out MetadataClass metadataClass,\n\
|
|
5
6
|
out MetadataStatistics metadataStatistics,\n\
|
|
6
7
|
ProcessedAttributes attributes\n\
|
|
7
8
|
)\n\
|
|
8
9
|
{\n\
|
|
9
|
-
initializeMetadata(metadata, metadataClass, metadataStatistics, attributes);\n\
|
|
10
|
+
initializeMetadata(featureIds, metadata, metadataClass, metadataStatistics, attributes);\n\
|
|
10
11
|
}\n\
|
|
11
12
|
";
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
void metadataStage(
|
|
2
|
+
FeatureIds featureIds,
|
|
2
3
|
out Metadata metadata,
|
|
3
4
|
out MetadataClass metadataClass,
|
|
4
5
|
out MetadataStatistics metadataStatistics,
|
|
5
6
|
ProcessedAttributes attributes
|
|
6
7
|
)
|
|
7
8
|
{
|
|
8
|
-
initializeMetadata(metadata, metadataClass, metadataStatistics, attributes);
|
|
9
|
+
initializeMetadata(featureIds, metadata, metadataClass, metadataStatistics, attributes);
|
|
9
10
|
setMetadataVaryings();
|
|
10
11
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
//This file is automatically rebuilt by the Cesium build process.
|
|
2
2
|
export default "void metadataStage(\n\
|
|
3
|
+
FeatureIds featureIds,\n\
|
|
3
4
|
out Metadata metadata,\n\
|
|
4
5
|
out MetadataClass metadataClass,\n\
|
|
5
6
|
out MetadataStatistics metadataStatistics,\n\
|
|
6
7
|
ProcessedAttributes attributes\n\
|
|
7
8
|
)\n\
|
|
8
9
|
{\n\
|
|
9
|
-
initializeMetadata(metadata, metadataClass, metadataStatistics, attributes);\n\
|
|
10
|
+
initializeMetadata(featureIds, metadata, metadataClass, metadataStatistics, attributes);\n\
|
|
10
11
|
setMetadataVaryings();\n\
|
|
11
12
|
}\n\
|
|
12
13
|
";
|
|
@@ -29,6 +29,14 @@ SelectedFeature selectedFeature;
|
|
|
29
29
|
|
|
30
30
|
void main()
|
|
31
31
|
{
|
|
32
|
+
#if defined(PRIMITIVE_TYPE_POINTS) && defined(HAS_POINT_DIAMETER)
|
|
33
|
+
// Render points as circles
|
|
34
|
+
float distanceToCenter = length(gl_PointCoord - vec2(0.5));
|
|
35
|
+
if (distanceToCenter > 0.5) {
|
|
36
|
+
discard;
|
|
37
|
+
}
|
|
38
|
+
#endif
|
|
39
|
+
|
|
32
40
|
#ifdef HAS_POINT_CLOUD_SHOW_STYLE
|
|
33
41
|
if (v_pointCloudShow == 0.0)
|
|
34
42
|
{
|
|
@@ -51,7 +59,7 @@ void main()
|
|
|
51
59
|
Metadata metadata;
|
|
52
60
|
MetadataClass metadataClass;
|
|
53
61
|
MetadataStatistics metadataStatistics;
|
|
54
|
-
metadataStage(metadata, metadataClass, metadataStatistics, attributes);
|
|
62
|
+
metadataStage(featureIds, metadata, metadataClass, metadataStatistics, attributes);
|
|
55
63
|
|
|
56
64
|
//========================================================================
|
|
57
65
|
// When not picking metadata START
|
|
@@ -30,6 +30,14 @@ SelectedFeature selectedFeature;\n\
|
|
|
30
30
|
\n\
|
|
31
31
|
void main()\n\
|
|
32
32
|
{\n\
|
|
33
|
+
#if defined(PRIMITIVE_TYPE_POINTS) && defined(HAS_POINT_DIAMETER)\n\
|
|
34
|
+
// Render points as circles\n\
|
|
35
|
+
float distanceToCenter = length(gl_PointCoord - vec2(0.5));\n\
|
|
36
|
+
if (distanceToCenter > 0.5) {\n\
|
|
37
|
+
discard;\n\
|
|
38
|
+
}\n\
|
|
39
|
+
#endif\n\
|
|
40
|
+
\n\
|
|
33
41
|
#ifdef HAS_POINT_CLOUD_SHOW_STYLE\n\
|
|
34
42
|
if (v_pointCloudShow == 0.0)\n\
|
|
35
43
|
{\n\
|
|
@@ -52,7 +60,7 @@ void main()\n\
|
|
|
52
60
|
Metadata metadata;\n\
|
|
53
61
|
MetadataClass metadataClass;\n\
|
|
54
62
|
MetadataStatistics metadataStatistics;\n\
|
|
55
|
-
metadataStage(metadata, metadataClass, metadataStatistics, attributes);\n\
|
|
63
|
+
metadataStage(featureIds, metadata, metadataClass, metadataStatistics, attributes);\n\
|
|
56
64
|
\n\
|
|
57
65
|
//========================================================================\n\
|
|
58
66
|
// When not picking metadata START\n\
|
|
@@ -95,7 +95,7 @@ void main()
|
|
|
95
95
|
Metadata metadata;
|
|
96
96
|
MetadataClass metadataClass;
|
|
97
97
|
MetadataStatistics metadataStatistics;
|
|
98
|
-
metadataStage(metadata, metadataClass, metadataStatistics, attributes);
|
|
98
|
+
metadataStage(featureIds, metadata, metadataClass, metadataStatistics, attributes);
|
|
99
99
|
|
|
100
100
|
#ifdef HAS_VERTICAL_EXAGGERATION
|
|
101
101
|
verticalExaggerationStage(attributes);
|
|
@@ -142,10 +142,12 @@ void main()
|
|
|
142
142
|
gl_PointSize = vsOutput.pointSize;
|
|
143
143
|
#elif defined(HAS_POINT_CLOUD_POINT_SIZE_STYLE) || defined(HAS_POINT_CLOUD_ATTENUATION)
|
|
144
144
|
gl_PointSize = pointCloudPointSizeStylingStage(attributes, metadata);
|
|
145
|
+
#elif defined(HAS_POINT_DIAMETER)
|
|
146
|
+
gl_PointSize = u_pointDiameter;
|
|
145
147
|
#else
|
|
146
148
|
gl_PointSize = 1.0;
|
|
147
149
|
#endif
|
|
148
|
-
|
|
150
|
+
|
|
149
151
|
gl_PointSize *= show;
|
|
150
152
|
#endif
|
|
151
153
|
|
|
@@ -96,7 +96,7 @@ void main()\n\
|
|
|
96
96
|
Metadata metadata;\n\
|
|
97
97
|
MetadataClass metadataClass;\n\
|
|
98
98
|
MetadataStatistics metadataStatistics;\n\
|
|
99
|
-
metadataStage(metadata, metadataClass, metadataStatistics, attributes);\n\
|
|
99
|
+
metadataStage(featureIds, metadata, metadataClass, metadataStatistics, attributes);\n\
|
|
100
100
|
\n\
|
|
101
101
|
#ifdef HAS_VERTICAL_EXAGGERATION\n\
|
|
102
102
|
verticalExaggerationStage(attributes);\n\
|
|
@@ -143,10 +143,12 @@ void main()\n\
|
|
|
143
143
|
gl_PointSize = vsOutput.pointSize;\n\
|
|
144
144
|
#elif defined(HAS_POINT_CLOUD_POINT_SIZE_STYLE) || defined(HAS_POINT_CLOUD_ATTENUATION)\n\
|
|
145
145
|
gl_PointSize = pointCloudPointSizeStylingStage(attributes, metadata);\n\
|
|
146
|
+
#elif defined(HAS_POINT_DIAMETER)\n\
|
|
147
|
+
gl_PointSize = u_pointDiameter;\n\
|
|
146
148
|
#else\n\
|
|
147
149
|
gl_PointSize = 1.0;\n\
|
|
148
150
|
#endif\n\
|
|
149
|
-
|
|
151
|
+
\n\
|
|
150
152
|
gl_PointSize *= show;\n\
|
|
151
153
|
#endif\n\
|
|
152
154
|
\n\
|
|
@@ -46,45 +46,14 @@ void main()
|
|
|
46
46
|
|
|
47
47
|
///////////////////////////////////////////////////////////////////////////
|
|
48
48
|
|
|
49
|
-
vec4 color;
|
|
50
|
-
vec4 outlineColor;
|
|
51
|
-
vec4 pickColor;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
pickColor.
|
|
57
|
-
temp = floor(temp) * SHIFT_RIGHT8;
|
|
58
|
-
pickColor.g = (temp - floor(temp)) * SHIFT_LEFT8;
|
|
59
|
-
pickColor.r = floor(temp);
|
|
60
|
-
|
|
61
|
-
// compressedAttribute0.x => color.rgb
|
|
62
|
-
|
|
63
|
-
temp = compressedAttribute0.x * SHIFT_RIGHT8;
|
|
64
|
-
color.b = (temp - floor(temp)) * SHIFT_LEFT8;
|
|
65
|
-
temp = floor(temp) * SHIFT_RIGHT8;
|
|
66
|
-
color.g = (temp - floor(temp)) * SHIFT_LEFT8;
|
|
67
|
-
color.r = floor(temp);
|
|
68
|
-
|
|
69
|
-
// compressedAttribute0.y => outlineColor.rgb
|
|
70
|
-
|
|
71
|
-
temp = compressedAttribute0.y * SHIFT_RIGHT8;
|
|
72
|
-
outlineColor.b = (temp - floor(temp)) * SHIFT_LEFT8;
|
|
73
|
-
temp = floor(temp) * SHIFT_RIGHT8;
|
|
74
|
-
outlineColor.g = (temp - floor(temp)) * SHIFT_LEFT8;
|
|
75
|
-
outlineColor.r = floor(temp);
|
|
76
|
-
|
|
77
|
-
// compressedAttribute0.w => color.a, outlineColor.a, pickColor.a
|
|
78
|
-
|
|
79
|
-
temp = compressedAttribute0.w * SHIFT_RIGHT8;
|
|
80
|
-
pickColor.a = (temp - floor(temp)) * SHIFT_LEFT8;
|
|
81
|
-
pickColor = pickColor / 255.0;
|
|
82
|
-
|
|
83
|
-
temp = floor(temp) * SHIFT_RIGHT8;
|
|
84
|
-
outlineColor.a = (temp - floor(temp)) * SHIFT_LEFT8;
|
|
85
|
-
outlineColor /= 255.0;
|
|
86
|
-
color.a = floor(temp);
|
|
87
|
-
color /= 255.0;
|
|
49
|
+
vec4 color = czm_decodeRGB8(compressedAttribute0.x);
|
|
50
|
+
vec4 outlineColor = czm_decodeRGB8(compressedAttribute0.y);
|
|
51
|
+
vec4 pickColor = czm_decodeRGB8(compressedAttribute0.z);
|
|
52
|
+
vec4 alphaPacked = czm_decodeRGB8(compressedAttribute0.w);
|
|
53
|
+
|
|
54
|
+
color.a = alphaPacked.x;
|
|
55
|
+
outlineColor.a = alphaPacked.y;
|
|
56
|
+
pickColor.a = alphaPacked.z;
|
|
88
57
|
|
|
89
58
|
///////////////////////////////////////////////////////////////////////////
|
|
90
59
|
|
|
@@ -47,45 +47,14 @@ void main()\n\
|
|
|
47
47
|
\n\
|
|
48
48
|
///////////////////////////////////////////////////////////////////////////\n\
|
|
49
49
|
\n\
|
|
50
|
-
vec4 color;\n\
|
|
51
|
-
vec4 outlineColor;\n\
|
|
52
|
-
vec4 pickColor;\n\
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
pickColor.
|
|
58
|
-
temp = floor(temp) * SHIFT_RIGHT8;\n\
|
|
59
|
-
pickColor.g = (temp - floor(temp)) * SHIFT_LEFT8;\n\
|
|
60
|
-
pickColor.r = floor(temp);\n\
|
|
61
|
-
\n\
|
|
62
|
-
// compressedAttribute0.x => color.rgb\n\
|
|
63
|
-
\n\
|
|
64
|
-
temp = compressedAttribute0.x * SHIFT_RIGHT8;\n\
|
|
65
|
-
color.b = (temp - floor(temp)) * SHIFT_LEFT8;\n\
|
|
66
|
-
temp = floor(temp) * SHIFT_RIGHT8;\n\
|
|
67
|
-
color.g = (temp - floor(temp)) * SHIFT_LEFT8;\n\
|
|
68
|
-
color.r = floor(temp);\n\
|
|
69
|
-
\n\
|
|
70
|
-
// compressedAttribute0.y => outlineColor.rgb\n\
|
|
71
|
-
\n\
|
|
72
|
-
temp = compressedAttribute0.y * SHIFT_RIGHT8;\n\
|
|
73
|
-
outlineColor.b = (temp - floor(temp)) * SHIFT_LEFT8;\n\
|
|
74
|
-
temp = floor(temp) * SHIFT_RIGHT8;\n\
|
|
75
|
-
outlineColor.g = (temp - floor(temp)) * SHIFT_LEFT8;\n\
|
|
76
|
-
outlineColor.r = floor(temp);\n\
|
|
77
|
-
\n\
|
|
78
|
-
// compressedAttribute0.w => color.a, outlineColor.a, pickColor.a\n\
|
|
79
|
-
\n\
|
|
80
|
-
temp = compressedAttribute0.w * SHIFT_RIGHT8;\n\
|
|
81
|
-
pickColor.a = (temp - floor(temp)) * SHIFT_LEFT8;\n\
|
|
82
|
-
pickColor = pickColor / 255.0;\n\
|
|
83
|
-
\n\
|
|
84
|
-
temp = floor(temp) * SHIFT_RIGHT8;\n\
|
|
85
|
-
outlineColor.a = (temp - floor(temp)) * SHIFT_LEFT8;\n\
|
|
86
|
-
outlineColor /= 255.0;\n\
|
|
87
|
-
color.a = floor(temp);\n\
|
|
88
|
-
color /= 255.0;\n\
|
|
50
|
+
vec4 color = czm_decodeRGB8(compressedAttribute0.x);\n\
|
|
51
|
+
vec4 outlineColor = czm_decodeRGB8(compressedAttribute0.y);\n\
|
|
52
|
+
vec4 pickColor = czm_decodeRGB8(compressedAttribute0.z);\n\
|
|
53
|
+
vec4 alphaPacked = czm_decodeRGB8(compressedAttribute0.w);\n\
|
|
54
|
+
\n\
|
|
55
|
+
color.a = alphaPacked.x;\n\
|
|
56
|
+
outlineColor.a = alphaPacked.y;\n\
|
|
57
|
+
pickColor.a = alphaPacked.z;\n\
|
|
89
58
|
\n\
|
|
90
59
|
///////////////////////////////////////////////////////////////////////////\n\
|
|
91
60
|
\n\
|
|
@@ -135,7 +135,7 @@ RayShapeIntersection nextIntersection(inout Intersections ix) {
|
|
|
135
135
|
surfaceIntersection = ix.intersections[i];
|
|
136
136
|
int intersectionType = int(length(surfaceIntersection.xyz) - 0.5);
|
|
137
137
|
bool currShapeIsPositive = intersectionType < 2;
|
|
138
|
-
bool enter =
|
|
138
|
+
bool enter = intersectionType % 2 == 0;
|
|
139
139
|
|
|
140
140
|
ix.surroundCount += enter ? +1 : -1;
|
|
141
141
|
ix.surroundIsPositive = currShapeIsPositive ? enter : ix.surroundIsPositive;
|
|
@@ -136,7 +136,7 @@ RayShapeIntersection nextIntersection(inout Intersections ix) {\n\
|
|
|
136
136
|
surfaceIntersection = ix.intersections[i];\n\
|
|
137
137
|
int intersectionType = int(length(surfaceIntersection.xyz) - 0.5);\n\
|
|
138
138
|
bool currShapeIsPositive = intersectionType < 2;\n\
|
|
139
|
-
bool enter =
|
|
139
|
+
bool enter = intersectionType % 2 == 0;\n\
|
|
140
140
|
\n\
|
|
141
141
|
ix.surroundCount += enter ? +1 : -1;\n\
|
|
142
142
|
ix.surroundIsPositive = currShapeIsPositive ? enter : ix.surroundIsPositive;\n\
|
|
@@ -1,104 +1,36 @@
|
|
|
1
|
-
// See Octree.glsl for the definitions of SampleData
|
|
1
|
+
// See Octree.glsl for the definitions of SampleData
|
|
2
2
|
|
|
3
3
|
/* Megatexture defines (set in Scene/VoxelRenderResources.js)
|
|
4
4
|
#define SAMPLE_COUNT ###
|
|
5
|
-
#define NEAREST_SAMPLING
|
|
6
5
|
#define PADDING
|
|
7
6
|
*/
|
|
8
7
|
|
|
9
|
-
uniform
|
|
10
|
-
uniform ivec2 u_megatextureTileDimensions; // number of tiles per megatexture, in two dimensions
|
|
11
|
-
uniform vec2 u_megatextureVoxelSizeUv;
|
|
12
|
-
uniform vec2 u_megatextureSliceSizeUv;
|
|
13
|
-
uniform vec2 u_megatextureTileSizeUv;
|
|
8
|
+
uniform ivec3 u_megatextureTileCounts; // number of tiles in the megatexture, along each axis
|
|
14
9
|
|
|
15
|
-
|
|
16
|
-
int intMin(int a, int b) {
|
|
17
|
-
return a <= b ? a : b;
|
|
18
|
-
}
|
|
19
|
-
int intMax(int a, int b) {
|
|
20
|
-
return a >= b ? a : b;
|
|
21
|
-
}
|
|
22
|
-
int intClamp(int v, int minVal, int maxVal) {
|
|
23
|
-
return intMin(intMax(v, minVal), maxVal);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
vec2 index1DTo2DTexcoord(int index, ivec2 dimensions, vec2 uvScale)
|
|
10
|
+
vec3 index1DTo3DTexCoord(int index)
|
|
27
11
|
{
|
|
28
|
-
int
|
|
29
|
-
int
|
|
30
|
-
|
|
12
|
+
int tilesPerZ = u_megatextureTileCounts.x * u_megatextureTileCounts.y;
|
|
13
|
+
int iz = index / tilesPerZ;
|
|
14
|
+
int remainder = index - iz * tilesPerZ;
|
|
15
|
+
int iy = remainder / u_megatextureTileCounts.x;
|
|
16
|
+
int ix = remainder - iy * u_megatextureTileCounts.x;
|
|
17
|
+
return vec3(ix, iy, iz) / vec3(u_megatextureTileCounts);
|
|
31
18
|
}
|
|
32
19
|
|
|
33
|
-
/*
|
|
34
|
-
How is 3D data stored in a 2D megatexture?
|
|
35
|
-
|
|
36
|
-
In this example there is only one loaded tile and it has 2x2x2 voxels (8 voxels total).
|
|
37
|
-
The data is sliced by Z. The data at Z = 0 is placed in texels (0,0), (0,1), (1,0), (1,1) and
|
|
38
|
-
the data at Z = 1 is placed in texels (2,0), (2,1), (3,0), (3,1).
|
|
39
|
-
Note that there could be empty space in the megatexture because it's a power of two.
|
|
40
|
-
|
|
41
|
-
0 1 2 3
|
|
42
|
-
+---+---+---+---+
|
|
43
|
-
| | | | | 3
|
|
44
|
-
+---+---+---+---+
|
|
45
|
-
| | | | | 2
|
|
46
|
-
+-------+-------+
|
|
47
|
-
|010|110|011|111| 1
|
|
48
|
-
|--- ---|--- ---|
|
|
49
|
-
|000|100|001|101| 0
|
|
50
|
-
+-------+-------+
|
|
51
|
-
|
|
52
|
-
When doing linear interpolation the megatexture needs to be sampled twice: once for
|
|
53
|
-
the Z slice above the voxel coordinate and once for the slice below. The two slices
|
|
54
|
-
are interpolated with fract(coord.z - 0.5). For example, a Z coordinate of 1.0 is
|
|
55
|
-
halfway between two Z slices so the interpolation factor is 0.5. Below is a side view
|
|
56
|
-
of the 3D voxel grid with voxel coordinates on the left side.
|
|
57
|
-
|
|
58
|
-
2 +---+
|
|
59
|
-
|001|
|
|
60
|
-
1 +-z-+
|
|
61
|
-
|000|
|
|
62
|
-
0 +---+
|
|
63
|
-
|
|
64
|
-
When doing nearest neighbor the megatexture only needs to be sampled once at the closest Z slice.
|
|
65
|
-
*/
|
|
66
|
-
|
|
67
20
|
Properties getPropertiesFromMegatexture(in SampleData sampleData) {
|
|
68
21
|
int tileIndex = sampleData.megatextureIndex;
|
|
69
22
|
|
|
70
23
|
vec3 voxelCoord = sampleData.inputCoordinate;
|
|
71
|
-
#if defined(NEAREST_SAMPLING)
|
|
72
|
-
// Round to the center of the nearest voxel
|
|
73
|
-
voxelCoord = floor(voxelCoord) + vec3(0.5);
|
|
74
|
-
#endif
|
|
75
24
|
|
|
76
|
-
//
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
// Slice location
|
|
80
|
-
float slice = voxelCoord.z - 0.5;
|
|
81
|
-
int sliceIndex = int(floor(slice));
|
|
82
|
-
int sliceIndex0 = intClamp(sliceIndex, 0, u_inputDimensions.z - 1);
|
|
83
|
-
vec2 sliceUvOffset0 = index1DTo2DTexcoord(sliceIndex0, u_megatextureSliceDimensions, u_megatextureSliceSizeUv);
|
|
25
|
+
// UV coordinate of the lower corner of the tile in the megatexture
|
|
26
|
+
vec3 tileUvOffset = index1DTo3DTexCoord(tileIndex);
|
|
84
27
|
|
|
85
28
|
// Voxel location
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
vec2 uv0 = tileUvOffset + sliceUvOffset0 + voxelUvOffset;
|
|
29
|
+
vec3 tileDimensions = vec3(u_inputDimensions);
|
|
30
|
+
vec3 clampedVoxelCoord = clamp(voxelCoord, vec3(0.5), tileDimensions - vec3(0.5));
|
|
31
|
+
vec3 voxelUv = clampedVoxelCoord / tileDimensions / vec3(u_megatextureTileCounts);
|
|
90
32
|
|
|
91
|
-
|
|
92
|
-
return getPropertiesFromMegatextureAtUv(uv0);
|
|
93
|
-
#else
|
|
94
|
-
float sliceLerp = fract(slice);
|
|
95
|
-
int sliceIndex1 = intMin(sliceIndex + 1, u_inputDimensions.z - 1);
|
|
96
|
-
vec2 sliceUvOffset1 = index1DTo2DTexcoord(sliceIndex1, u_megatextureSliceDimensions, u_megatextureSliceSizeUv);
|
|
97
|
-
vec2 uv1 = tileUvOffset + sliceUvOffset1 + voxelUvOffset;
|
|
98
|
-
Properties properties0 = getPropertiesFromMegatextureAtUv(uv0);
|
|
99
|
-
Properties properties1 = getPropertiesFromMegatextureAtUv(uv1);
|
|
100
|
-
return mixProperties(properties0, properties1, sliceLerp);
|
|
101
|
-
#endif
|
|
33
|
+
return getPropertiesFromMegatextureAtUv(tileUvOffset + voxelUv);
|
|
102
34
|
}
|
|
103
35
|
|
|
104
36
|
// Convert an array of sample datas to a final weighted properties.
|
|
@@ -1,105 +1,37 @@
|
|
|
1
1
|
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
-
export default "// See Octree.glsl for the definitions of SampleData
|
|
2
|
+
export default "// See Octree.glsl for the definitions of SampleData\n\
|
|
3
3
|
\n\
|
|
4
4
|
/* Megatexture defines (set in Scene/VoxelRenderResources.js)\n\
|
|
5
5
|
#define SAMPLE_COUNT ###\n\
|
|
6
|
-
#define NEAREST_SAMPLING\n\
|
|
7
6
|
#define PADDING\n\
|
|
8
7
|
*/\n\
|
|
9
8
|
\n\
|
|
10
|
-
uniform
|
|
11
|
-
uniform ivec2 u_megatextureTileDimensions; // number of tiles per megatexture, in two dimensions\n\
|
|
12
|
-
uniform vec2 u_megatextureVoxelSizeUv;\n\
|
|
13
|
-
uniform vec2 u_megatextureSliceSizeUv;\n\
|
|
14
|
-
uniform vec2 u_megatextureTileSizeUv;\n\
|
|
9
|
+
uniform ivec3 u_megatextureTileCounts; // number of tiles in the megatexture, along each axis\n\
|
|
15
10
|
\n\
|
|
16
|
-
|
|
17
|
-
int intMin(int a, int b) {\n\
|
|
18
|
-
return a <= b ? a : b;\n\
|
|
19
|
-
}\n\
|
|
20
|
-
int intMax(int a, int b) {\n\
|
|
21
|
-
return a >= b ? a : b;\n\
|
|
22
|
-
}\n\
|
|
23
|
-
int intClamp(int v, int minVal, int maxVal) {\n\
|
|
24
|
-
return intMin(intMax(v, minVal), maxVal);\n\
|
|
25
|
-
}\n\
|
|
26
|
-
\n\
|
|
27
|
-
vec2 index1DTo2DTexcoord(int index, ivec2 dimensions, vec2 uvScale)\n\
|
|
11
|
+
vec3 index1DTo3DTexCoord(int index)\n\
|
|
28
12
|
{\n\
|
|
29
|
-
int
|
|
30
|
-
int
|
|
31
|
-
|
|
13
|
+
int tilesPerZ = u_megatextureTileCounts.x * u_megatextureTileCounts.y;\n\
|
|
14
|
+
int iz = index / tilesPerZ;\n\
|
|
15
|
+
int remainder = index - iz * tilesPerZ;\n\
|
|
16
|
+
int iy = remainder / u_megatextureTileCounts.x;\n\
|
|
17
|
+
int ix = remainder - iy * u_megatextureTileCounts.x;\n\
|
|
18
|
+
return vec3(ix, iy, iz) / vec3(u_megatextureTileCounts);\n\
|
|
32
19
|
}\n\
|
|
33
20
|
\n\
|
|
34
|
-
/*\n\
|
|
35
|
-
How is 3D data stored in a 2D megatexture?\n\
|
|
36
|
-
\n\
|
|
37
|
-
In this example there is only one loaded tile and it has 2x2x2 voxels (8 voxels total).\n\
|
|
38
|
-
The data is sliced by Z. The data at Z = 0 is placed in texels (0,0), (0,1), (1,0), (1,1) and\n\
|
|
39
|
-
the data at Z = 1 is placed in texels (2,0), (2,1), (3,0), (3,1).\n\
|
|
40
|
-
Note that there could be empty space in the megatexture because it's a power of two.\n\
|
|
41
|
-
\n\
|
|
42
|
-
0 1 2 3\n\
|
|
43
|
-
+---+---+---+---+\n\
|
|
44
|
-
| | | | | 3\n\
|
|
45
|
-
+---+---+---+---+\n\
|
|
46
|
-
| | | | | 2\n\
|
|
47
|
-
+-------+-------+\n\
|
|
48
|
-
|010|110|011|111| 1\n\
|
|
49
|
-
|--- ---|--- ---|\n\
|
|
50
|
-
|000|100|001|101| 0\n\
|
|
51
|
-
+-------+-------+\n\
|
|
52
|
-
\n\
|
|
53
|
-
When doing linear interpolation the megatexture needs to be sampled twice: once for\n\
|
|
54
|
-
the Z slice above the voxel coordinate and once for the slice below. The two slices\n\
|
|
55
|
-
are interpolated with fract(coord.z - 0.5). For example, a Z coordinate of 1.0 is\n\
|
|
56
|
-
halfway between two Z slices so the interpolation factor is 0.5. Below is a side view\n\
|
|
57
|
-
of the 3D voxel grid with voxel coordinates on the left side.\n\
|
|
58
|
-
\n\
|
|
59
|
-
2 +---+\n\
|
|
60
|
-
|001|\n\
|
|
61
|
-
1 +-z-+\n\
|
|
62
|
-
|000|\n\
|
|
63
|
-
0 +---+\n\
|
|
64
|
-
\n\
|
|
65
|
-
When doing nearest neighbor the megatexture only needs to be sampled once at the closest Z slice.\n\
|
|
66
|
-
*/\n\
|
|
67
|
-
\n\
|
|
68
21
|
Properties getPropertiesFromMegatexture(in SampleData sampleData) {\n\
|
|
69
22
|
int tileIndex = sampleData.megatextureIndex;\n\
|
|
70
23
|
\n\
|
|
71
24
|
vec3 voxelCoord = sampleData.inputCoordinate;\n\
|
|
72
|
-
#if defined(NEAREST_SAMPLING)\n\
|
|
73
|
-
// Round to the center of the nearest voxel\n\
|
|
74
|
-
voxelCoord = floor(voxelCoord) + vec3(0.5);\n\
|
|
75
|
-
#endif\n\
|
|
76
25
|
\n\
|
|
77
|
-
//
|
|
78
|
-
|
|
79
|
-
\n\
|
|
80
|
-
// Slice location\n\
|
|
81
|
-
float slice = voxelCoord.z - 0.5;\n\
|
|
82
|
-
int sliceIndex = int(floor(slice));\n\
|
|
83
|
-
int sliceIndex0 = intClamp(sliceIndex, 0, u_inputDimensions.z - 1);\n\
|
|
84
|
-
vec2 sliceUvOffset0 = index1DTo2DTexcoord(sliceIndex0, u_megatextureSliceDimensions, u_megatextureSliceSizeUv);\n\
|
|
26
|
+
// UV coordinate of the lower corner of the tile in the megatexture\n\
|
|
27
|
+
vec3 tileUvOffset = index1DTo3DTexCoord(tileIndex);\n\
|
|
85
28
|
\n\
|
|
86
29
|
// Voxel location\n\
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
vec2 uv0 = tileUvOffset + sliceUvOffset0 + voxelUvOffset;\n\
|
|
30
|
+
vec3 tileDimensions = vec3(u_inputDimensions);\n\
|
|
31
|
+
vec3 clampedVoxelCoord = clamp(voxelCoord, vec3(0.5), tileDimensions - vec3(0.5));\n\
|
|
32
|
+
vec3 voxelUv = clampedVoxelCoord / tileDimensions / vec3(u_megatextureTileCounts);\n\
|
|
91
33
|
\n\
|
|
92
|
-
|
|
93
|
-
return getPropertiesFromMegatextureAtUv(uv0);\n\
|
|
94
|
-
#else\n\
|
|
95
|
-
float sliceLerp = fract(slice);\n\
|
|
96
|
-
int sliceIndex1 = intMin(sliceIndex + 1, u_inputDimensions.z - 1);\n\
|
|
97
|
-
vec2 sliceUvOffset1 = index1DTo2DTexcoord(sliceIndex1, u_megatextureSliceDimensions, u_megatextureSliceSizeUv);\n\
|
|
98
|
-
vec2 uv1 = tileUvOffset + sliceUvOffset1 + voxelUvOffset;\n\
|
|
99
|
-
Properties properties0 = getPropertiesFromMegatextureAtUv(uv0);\n\
|
|
100
|
-
Properties properties1 = getPropertiesFromMegatextureAtUv(uv1);\n\
|
|
101
|
-
return mixProperties(properties0, properties1, sliceLerp);\n\
|
|
102
|
-
#endif\n\
|
|
34
|
+
return getPropertiesFromMegatextureAtUv(tileUvOffset + voxelUv);\n\
|
|
103
35
|
}\n\
|
|
104
36
|
\n\
|
|
105
37
|
// Convert an array of sample datas to a final weighted properties.\n\
|