osgVerse is a complete 3D engine solution based on OpenSceneGraph (OSG). It provides a modern rendering pipeline with PBR (Physically Based Rendering), deferred shading, real-time shadows, and comprehensive 3D functionality including physics, animation, and UI systems.
- Language: C++ (C++14/C++17)
- Build System: CMake 3.10+
- License: See LICENSE file
- Graphics API: OpenGL 2.0+, OpenGL 3.3+ Core Profile, GLES2/GLES3, WebGL 1/2
- 3D Framework: (Minimum) OpenSceneGraph 3.1.1; (Preferred) OpenSceneGraph 3.6.5
- Build System: CMake 3.10+
- Platforms: Windows (10-11), Linux (Ubuntu/Debian/Kylin/UOS), macOS, Android, WebAssembly (Emscripten)
- OpenSceneGraph (Required): Core 3D framework
- OpenGL/GLES: Graphics rendering
- SDL2: Windowing for Android/IOS/WASM
- CUDA/MUSA (Optional): GPU compute
- Bullet3 (Optional): Physics simulation
- Qt5/Qt6 (Optional): Qt-based applications
- FFmpeg (Optional): Video decoding/encoding
- Draco (Optional): Mesh compression
- libIGL (Optional): Geometry processing
- ZLMediaKit (Optional): Media streaming
The project includes many embedded third-party libraries:
- blend2d: 2D vector graphics engine
- imgui: Immediate mode GUI (with extensions like ImGuizmo, implot)
- leveldb: Key-value storage
- libhv: High-performance network library
- ktx: Khronos texture format
- ozz: Animation runtime
- recastnavigation: Navigation mesh
- marl: Task scheduler
- meshoptimizer: Mesh optimization
- Eigen: Linear algebra
- And many more (see THIRDPARTY_LICENSES.md for complete list)
osgVerse/
├── CMakeLists.txt # Root CMake configuration
├── Setup.sh / Setup.bat # Automated build scripts
├── VerseCommon.h # Main unified header
├── CODE_STYLE.md # Coding style guidelines
│
├── 3rdparty/ # Embedded third-party libraries
│ ├── blend2d/ # 2D graphics
│ ├── imgui/ # GUI library
│ ├── leveldb/ # Database
│ ├── libhv/ # Network library
│ ├── ktx/ # Texture format
│ ├── ozz/ # Animation
│ └── ... # Many more
│
├── pipeline/ # Rendering pipeline (osgVersePipeline)
│ ├── Pipeline.h/cpp # Core pipeline
│ ├── DeferredCallback.h/cpp # Deferred shading
│ ├── ShadowModule.h/cpp # Shadow rendering
│ ├── LightModule.h/cpp # Lighting system
│ ├── ShaderLibrary.h/cpp # Shader management
│ └── ...
│
├── modeling/ # Geometry processing (osgVerseModeling)
│ ├── MeshDeformer.h/cpp # Mesh deformation
│ ├── GeometryMerger.h/cpp # Geometry merging
│ ├── Math.h/cpp # Math utilities
│ └── ...
│
├── readerwriter/ # I/O utilities (osgVerseReaderWriter)
│ ├── DracoProcessor.h/cpp # Draco compression
│ ├── KTXProcessor.h/cpp # KTX textures
│ ├── GLTFReader.h/cpp # GLTF support
│ └── ...
│
├── animation/ # Animation & physics (osgVerseAnimation)
│ ├── PhysicsEngine.h/cpp # Bullet physics
│ ├── PlayerAnimation.h/cpp # Character animation
│ ├── TweenAnimation.h/cpp # Tweening
│ └── ...
│
├── ui/ # User interface (osgVerseUI)
│ ├── imgui/ # ImGui integration
│ ├── Canvas2D.h/cpp # 2D canvas
│ └── ...
│
├── script/ # Scripting (osgVerseScript)
│ └── ...
│
├── ai/ # AI & navigation (osgVerseAI)
│ └── ...
│
├── wrappers/ # Serialization wrappers (osgVerseWrappers)
│ └── ...
│
├── plugins/ # OSG plugins
│ ├── osgdb_fbx/ # FBX format
│ ├── osgdb_gltf/ # GLTF format
│ ├── osgdb_ktx/ # KTX format
│ ├── osgdb_3dgs/ # 3D Gaussian Splatting
│ ├── osgdb_ffmpeg/ # Video support
│ └── ...
│
├── tests/ # Test applications
│ ├── pipeline_test.cpp # Pipeline testing
│ ├── shadow_test.cpp # Shadow testing
│ ├── physics_basic_test.cpp # Physics testing
│ └── ...
│
├── applications/ # Main applications
│ ├── viewer/ # Basic viewer
│ ├── viewer_composite/ # Multi-view viewer
│ ├── scene_editor/ # Scene editor
│ ├── earth_explorer/ # Earth visualization
│ ├── qt_viewer/ # Qt integration
│ └── ...
│
├── wasm/ # WebAssembly specific code
├── android/ # Android specific code
├── helpers/ # Build helpers
│ ├── toolchain_builder/ # 3rdparty build tools
│ └── osg_builder/ # OSG build helpers
│
├── assets/ # Assets (models, shaders, textures)
│ ├── models/ # 3D models
│ ├── shaders/ # GLSL shaders
│ ├── skyboxes/ # HDR skyboxes
│ └── textures/ # Textures
│
├── cmake/ # CMake modules
│ ├── VerseMacros.cmake # Build macros
│ └── ...
│
└── build/ # Build output (generated)
| Module | Dependencies | Optional External |
|---|---|---|
| osgVerseDependency | - | - |
| osgVerseModeling | Dependency | libIGL |
| osgVersePipeline | Dependency, Modeling | CUDA |
| osgVerseScript | Dependency, Pipeline | - |
| osgVerseAI | Dependency, Modeling | - |
| osgVerseAnimation | Dependency, Pipeline, Modeling | Bullet, Effekseer |
| osgVerseUI | Dependency, Modeling, Script | libCEF |
| osgVerseReaderWriter | Dependency, Animation, Modeling, Pipeline | libDraco, SDL |
| osgVerseWrappers | ALL | - |
Use the provided setup scripts:
Linux/macOS:
./Setup.sh [optional_path]Windows:
Setup.bat [optional_path]The script will:
- Download OpenSceneGraph if not present
- Build third-party libraries
- Build OpenSceneGraph
- Build osgVerse
# 1. Ensure OpenSceneGraph is built and OSG_ROOT is set
export OSG_ROOT=/path/to/osg
# 2. Create build directory
mkdir build && cd build
# 3. Configure
cmake .. -DOSG_ROOT=$OSG_ROOT
# 4. Build
cmake --build . --target install --config Release| Option | Type | Default | Description |
|---|---|---|---|
OSG_ROOT |
Path | - | OpenSceneGraph root directory |
VERSE_3RDPARTY_PATH |
Path | ../Dependencies | Third-party libraries path |
VERSE_BUILD_EXAMPLES |
Bool | ON | Build examples and tests |
VERSE_BUILD_WITH_QT |
Bool | ON | Build Qt-based applications |
VERSE_BUILD_WITH_CUDA |
Bool | ON | Build CUDA-based libraries |
VERSE_STATIC_BUILD |
Bool | OFF | Static library build |
VERSE_USE_OSG_STATIC |
Bool | OFF | Use static OSG |
VERSE_SUPPORT_CPP17 |
Bool | ON | Enable C++17 features |
VERSE_BUILD_DEPRECATED_TESTS |
Bool | OFF | Build deprecated tests |
WebAssembly (Emscripten):
./Setup.sh /path/to/emsdk
# Select option 3 (WebGL 1) or 4 (WebGL 2)Android:
# Set ANDROID_SDK and ANDROID_NDK environment variables
export ANDROID_SDK=/path/to/sdk
export ANDROID_NDK=/path/to/ndk
./Setup.sh
# Select option 5 (Android)OpenGL ES:
./Setup.sh /path/to/gles/libs
# Select option 2 (GLES)See CODE_STYLE.md for full details. Key points:
- 4 spaces indent
- 8 spaces continuation indent
- 100 columns max
- Opening brace
{on new line - Spaces around operators
- Constants: UPPER_CASE (e.g.,
FOO_COUNT) - Global variables:
g_prefix (e.g.,g_globalWarming) - Static/class variables:
s_prefix - Private/protected attributes:
_prefix (e.g.,_attributeName) - Class names: UpperCamelCase (e.g.,
FooBar) - Methods/variables: lowerCamelCase (e.g.,
methodName)
- Headers:
.h - Implementation:
.cpp - Inline includes:
.inline - Public headers:
#include <module/Header.h> - Private headers:
#include "Header.h"
class FooBar
{
public:
void methodName(int arg1, bool arg2);
int sizeInBytes;
private:
int _attributeName;
static int s_globalAttribute;
enum { ONE, TWO, THREE };
};Tests are in tests/ directory and categorized as:
Regular Tests (NEW_TEST):
osgVerse_Test_Compressing- KTX/Draco compressionosgVerse_Test_Thread- Marl task schedulerosgVerse_Test_Volume_Rendering- Volume rendering methodsosgVerse_Test_Auto_LOD- Geometry merging/optimizationosgVerse_Test_Sky_Box- Skybox and atmosphere
Examples (NEW_EXAMPLE):
osgVerse_Test_Pipeline- Basic pipeline usageosgVerse_Test_Shadow- Shadow algorithmsosgVerse_Test_Forward_Pbr- Forward PBR renderingosgVerse_Test_ImGui- ImGui integrationosgVerse_Test_Earth- Earth/atmosphere/oceanosgVerse_Test_Physics_Basic- Physics simulation (requires Bullet)- And many more...
Tests are built automatically when VERSE_BUILD_EXAMPLES=ON. Run from build directory:
./bin/osgVerse_Test_Pipeline- Add source files to appropriate module's
CMakeLists.txt - Use
NEW_LIBRARY()macro for regular libraries - Use
NEW_CUDA_LIBRARY()for CUDA/MUSA libraries - Link dependencies using
TARGET_LINK_LIBRARIES()
- Create subdirectory in
plugins/ - Create
ReaderWriterXXX.cppimplementing OSG plugin interface - Add subdirectory to
plugins/CMakeLists.txt - Use
NEW_PLUGIN()macro
- Add
.cppfile totests/ - Add
NEW_TEST(exe_name source.cpp)totests/CMakeLists.txt - Or use
NEW_EXAMPLE()for example applications
Use export macros for cross-platform compatibility:
#include <wrappers/Export.h>
// For pipeline: OSGVERSE_PIPELINE_EXPORT
// For modeling: OSGVERSE_MODELING_EXPORT
// etc.The rendering pipeline uses a stage-based architecture:
Pipeline: Main orchestratorPipeline::Stage: Individual render pass- Modules (ShadowModule, LightModule, etc.) extend functionality
- Uses OSG's reference counting (
osg::ref_ptr) - Custom allocators available via
VERSE_USE_MIMALLOC
Automatic SIMD detection and compilation:
- SSE/SSE2/SSE3/SSSE3/SSE4.1/SSE4.2
- AVX/AVX2/AVX512
- Automatic flags applied via
VERSE_SIMD_FEATURES
- Buffer Overflow: Use OSG's array classes and bounds checking
- Shader Injection: Validate all shader inputs
- File I/O: Use OSG's virtual file system for sandboxing
- Network: libhv includes mbedtls for TLS support
OpenSceneGraph not found:
- Set
OSG_ROOTenvironment variable or CMake variable - Or place OSG source at
../OpenSceneGraph
GLES libraries not found:
- For GLES builds, provide path to libEGL.so and libGLESv2.so
- Use
Setup.sh <path_to_gles_libs>
CUDA/Compiler incompatibility:
- Check CUDA version against compiler version compatibility
- See CMakeLists.txt line ~353-396 for version checks
Static build issues:
- Enable
VERSE_USE_OSG_STATICto use static OSG - This forces
VERSE_STATIC_BUILDautomatically
Linux (Kylin/UOS):
- May need
VERSE_FIND_LEGACY_OPENGL=ON - May need
VERSE_USE_GLIBCXX11_ABI=OFFfor older systems
macOS:
- Uses
.sosuffix for shared libraries - May need Google Angle for GLES support
Windows:
- Use Visual Studio 2017-2022 recommended
- MSYS2/MinGW also supported
- PDB files installed with
VERSE_INSTALL_PDB_FILES=ON
- README.md: Full project documentation
- CODE_STYLE.md: Detailed coding standards
- TODO_cn.md: Development roadmap (Chinese)
- THIRDPARTY_LICENSES.md: Third-party license information
When contributing:
- Follow the code style in
CODE_STYLE.md - Test on multiple platforms if possible
- Update this file if build processes change
- Add tests for new features