Convert Figma logo to code with AI

vsg-dev logoVulkanSceneGraph

Vulkan & C++17 based Scene Graph Project

1,280
205
1,280
20

Top Related Projects

One stop solution for all Vulkan samples

10,152

C++ examples for the Vulkan graphics API

Easy to integrate Vulkan memory allocation library

Vulkan Samples

Ray tracing examples and tutorials using VK_KHR_ray_tracing

17,590

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2

Quick Overview

VulkanSceneGraph (VSG) is a modern, high-performance scene graph library built on top of Vulkan. It provides a robust framework for creating 3D graphics applications and games, offering an intuitive API that simplifies Vulkan development while maintaining its performance benefits.

Pros

  • High performance due to Vulkan backend
  • Modern C++ design with strong type safety
  • Cross-platform support (Windows, Linux, macOS, Android, iOS)
  • Extensive documentation and examples

Cons

  • Steeper learning curve compared to OpenGL-based scene graphs
  • Requires Vulkan-capable hardware
  • Smaller community compared to more established graphics libraries
  • Limited built-in shaders and materials (requires more custom implementation)

Code Examples

Creating a simple window and scene:

#include <vsg/all.h>

int main()
{
    auto windowTraits = vsg::WindowTraits::create();
    auto window = vsg::Window::create(windowTraits);
    auto viewer = vsg::Viewer::create();
    viewer->addWindow(window);

    auto scene = vsg::Group::create();
    // Add objects to the scene

    viewer->assignRecordAndSubmitTaskAndPresentation({scene});
    viewer->compile();
    viewer->run();

    return 0;
}

Creating a basic geometry:

auto box = vsg::Box::create(vsg::vec3(0.0f, 0.0f, 0.0f), 1.0f);
auto boxGeometry = vsg::ShapeGeometry::create();
boxGeometry->shapes = vsg::ShapeGeometry::Shapes{box};

auto drawCommands = vsg::Commands::create();
drawCommands->addChild(boxGeometry);

scene->addChild(drawCommands);

Setting up a camera:

auto lookAt = vsg::LookAt::create(vsg::dvec3(0.0, 0.0, 10.0), vsg::dvec3(0.0, 0.0, 0.0), vsg::dvec3(0.0, 1.0, 0.0));
auto perspective = vsg::Perspective::create(60.0, static_cast<double>(window->extent2D().width) / static_cast<double>(window->extent2D().height), 0.1, 100.0);
auto camera = vsg::Camera::create(perspective, lookAt);

scene->addChild(camera);

Getting Started

  1. Install Vulkan SDK and CMake
  2. Clone the VulkanSceneGraph repository:
    git clone https://github.com/vsg-dev/VulkanSceneGraph.git
    
  3. Build the library:
    cd VulkanSceneGraph
    cmake -B build -S .
    cmake --build build
    
  4. Include the library in your project's CMakeLists.txt:
    find_package(vsg REQUIRED)
    target_link_libraries(your_target vsg::vsg)
    
  5. Start coding using the examples provided above!

Competitor Comparisons

One stop solution for all Vulkan samples

Pros of Vulkan-Samples

  • Official Khronos Group repository, ensuring high-quality and up-to-date Vulkan examples
  • Extensive collection of samples covering various Vulkan features and best practices
  • Well-documented and maintained, with regular updates and community support

Cons of Vulkan-Samples

  • Focused on individual samples rather than providing a complete scene graph framework
  • May require more setup and configuration for complex applications
  • Less abstraction, potentially leading to more verbose code for larger projects

Code Comparison

VulkanSceneGraph:

auto root = vsg::Group::create();
auto transform = vsg::MatrixTransform::create();
transform->addChild(vsg::Node::create());
root->addChild(transform);

Vulkan-Samples:

VkCommandBuffer cmd_buf = ...;
vkCmdBeginRenderPass(cmd_buf, &render_pass_begin_info, VK_SUBPASS_CONTENTS_INLINE);
vkCmdBindPipeline(cmd_buf, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
vkCmdDraw(cmd_buf, 3, 1, 0, 0);
vkCmdEndRenderPass(cmd_buf);

VulkanSceneGraph provides a higher-level abstraction for scene management, while Vulkan-Samples focuses on demonstrating low-level Vulkan API usage. VulkanSceneGraph is better suited for complex 3D applications, while Vulkan-Samples is ideal for learning Vulkan concepts and best practices.

10,152

C++ examples for the Vulkan graphics API

Pros of Vulkan

  • Extensive collection of Vulkan examples covering various techniques
  • Well-documented code with detailed explanations for each example
  • Focuses on individual Vulkan concepts, making it easier to learn specific features

Cons of Vulkan

  • Not designed as a complete scene graph or rendering engine
  • Lacks higher-level abstractions for complex scene management
  • May require more manual setup and management for larger projects

Code Comparison

VulkanSceneGraph:

auto root = vsg::Group::create();
auto transform = vsg::MatrixTransform::create();
transform->addChild(vsg::Node::create());
root->addChild(transform);

Vulkan:

VkCommandBuffer cmdBuffer = beginSingleTimeCommands();
vkCmdBeginRenderPass(cmdBuffer, &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
vkCmdBindPipeline(cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, graphicsPipeline);
vkCmdDraw(cmdBuffer, 3, 1, 0, 0);

VulkanSceneGraph provides a higher-level scene graph API, while Vulkan focuses on low-level Vulkan commands. VulkanSceneGraph simplifies scene management, while Vulkan offers more direct control over rendering operations.

Easy to integrate Vulkan memory allocation library

Pros of VulkanMemoryAllocator

  • Specialized focus on memory allocation, providing optimized memory management for Vulkan applications
  • Lightweight and easy to integrate into existing Vulkan projects
  • Extensive documentation and examples for various use cases

Cons of VulkanMemoryAllocator

  • Limited scope, focusing only on memory allocation rather than providing a full scene graph solution
  • Requires more manual setup and integration with other Vulkan components
  • Less suitable for high-level scene management and rendering abstractions

Code Comparison

VulkanMemoryAllocator:

VmaAllocator allocator;
VmaAllocatorCreateInfo allocatorInfo = {};
vmaCreateAllocator(&allocatorInfo, &allocator);

VkBufferCreateInfo bufferInfo = { /* ... */ };
VmaAllocationCreateInfo allocInfo = {};
VkBuffer buffer;
VmaAllocation allocation;
vmaCreateBuffer(allocator, &bufferInfo, &allocInfo, &buffer, &allocation, nullptr);

VulkanSceneGraph:

auto device = vsg::Device::create(window);
auto bufferInfo = vsg::BufferInfo::create();
bufferInfo->usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
bufferInfo->data = vsg::Data::create(vertices);
auto vertexBuffer = vsg::createBufferAndTransferData(device, bufferInfo, VK_SHARING_MODE_EXCLUSIVE, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);

VulkanMemoryAllocator provides fine-grained control over memory allocation, while VulkanSceneGraph offers higher-level abstractions for scene management and rendering, simplifying the overall development process for complex 3D applications.

Vulkan Samples

Pros of VulkanSamples

  • Focused on providing simple, standalone examples for learning Vulkan concepts
  • Maintained by LunarG, a key player in Vulkan development
  • Regularly updated with new Vulkan features and best practices

Cons of VulkanSamples

  • Limited to basic examples, not suitable for complex scene management
  • Lacks higher-level abstractions for easier Vulkan development
  • Not designed as a full-fledged scene graph or rendering engine

Code Comparison

VulkanSamples (basic triangle rendering):

void draw() {
    vkCmdBeginRenderPass(command_buffer, &render_pass_begin_info, VK_SUBPASS_CONTENTS_INLINE);
    vkCmdBindPipeline(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
    vkCmdDraw(command_buffer, 3, 1, 0, 0);
    vkCmdEndRenderPass(command_buffer);
}

VulkanSceneGraph (equivalent functionality):

auto commandGraph = vsg::CommandGraph::create(window);
auto camera = vsg::Camera::create(perspective, lookAt);
auto scenegraph = vsg::Group::create();
commandGraph->addChild(vsg::createRenderGraphForView(window, camera, scenegraph));
viewer->assignRecordAndSubmitTaskAndPresentation({commandGraph});

VulkanSceneGraph provides a higher-level abstraction, simplifying scene management and rendering, while VulkanSamples focuses on direct Vulkan API usage for educational purposes.

Ray tracing examples and tutorials using VK_KHR_ray_tracing

Pros of vk_raytracing_tutorial_KHR

  • Focused specifically on Vulkan ray tracing, providing in-depth examples and tutorials
  • Includes NVIDIA-specific optimizations and best practices
  • Offers a step-by-step approach to learning ray tracing in Vulkan

Cons of vk_raytracing_tutorial_KHR

  • Limited scope compared to VulkanSceneGraph's more comprehensive scene graph functionality
  • May not be as suitable for general-purpose Vulkan development
  • Less active community and fewer contributors

Code Comparison

VulkanSceneGraph:

auto camera = vsg::Camera::create(perspective, lookAt, ViewportState::create(window->extent2D()));
auto commandGraph = vsg::createCommandGraphForView(window, camera, scenegraph);
auto commandBuffer = vsg::CommandBuffer::create(device, commandPool);

vk_raytracing_tutorial_KHR:

void HelloVulkan::createBottomLevelAS()
{
  std::vector<nvvk::RaytracingBuilderKHR::Bottom> blas;
  blas.reserve(m_objModel.size());
  for(const auto& obj : m_objModel)
  {
    auto blas = objectToVkGeometryKHR(obj);
    blas.push_back({blas});
  }
  m_rtBuilder.buildBlas(blas, vk::BuildAccelerationStructureFlagBitsKHR::ePreferFastTrace);
}

The code snippets highlight the different focus areas of the two projects. VulkanSceneGraph emphasizes scene graph management and rendering setup, while vk_raytracing_tutorial_KHR concentrates on ray tracing-specific constructs like acceleration structures.

17,590

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2

Pros of Filament

  • More mature and widely adopted, with extensive documentation and examples
  • Supports multiple rendering backends (OpenGL, Vulkan, Metal)
  • Includes a powerful material system and built-in physically-based rendering (PBR)

Cons of Filament

  • Larger codebase and potentially steeper learning curve
  • Less focused on Vulkan-specific optimizations
  • May have more overhead for simple rendering tasks

Code Comparison

VulkanSceneGraph:

auto camera = vsg::Camera::create(perspective, lookAt, ViewportState::create(window->extent2D()));
auto commandGraph = vsg::createCommandGraphForView(window, camera, scenegraph);
viewer->assignRecordAndSubmitTaskAndPresentation({commandGraph});

Filament:

auto camera = engine->createCamera();
camera->setProjection(60.0f, (float)width / height, 0.1f, 100.0f);
camera->lookAt(eye, center, up);
renderer->render(view);

Both libraries provide abstractions for camera setup and rendering, but VulkanSceneGraph's API is more Vulkan-centric, while Filament offers a higher-level, more generic approach to rendering.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

VulkanSceneGraph

VulkanSceneGraph (VSG), is a modern, cross platform, high performance scene graph library built upon Vulkan graphics/compute API. The software is written in C++17, and follows the CppCoreGuidelines and FOSS Best Practices. The source code is published under the MIT License, with the exception of vulkan.h, used for Vulkan extensions, which is under Apache License 2.0.

This repository contains C++ headers and source and CMake build scripts to build the libvsg library. Additional support libraries and examples are provided in separate repositories, links to these are provided below. The software currently builds under Linux (desktops variants through to Jetson & Raspberry Pi), Windows (VisualStudio, MinGW & Cygwin), Android, and macOS & iOS (using MoltenVk).

Links to further information

The vulkanscenegraph.org website provides a detailed list of features, tutorials and reference documentation, while this repository provides the source code and build support for creating the VulkanSceneGraph library. Quick links to resources hosted on the website:

  • Features - tour of features you'll find in the VulkanSceneGraph and companion projects.
  • Screenshots - screenshots from VulkanSceneGraph examples and 3rd party libraries and applications
  • Tutorials - mulit-part tutorial that takes you from introduction to scene graphs to multi-threading and optimization.
  • Documentation - doxygen generated reference documentation and links to 3rd party learning materials
  • Discussion - Discussion forum hosted on github.
  • Services - List of companies connected to the VulkanSceneGraph project that can provide professional services

Links to companion projects that offer additional features

Hosted as part of the vsg-dev:

  • vsgXchange reading and writing of 3rd party images and 3d models and HTTP support.
  • vsgExamples tests & examples.
  • osg2vsg OpenSceneGraph integration library that enables converting of OSG to VSG scene graph and use of OpenSceneGraph loaders.
  • vsgImGui ImGui integration enabling UI in graphics window.
  • vsgQt Qt integration with VulkanSceneGraph.
  • vsgPoints 3d point cloud loading and rendering for VulkanSceneGraph with database paging support and scalability up to billions of points.
  • vsgUnity plugin for Unity that provides export to native VulkanSceneGraph binary/ascii format.
  • MyFirstVsgApplication simple standalone VSG application that can be used as a template for your own applications.
  • vsgFramework template project that uses CMake FetchContent to pull in all the main libraries associated with VulkanSceneGraph and dependencies and builds them together.

Community projects:

  • vsgSDL SDL integration with VulkanSceneGraph.
  • vsgvr OpenVR integration with VulkanSceneGraph.
  • vsgCs 3D Tiles and Cesium ion integration
  • vsgEarth osgEarth integration
  • rocky 3D Geospatial Application Engine (Vulkan / C++17 / VSG). Pelican Mapping's successor to osgEerth.

Quick Guide to building the VSG

Prerequisites:

  • Required: C++17 compliant compiler i.e. g++ 7.3 or later, Clang 6.0 or later, Visual Studio S2017 or later.
  • Required: CMake 3.7 or later.
  • Required: Vulkan 1.1 or later.
  • Optional : glslang 14.0 or later. Only required if shader compilation at runtime is needed.

The above dependency versions are known to work so they've been set as the current minimum, it may be possible to build against older versions. If you find success with older versions let us know and we can update the version info.

While you can install Vulkan and glslang development libraries and headers from 3rd party repositoriesm these may be older, so for the latest versions you can also use the VulkanSDK provided by LunarG. Your can download VulkanSDK from LunarG, unpack into a local directory and set VULKAN_SDK environment variable to the include/lib directory within it.

Command line build instructions:

To build and install the static libvsg library (.a/.lib) in source:

git clone https://github.com/vsg-dev/VulkanSceneGraph.git
cd VulkanSceneGraph
cmake .
cmake --build . -j 16 -t install

Full details on how to build the VSG (Unix/Windows/Android/macOS) can be found in the INSTALL.md file.