Languages | English | 日本語
PRayGround is a C++/CUDA library with OptiX 7 that provides you with an easy and scalable environment to have fun a interactive ray tracing on GPU. This includes wrapper libraries of OptiX 7 API, easy management system of device side data pointer in per-instance (shape, material, textures, bitmap...) basis, intuitive setup and looping functions, and easy build system via CMake that enables you to launch tons of rays by just modifying App.h/cpp, main.cpp
and adding your ray tracing code.
This project still remain a huge room to improve its readability, performance, and scalability. I'd appreciate it if you advise me any things!
1920 x 1080, 100000spp, 592.9s on NVIDIA RTX 3090
Before building the project, please be sure to check requirements and your environment, especially if the your version of the C++ compiler supports C++20.
- CUDA Toolkit (Tested : 11.1, 11.2, 11.3, 11.4)
- C++ compiler which supports C++20
- Linux (Tested : g++ 10.3.0)
- Windows (Tested : Visual Studio 2019, version 16.10.2)
- OptiX 7 and 8 (Tested : 7.3 to 8.0)
- CMake 3.0 minimum (Tested : cmake 3.16.3)
git clone https://github.com/sketchbooks99/PRayGround.git
cd PRayGround
git submodule update --init --recursive
Before a compilation, please be sure to export two environment variables CC
and CXX
. We recommend you to add them to your ~/.bashrc
file as follows so that they are automatically exported when a terminal is launched.
export CC=gcc-10
export CXX=g++-10
Next, you can build with following command. Please be sure to set OptiX_INCLUDE
in terminal command of ccmake or in the launched prompt.
cd <path/to/PRayGround>
mkdir build
cd build
ccmake .. -DOptiX_INCLUDE=<path/to/OptiX>/include
or
ccmake .. # and set OptiX_INCLUDE to the path of OptiX library include.
# You can generate a makefile with a standard step of CMake ( [C] Configure -> [G] Generate ).
make
After compiling got through, the execution file will be created in the build/bin
directory.
cd bin
./<app-name>
On Windows, a recent version of Visual Studio 2019 which supports C++20 features is required.
For configuring sources, please use cmake-gui to generate the solution files.
Building steps are as follows.
-
Start up cmake-gui.
-
Set the
<path/to/PRayGround>
for the source code location ( Where is the source code ). -
Set the
<path/to/PRayGround>/build
for the binary location ( Where to build the binaries ). -
Press
Configure
button at the bottom of the window. When a window popped up, be careful with the settings for the platform to build. You must select Visual Studio 16 2019 as the generator to use the recent features of C++, and specify the x64 for the generator platform because OptiX only supports 64-bit builds. -
Press
Finish
button and configuration will start. If errors occur while configuring, it may be due toOptiX_INCLUDE_NOTFOUND
error. If so, please setOptiX_INCLUDE
to the path of Optix library include. On Windows, OptiX include directory may be located inC:ProgramData\NVIDIA Corporation\OptiX SDK <your version>
. -
When configulation finished, press
Generate
. -
Open the
PRayGround.sln
solution file in the build directory. -
Execute
Build Solution
in the IDE. When compilation is succeeded, the execution file will be created in thebuild/bin/Debug or Release
directory. You also can run the ray tracer by setting the<app-name>
project as start up project.
Not supported.
You can create your custom application by just adding new directory in apps/
and modifying App.h/.cpp
, main.cpp
and CMakeLists.txt
.
The procedure is as follows:
- Copy and paste
apps/empty_app
directory toapps/
and rename the directory. - Modifying the app-name in
CMakeLists.txt
inside the app directory.
PRAYGROUND_add_executalbe(empty_app target_name # empty_app -> <your-app-name>
main.cpp
app.cpp
app.h
)
target_compile_definitions(
${target_name}
PRIVATE
APP_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
)
target_link_libraries(${target_name} ${CUDA_LIBRARIES})
- Add line of
add_subdirectory(<your-app-name>)
inPRayGround/CMakeLists.txt
.
# Executable apps
add_subdirectory(apps/empty_app)
add_subdirectory(apps/<your-app-name>) # Add this line
- Enjoy coding!
- Build your application using CMake.
Warning
The 3D models and textures used in the examples are not contained in this repository.
Single GAS | Path tracing | Obj scene |
---|---|---|
Ray Tracing: The Next Weekend | Ray Tracing: The Rest Of Your Life | Dynamic update |
Motion blur | Denoiser (:warning: Support with OptiX 7.3~) | Spectrum |
Volume | Curves | |
- glad (MIT license) ... For OpenGL features
- GLFW (Zlib license) ... For OpenGL
- hapPLY (MIT license) ... For loading PLY mesh
- Dear ImGui (MIT license)... For easy GUI usage
- stb (MIT license)... To read/write image of PNG, JPG format
- tinyexr ... To read/write image of OpenEXR format
- tinyobjloader (MIT and ISC license) ... For loading OBJ mesh