Skip to content

xandergos/unity-sparse-voxel-octrees

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 

Repository files navigation

Unity Sparse Voxel Octrees

A Unity-based method of rendering voxels using Sparse Voxel Octrees as seen in Nvidia's paper: "Efficient Sparse Voxel Octrees – Analysis, Extensions, and Implementation".

Installation

Currently the only way to use the library is to download the files and compile them yourself in unity.

Quick Start

Place the SVO folder in your Unity Project. You must enable unsafe code: Project Settings > Player > Other Settings > Allow 'unsafe' Code. To get a simple octree working, create a script:

  • Create a Start method
  • In the start method, create an octree with new SVO.Octree()
  • Modify the octree however you want
  • Set the texture of a material using an octree shader with material.mainTexture = octree.Apply()

A demo with code is available here.

Screenshot

This image contains voxels from the minimum size of 2^-23 up to approximately 2^-8. At this scale there are a lot of artifacts due to floating point errors, but in practice (when working at reasonable scales) this will not happen.

image

Limitations

  • Deformations, such as vertex deformations commonly used to animate characters or other objects, are not implemented, and are not planned (If its even possible).
  • No collider support. Unlike normal meshes, there is no built-in collider for representing an Octree. Any octree-based object will need to be represented using an approximate collider. This is not a huge deal, as an approximate collider is generally the more performant approach with traditional triangle-based meshes anyways. Theoretically, an exact octree collider could be made by recreating the octree using box colliders, but this would be memory intensive and slow, and implementation would take time, so this is not planned.
  • No shadows. Someone with experience developing shaders in Unity could resolve this, but as of now I do not have the time to add them in. PRs are welcome.

About

A sparse voxel octree renderer, made for use with Unity.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published