Code Monkey home page Code Monkey logo

prayground's Introduction

Languages | English | 日本語

PRayGround

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!

output.png 1920 x 1080, 100000spp, 592.9s on NVIDIA RTX 3090

💻 Requirements

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)

📥 Cloning

git clone https://github.com/sketchbooks99/PRayGround.git
cd PRayGround
git submodule update --init --recursive 

🔨 How to build

Linux

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>

Windows

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.

  1. Start up cmake-gui.

  2. Set the <path/to/PRayGround> for the source code location ( Where is the source code ).

  3. Set the <path/to/PRayGround>/build for the binary location ( Where to build the binaries ).

  4. 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.

  5. Press Finish button and configuration will start. If errors occur while configuring, it may be due to OptiX_INCLUDE_NOTFOUND error. If so, please set OptiX_INCLUDE to the path of Optix library include. On Windows, OptiX include directory may be located in C:ProgramData\NVIDIA Corporation\OptiX SDK <your version>.

  6. When configulation finished, press Generate.

  7. Open the PRayGround.sln solution file in the build directory.

  8. Execute Build Solution in the IDE. When compilation is succeeded, the execution file will be created in the build/bin/Debug or Release directory. You also can run the ray tracer by setting the <app-name> project as start up project.

Mac

Not supported.

💡 Create new application

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:

  1. Copy and paste apps/empty_app directory to apps/ and rename the directory.
  2. 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})
  1. Add line of add_subdirectory(<your-app-name>) in PRayGround/CMakeLists.txt.
# Executable apps
add_subdirectory(apps/empty_app)
add_subdirectory(apps/<your-app-name>) # Add this line
  1. Enjoy coding!
  2. Build your application using CMake.

🎨 Examples

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

External libraries

  • 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

prayground's People

Contributors

sketchbooks99 avatar

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.