A modern C++ library for reading, writing, and processing 3D Gaussian Splatting files, designed for real-time neural rendering applications.
SplatLib provides comprehensive support for various Gaussian splat formats, enabling efficient conversion, manipulation, and optimization of 3D scene data for web-based real-time rendering and neural graphics applications.
- PLY: Industry-standard uncompressed format for training, editing, and archival storage
- SOG: Compressed format optimized for web delivery (15-20× smaller than PLY)
- KSPLAT, SPZ, LCC: Additional specialized formats for different use cases
- CUDA-based high-performance processing
- GPU-accelerated SOG compression and spatial algorithms
- Support for multiple CUDA compute capabilities (7.5, 8.0, 8.9)
- Octree: Hierarchical spatial partitioning
- K-D Tree: Nearest neighbor searches
- B-Tree: Efficient data organization
- Morton Encoding: Spatial coherence optimization
- K-means clustering (CPU/GPU dual implementations)
- Spherical harmonic (SH) rotation and manipulation
- Coordinate transformations and data processing
- Level of Detail (LOD): Chunk-based organization supporting multi-resolution representations
- Data Compression: Integrated WebP codec for efficient texture compression
- Parallel Processing: Built-in thread pools and parallel algorithms
- Python Bindings: pybind11-based Python interface
SplatLib follows a modular design with core components organized into the following modules:
The library is organized into focused modules that provide specific functionality:
ply_reader.h/ply_writer.h- PLY format reading/writingsog_reader.h/sog_writer.h- SOG format reading/writingcompressed_ply_writer.h- Compressed PLY writingksplat_reader.h/spz_reader.h/lcc_reader.h- Specialized format readerscsv_writer.h- CSV format outputlod_writer.h- LOD data writing
ply.h- PLY file structure definitions (PlyHeader, PlyElement, PlyData)sog.h- SOG metadata structures (Meta, SHN, etc.)data-table.h- Generic data table structure supporting multiple column types
octree.h- Octree implementation for spatial partitioning and querieskdtree.h- K-D tree implementation for nearest neighbor searchesbtree.h- B-tree implementation for efficient data organizationkmeans.h- K-means clustering (CPU/GPU implementations)
maths.h- Basic mathematical operationsrotate-sh.h- Spherical harmonic rotation operations
transform.h- Coordinate transformation operationscombine.h- Data combination operationsmorton-order.h- Morton spatial encoding
logger.h- Logging infrastructurethreadpool.h- Thread pool implementationwebp-codec.h- WebP image encoding/decodingzip-reader.h/zip-writer.h- ZIP compression supportcrc.h- CRC checksum validation
- Mirrors the include/ directory structure with corresponding implementation files
- CUDA implementations located in files like
spatial/kmeans.cu
- Modularity: Each functional module is self-contained for easy testing and maintenance
- Zero-Copy: Prioritizes views and references to avoid unnecessary data copying
- Type Safety: Uses strong typing to reduce runtime errors
- Performance-First: GPU acceleration, parallel processing, and memory optimization
- Extensibility: Plugin-style format support makes adding new file formats straightforward
#include <splat/splat.h>
// Read a PLY file
auto data = splat::readPly("scene.ply");
// Write to compressed SOG format
splat::writeSog("scene.sog", *data);#include <splat/spatial/octree.h>
#include <splat/models/data-table.h>
// Build spatial index
auto octree = std::make_unique<splat::Octree>(data.get(), /*maxPoints=*/32, /*maxDepth=*/8);
// Query operations
// ... spatial queries using the octree#include <splat/maths/rotate-sh.h>
#include <splat/op/transform.h>
// Apply spherical harmonic rotation
Eigen::Matrix3f rotation_matrix = /* ... */;
auto rotated_sh = splat::rotateSHCoefficients(original_sh, rotation_matrix);
// Coordinate transformation
auto transformed_data = splat::transform(*data, transformation_matrix);To add support for a new file format:
-
Define the data model in
include/splat/models/- Create structures for format-specific metadata
- Define any custom data types needed
-
Implement I/O operations in
include/splat/io/- Create reader/writer header files following existing patterns
- Implement parsing/writing logic in corresponding src/ files
-
Update the main header (
include/splat/splat.h)- Add includes for new headers
- Ensure new functions are properly namespaced
-
Add format detection if needed
- Extend file type detection logic
- Add format-specific validation
When adding new spatial data structures:
-
Design the interface in
include/splat/spatial/- Follow patterns established by existing structures (Octree, KdTree)
- Consider memory layout and cache efficiency
-
Implement core algorithms in src/
- Support both CPU and GPU implementations where applicable
- Include comprehensive error handling
-
Add performance optimizations
- Vectorization for CPU operations
- GPU acceleration for compute-intensive tasks
- Memory pool management for large datasets
For new mathematical operations:
-
Create utility functions in
include/splat/maths/- Use Eigen for matrix operations
- Support both float and double precision
-
Add operation modules in
include/splat/op/- Implement composable operations
- Support batched processing
-
GPU acceleration where beneficial
- CUDA kernels for compute-intensive operations
- Memory transfer optimization
- CUDA (compute capability 7.5, 8.0, or 8.9) - GPU acceleration
- Eigen3 - Linear algebra library
- WebP - Image compression library
- nlohmann_json - JSON parsing
- Abseil - C++ utilities
- ZLIB - Compression library
- Doxygen - API documentation generation
- pybind11 - Python bindings
# Clone the repository
git clone https://github.com/merlotqi/SplatLib.git
cd SplatLib
# Create build directory
mkdir build && cd build
# Configure with CMake
cmake .. -DBUILD_SPLAT_TRANSFORM_TOOL=ON -DBUILD_PYTHON_BINDINGS=OFF
# Build
make -j$(nproc)BUILD_SPLAT_TRANSFORM_TOOL- Build command-line transform utility (default: OFF)BUILD_PYTHON_BINDINGS- Build Python bindings (default: OFF)ENABLE_CLANG_TIDY- Enable clang-tidy static analysis (default: OFF)
SplatLib/
├── include/splat/ # Public API headers
├── src/ # Implementation files
├── python/ # Python bindings
├── transform/ # Command-line tool (optional)
├── docs/ # Documentation
├── data/ # Example data
├── thirdparty/ # External dependencies
└── cmake/ # CMake utilities
- PLY Format Specification - Industry standard for Gaussian splats
- SOG Format Specification - Compressed format for web delivery
- API Documentation - Library overview and format comparison
Generate Doxygen documentation:
cd build && make doc
# Open docs/html/index.htmlSee CONTRIBUTING.md for detailed contribution guidelines.
Licensed under GNU General Public License v3.0. See LICENSE and COPYRIGHT for details.
Current version: 1.2.0
See ChangeLog for version history.