/KiRaRay

KiRaRay is a simple interactive ray-tracing renderer using OptiX.

Primary LanguageC++The UnlicenseUnlicense

KiRaRay

KiRaRay is a simple interactive ray-tracing renderer using optix.

Features

Working in progress (?) project
This toy renderer is purposed for learning and only with limited features.

  • GPU path tracing (megakernel/wavefront).
  • GPU volumetric rendering (wavefront).
  • Spectral or tristimulus (RGB) rendering.
  • Other distributed effects like DoF and motion blur.
  • Post processing passes (e.g. denoising).
  • Single/multi-level scene graph with animation support.
  • Interactive editing scene components with simple UI.

Build and run

Windows (MSVC, C++17) Build

Requirements

  • OptiX 7.5+ and CUDA 12.5+.
  • CUDA Compute Capability 6+ (Pascal+, Turing+ is better).
  • Vulkan SDK 1.3+.

This project is developed with on Windows (MSVC). It cannot compile on Linux.

KiRaRay has bumped the required CUDA version to 12.5 for newer libcu++ features. The most recent legacy version on CUDA 11.4 is at the cu114 branch.

KiRaRay now uses Vulkan for interoperability with CUDA. If Vulkan is not desired, check the legacy-GL branch that instead depends on OpenGL.

Cloning the repository

KiRaRay uses thirdparty dependencies as submodules so fetch them recursively when cloning:

git clone --recursive https://github.com/cuteday/KiRaRay.git

Building

This project uses cmake to build, make sure CUDA is installed and added to PATH. Several optional variables are available for building configuration.

Variable Default Description
OptiX_INSTALL_DIR auto-detect When auto-detection failed to find the correct OptiX path, this variable needs to be manually specified to point to the OptiX installation.
KRR_RENDER_SPECTRAL ON Whether to build spectral render. If turned OFF, the RGB renderer is build.
KRR_PYTHON_PATH auto-detect Manually specify this to enable Python binding for a specific version of Python.

Running

Specify the json configuration file as command line argument to start the renderer, as the example below. Check the example configurations for some test scenes, showcasing core features like volumetric rendering, animated scenes and motion blur.

build/src/kiraray.exe common/configs/example_cbox.json

The two necessary entries in the configuration are model (specifying the relative path to the scene file) and passes (describing the render pipeline). Once compiled, directly run kiraray without specifying configuration (this example configuration will be used) to get a feel for this toy renderer.

Usage

Camera controlling. Dragging LeftMouse for orbiting, dragging Scroll or Shift+LeftMouse for panning. Scroll for zooming in/out.

Python binding. Several simple interfaces are exposed to python scripting via pybind11, including a OptiX denoiser wrapper for denoising NumPy or PyTorch tensors, see scripts for details.

Known Build Issues

  • In CUDA 12.5 there exist some CUDA-only expressions in thrust headers. If you use CUDA 12.5, you may consider disable the thrust routines in host code (as done in this commit) or update to 12.6.
  • In CUDA 12.6 there is a compile error in NVTX related code referenced by thrust (MemoryBarrier undefined). While I do not know why, I temporarily disabled NVTX as a workaround by defining the NVTX_DISABLE macro.

Galleries

Additional Information

Writing new render passes.

It is possible to write your own render pass, see the examples here. Check bindless render pass (rasterization) or the post-processing passes for more working examples.

Scene loading

Kiraray provided limited support for importing scenes like OBJ, glTF2 using Assimp. Animations in glTF2 models could be correctly imported, but skeleton animation is not yet supported. pbrt-parser is used to import pbrt-v3 scenes (get some here, modify the file url to download the pbrt-v3 format models).

Epilogue

Be happy today!

Although the main purpose of this project is to let me (a beginner) learn c++ and optix, I really wish to add more features and make it a fully-functional renderer with support for both ray-tracing and rasterization based techniques, combined via vulkan-cuda interopration. However, it may be a long process and I don't know if I will continue to do it. Since in reality i am so lazy, trying to sleep as more as possible (*/ω\*).

Credits