Giter Club home page Giter Club logo

unity-sparse-voxel-octrees's Introduction

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.

unity-sparse-voxel-octrees's People

Contributors

xandergos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

unity-sparse-voxel-octrees's Issues

Periodic clipping errors in tiled terrain.

Steps to reproduce:

  • Create several tiled Octrees with continuous terrain for data.
  • Align camera roughly with intersection of two Octrees
  • There is a chance that at the intersection neither Octree will be rendered.

The behavior is very inconsistent and is NOT solved by making the Octrees slightly larger as if to close a gap between the tiles. The inconsistency is reminiscent of previous bugs that were due to floating point rounding errors. The issue becomes less common the closer to the terrain you are.

Solution:

Unknown

image
image

Maximum Octree size is just above 4GB

Internally, pointers for Octree data are stored with 2 bits for the type, and 30 for other data. With pointers, those 30 bits means that anything stored outside of index 2^30-1 (4gb out) cannot be described with a pointer. Solving this problem would almost certainly lower performance or increase memory usage significantly, so it is unlikely this will ever be fixed, If this issue is encountered, it can be fixed my splitting up the model.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.