PlenOctree Volume Rendering (supports CUDA & fragment shader backends)

Overview

PlenOctree Volume Rendering

This is a real-time PlenOctree volume renderer written in C++ using OpenGL, constituting part of the code release for:

PlenOctrees for Real Time Rendering of Neural Radiance Fields
Alex Yu, Ruilong Li, Matthew Tancik, Hao Li, Ren Ng, Angjoo Kanazawa

https://alexyu.net/plenoctrees

@inproceedings{yu2021plenoctrees,
      title={{PlenOctrees} for Real-time Rendering of Neural Radiance Fields},
      author={Alex Yu and Ruilong Li and Matthew Tancik and Hao Li and Ren Ng and Angjoo Kanazawa},
      year={2021},
      booktitle={ICCV},
}

Screenshot

The project has several repositories:

More will be released soon, we are taking a short break now.

Building

Please install a recent version of CMake https://cmake.org

Linux

mkdir build && cd build
cmake ..
make -j12
  • If you do not have CUDA-capable GPU, pass -DVOLREND_USE_CUDA=OFF after cmake .. to use fragment shader backend, which is also used for the web demo. It is slower and does not support mesh-insertion and dependent features such as lumisphere probe.

The main real-time PlenOctree rendererer volrend and a headless version volrend_headless are built. The latter requires CUDA. There is also an animation maker volrend_anim, which I used to make some of the video animations; don't worry about it unless interested.

You should be able to build the project as long as you have GLFW. On Ubuntu, you will need X-server; you can try sudo apt-get install libgl1-mesa-dev libxi-dev libxinerama-dev libxcursor-dev libxrandr-dev libgl1-mesa-dev libglu1-mesa-dev

macOS

For macOS, we assume you have the homebrew package manager, and no CUDA-capable GPU.

brew install cmake
brew install glfw
mkdir build && cd build
cmake .. -DVOLREND_USE_CUDA=OFF
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/lib; export CPLUS_INCLUDE_PATH="/usr/local/Cellar/glfw/3.3.4/include"; make -j8

Windows 10

Install Visual Studio (I am using 2019 here). Then

mkdir build && cd build
cmake .. -G"Visual Studio 16 2019"
cmake --build . --config Release
  • If you do not have CUDA-capable GPU, pass -DVOLREND_USE_CUDA=OFF after cmake .. to use fragment shader backend, which is also used for the web demo. It is slower and does not support mesh-insertion and dependent features such as lumisphere probe.

The main real-time PlenOctree rendererer volrend and a headless version volrend_headless are built. The latter requires CUDA. There is also an animation maker volrend_anim, which I used to make some of the video animations; don't worry about it unless interested.

Dependencies

  • C++17
  • OpenGL
    • any dependencies of GLFW
  • libpng-dev (only for writing image in headless mode and saving screenshot)

Optional

  • CUDA Toolkit, I tried on both 11.0 and 10.2
    • Pass -DVOLREND_USE_CUDA=OFF to disable it.

Run

./volrend <name>.npz

See --help for flags.

There is an ImGui window which exposes rendering options as well as interactive features mentioned in the paper + video. For the mesh insertion, only OBJ files optionally with vertex coloring are supported. Texturing mapping is not implemented right now. Some example meshes are in sample_obj, and a program to generate SH meshes (just for fun) is in sample_obj/sh/gen_sh.cpp. Please use meshlab to triangulate other mesh.

Keyboard + Mouse Controls (Desktop GUI)

  • Left mouse btn + drag: rotate about camera position
  • Right mouse btn + drag: rotate about origin point (can be moved)
  • Middle mouse btn + drag: pan camera
  • Shift + Left mouse btn + drag: pan camera (alt)
  • Shift + middle mouse btn + drag: pan camera AND move origin point simultaneously
  • Scroll with wheel: move forward/back in z
  • WASDQE: move; Shift + WASDQE to move faster
  • 123456: preset world_up directions, sweep through these keys if scene is using different coordinate system.
  • 0: reset the focal length to default, if you messed with it
  • Z: cycle gizmo operations translate/rotate/scale (only visible if mesh is opened in Manipulate section)
  • X: toggle gizmo space local/world (applies to mesh translation/rotation)

Lumisphere probe:

  • IJKLUO: move the lumisphere probe; Hold shift to move faster

Offscreen Rendering

The program volrend_headless allows you to perform offscreen rendering on a server.

Usage: ./volrend_headless tree.npz -i intrinsics.txt pose1 pose2... [-o out_dir]

intrinsics.txt should be a 4x4 intrinsics matrix. pose1, pose2 ... should contain 3x4 or 4x4 c2w pose matrices, or multiple matrices in a 4Nx4 format. Add -r to use OpenCV camera space instead of NeRF.

The following zip file contains intrinsics and pose files for each scene of NeRF-synthetic, https://drive.google.com/file/d/1mI4xl9FXQDm_0TidISkKCp9eyTz40stE/view?usp=sharing

Example to render out images: ./volrend_headless drums/tree.npz -i data/nerf_synthetic/drums/intrinsics.txt data/nerf_synthetic/drums/pose/* -o tree_rend/drums

The PNG writing is a huge bottleneck. Example to compute the FPS: ./volrend_headless drums/tree.npz -i data/nerf_synthetic/drums/intrinsics.txt data/nerf_synthetic/drums/pose/*

See ./volrend_headless --help for more options such as setting rendering options.

Precomputed PlenOctree Files

The full resolution tree files for NeRF-synthetic reported in the paper may be found at: https://drive.google.com/drive/folders/1DIYj-iu3TOHProJVHPIQTjHnmYf80_vC?usp=sharing

The uncompressed NeRF-synthetic files used for the web demo are here: https://drive.google.com/drive/folders/1vGXEjb3yhbClrZH1vLdl2iKtowfinWOg?usp=sharing The compression script used to turn this in to the web version is in scripts/compress_octree.py.

More to come soon.

PyTorch Extension: svox

You can find a (mostly) compatible PlenOctree library called svox, which we use to build the tree; pip install svox.

More information to be added soon.

Building the Web Demo

The backend of the web demo is built from the shader version of the C++ source using emscripten. Install emscripten per instructions here: https://emscripten.org/docs/getting_started/downloads.html

Then use

mkdir embuild && cd embuild
emcmake cmake ..
make -j12

The full website should be written to embuild/build. Some CMake scripts even write the html/css/js files. To launch it locally for previewing, you can use the make target:

make serve

Which should launch a server at http://0.0.0.0:8000/. NEW: You may load local files and OBJs by using Load Local in the navbar. Open Layers in the top right and click the camera layer to show cameras.

Comments
  • Issues with installing svox

    Issues with installing svox

    I use pip install svox to install svox. However, when I import svox in python, it raises the following warning:

    UserWarning: CUDA extension svox.csrc could not be loaded! Operations will be slow. Please do not import svox in the SVOX source directory. warn("CUDA extension svox.csrc could not be loaded! "

    Platform: ubuntu~16.04.10 Cuda Version: 10.1

    Thanks!

    opened by cititude 3
  • macOS fixes

    macOS fixes

    Hey Alex, thanks for the great work!

    Here are some fixes to make volrend work on macOS by using an older OpenGL version.

    I hope these changes are not detrimental for the compilation or performance on Win/Ubuntu.

    opened by ignacio-rocco 2
  • License for volrend?

    License for volrend?

    Hello, thank you for you and your team's work. I see the other repositories connected to the Plenoctree NeRF paper are under the BSD-2-Clause license and was wondering if there was a preferred licensing for volrend as well. Thank you!

    opened by MilesLabrador 1
  • headless rendering produces blank images

    headless rendering produces blank images

    Hi, thank you for work.

    I wanted to see if I can produce .png images. I downloaded pretrained tree, intrinsics and poses. Then I ran

    ./volrend_headless /home/hyo26751/Downloads/tree.npz -i /home/hyo26751/Downloads/drums/intrinsics.txt /home/hyo26751/Downloads/drums/pose/* -o ../
    INFO: Use NeRF camera convention
    INFO: Data format SH16
    INFO: Scale 0.445217 0.588506 0.68048943.2574615479 ms per frame
    23.1173992157 fps
    

    which produced a set of blank images. Possible mistakes I have made?

    opened by hvkwak 0
  • A little problem about the Run command ./volrend

    A little problem about the Run command ./volrend

    image

    The volrend.exe file is under build/Release after build, so there will be error if you run ./volrend directly when your current path is just build. When your current command path is under build, the correct way is cd Release first and then run ./volrend, or you can just run ./Release/volrend instead. Besides, if you have the .npz files, you can just put it under Release file, and run ./volrend name.npz. image image

    opened by Dy111111 0
  • Is there a way to use headless version w/o CUDA?

    Is there a way to use headless version w/o CUDA?

    I want to make Plenoctree streaming server because plenoctree web viewer is pretty laggy and lack of mobile support.

    So i tried to make headless version w/o CUDA, but it wont works w/o GLFW window. is there any solution?

    opened by Bananamilk452 0
  • running error in ubuntu&windows11

    running error in ubuntu&windows11

    hi sxyu, When running the code on ubuntu20.04, I encountered a cuda-related problem. I tried the 11.0 and 11.1 versions of cuda and reported the error in the figure below. But It can run normally with the same configuration on the computer of my classmate. image

    When I try to run with window11, but it automatically runs on integrated graphics card while the computer has a discrete graphics card.

    I would be grateful if you could help me out with these two issues. @sxyu

    opened by 1742483876 0
  • How to convert the cuda-based npz model to npz used in web demo ?

    How to convert the cuda-based npz model to npz used in web demo ?

    I trained nerf-sh model with chair dataset. After extraction and optimization, I got the tree_opt.npz. However, I loaded this npz with webgl viewer, I got an incorrect viewing result as follows: Screenshot from 2021-09-03 17-31-43 If I launch this npz with cuda-based volrend viewer, I get correct viewing result. Furthermore, I downloaded the uncompressed NeRF-synthetic files used for the web demo, the npz file is ok when I load with webgl viewer. So, I have a question. Is there any difference between the tree_opt.npz and you provided uncompressed npz model ? @liruilong940607 @sxyu

    opened by bruinxiong 1
Owner
Alex Yu
Researcher at UC Berkeley
Alex Yu
The mainly point on this project is show how level of my comprehend for fragment SHADER.

PS The mainly point on this project is show how level of my comprehend for fragment SHADER. This project has some issue I can't solve else. cause I st

null 2 Nov 26, 2021
A cross platform shader language with multi-threaded offline compilation or platform shader source code generation

A cross platform shader language with multi-threaded offline compilation or platform shader source code generation. Output json reflection info and c++ header with your shaders structs, fx-like techniques and compile time branch evaluation via (uber-shader) "permutations".

Alex Dixon 286 Dec 14, 2022
Shader Playground is a website for exploring shader compilers.

Shader Playground is a website for exploring shader compilers. Visit website Supported backends Compilers ANGLE Clspv DXC FXC Glslan

Tim Jones 445 Dec 30, 2022
Shader cross compiler to translate HLSL (Shader Model 4 and 5) to GLSL

XShaderCompiler ("Cross Shader Compiler") Features Cross compiles HLSL shader code (Shader Model 4 and 5) into GLSL Simple to integrate into other pro

Lukas Hermanns 345 Dec 9, 2022
IDA Debugger Module to Dynamically Synchronize Memory and Registers with third-party Backends (Tenet, Unicorn, GDB, etc.)

IDA Debug Bridge IDA Debugger Module to Dynamically Synchronize Memory and Registers with third-party Backends (Tenet, Unicorn, GDB, etc.) By synchron

null 9 Sep 5, 2022
A cross platform connection manager for V2Ray and other backends.

Qv2ray - For developers. By developers. Qv2ray is a cross-platform connection manager for V2Ray and other backends. This is the original Qv2ray projec

Shadowsocks.NET 677 Jan 7, 2023
Step-by-step guide through the abstract and complex universe of Fragment Shaders.

The Book of Shaders by Patricio Gonzalez Vivo and Jen Lowe This is a gentle step-by-step guide through the abstract and complex universe of Fragment S

Patricio Gonzalez Vivo 4.9k Jan 2, 2023
Super Volume Render of Monte Carlo Path tracing for Linux

exposure-render-for-Linux Super Volume Render of Monte Carlo Path tracing for Linux Introduction The code is a Linux distribution of exposure render.

engineer 4 Dec 11, 2022
OpenVDB - Sparse volume data structure and tools

OpenVDB AX Nano Houdini Website | Discussion Forum | Documentation OpenVDB is an open source C++ library comprising a novel hierarchical data structur

Academy Software Foundation 1.9k Jan 6, 2023
A CUDA-accelerated cloth simulation engine based on Extended Position Based Dynamics (XPBD).

Velvet Velvet is a CUDA-accelerated cloth simulation engine based on Extended Position Based Dynamics (XPBD). Why another cloth simulator? There are a

Vital Chen 39 Dec 21, 2022
GPU 3D signed distance field generator, written with DirectX 11 compute shader

GPU SDF Generator GPU 3D signed distance field generator, written with DirectX 11 compute shader Building git clone --recursive https://github.com/Air

Z Guan 30 Dec 13, 2022
Skyline's fork of yuzu's shader compiler

Skyline Shader Compiler (SSC) A fork of yuzu's shader compiler modified for Skyline's needs with all other changes being upstreamed and changes from y

Skyline 16 Dec 9, 2022
A small DLL that fixes tool's usage of the Halo 3 shader compiler.

h3-shader-compiler-fix A small DLL that fixes tool's usage of the Halo 3 shader compiler. Tool forgot to initialise the compiler before using it, so t

null 7 Jun 20, 2022
Shader languages support for VS Code

vscode-shader Description Shader languages support for VS Code HLSL - High-Level Shading Language GLSL - OpenGL Shading Language Cg - C for Graphics M

null 141 Dec 17, 2022
Command line tool for offline shader ISA inspection.

Intel Shader Analyzer Intel Shader Analyzer is a tool for offline static analysis of shaders for Intel GPU Architectures. It allows a user to compile

null 113 Jan 3, 2023
A collection of tools, libraries, and tests for Vulkan shader compilation.

Shaderc A collection of tools, libraries and tests for shader compilation. At the moment it includes: glslc, a command line compiler for GLSL/HLSL to

Google 1.4k Dec 29, 2022
Cg shader version of the HQx pixel art upscaling filter

HQx-shader Cg shader version of the HQx pixel art upscaling filter. How to use Load the preset files for the desired upscale factor in an emulator tha

Jules Blok 44 Nov 24, 2022
A C header file & shader for simulating colourblindness and checking contrast.

Colourblind A C header file & shader for simulating colourblindness and checking contrast. Make sure that your graphic design is suitable for the ~8%

Andrew Reece 23 Nov 18, 2022
GraphicsFuzz provides tools for automatically finding and simplifying bugs in graphics drivers, specifically graphics shader compilers.

GraphicsFuzz GraphicsFuzz is a set of tools for testing shader compilers GraphicsFuzz provides tools for automatically finding and simplifying bugs in

Google 516 Dec 15, 2022