Skip to content

Ray Tracing in One Weekend (RTOW) in Cuda with a GLFW live render display

License

Notifications You must be signed in to change notification settings

gomezzz/RTOWCudaGLFW

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ray Tracing in One Weekend (RTOW) in Cuda with a GLFW live render

DISCLAIMER: This code is intended to be close to the original RTOW tutorial and thus uses neither modern C++ nor is it pretty, production-ready or anything like that.

1800x900 Render of the current default scene at 3000 samples.

The purpose of this code is to have a functional version of the RTOW code in CUDA with a live render output using GLFW. Thus, one can continue integration of more sophisticated features etc. without having to look at the generated image files all the time. If you have any ideas for improvements feel free to submit pull requests or comment.

I intentionally included my VS 2019 project files to allow a rapid start. Also, I added references in the code where each excerpt is discussed in RTOW and a bunch of comments.

The code builds on three different tutorials:

Structure

  • camera.h,hitable.h,hitable_list.h,material.h,ray.h,sphere.h,vec3.h - These files are similar to the RTOWCuda tutorial by Roger Allen
  • check_cuda.h - Used throughout the project to display potential CUDA errors
  • interop.cpp,interop.h - These are close to the tutorial by Allan MacKinnon
  • main.cpp, kernel.cu - These were modified to allow the live render display

For changing resolution, CUDA blocks / threads and the world (spheres etc.) configuration have a look at the settings section in kernel.cu

Requirements

  • CUDA>=10.2 (lower might work, not tested)
  • GLFW - This will have to be added to includes and you need to link the appropriate lib
  • glad - You will need to include your own glad.c file into the project and add the includes
  • Visual Studio 2019 - If you want to use the included VS solution file. Unfortunately, I don't have the time to create a cross-platform version using CMake right now. However, I am unaware of anything that would inhibit it.

For a great setup tutorial of GLFW and glad please refer to learnopengl.com

Execution

Once you get the solution up and running you are good to go. Note that Release mode in VS will give you much higher FPS. Still, this code is of course not particularly efficient at the moment.

I took the freedom to change the default scene for testing purposes. If everything works you should get a lower resolution version of the image at the top.

About

Ray Tracing in One Weekend (RTOW) in Cuda with a GLFW live render display

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published