Skip to content

Li0nMo0se/cuda_ray_tracer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GPU Ray Tracer

Watch the video Watch the video

Requirements

Build

CMake is used as build system.

Linux

Release mode

mkdir build
cd build
cmake ..
make

Debug mode

mkdir build_debug
cd build_debug
cmake ..
make

Windows

Additional requirements:

A wrapper for building the source code on Windows can be found in tools/build.py. This python script will invoke Ninja to build fast with MSVC and NVCC.

Release

python3 ./tools/build.py R

Debug

python3 ./tools/build.py D

Run

The executable can be found in the build directory.

Usage:

./raytracer input.scene output_directory width height nb_frames aliasing_level reflection_max_depth

  • input.scene: the input file (must have the .scene format)
  • output_directoy: the output directory in which the frames are stored (ppm format)
  • width: width of the resolution of the output frame
  • height: height of the resolution of the output frame
  • nb_frames: number of frames to record
  • aliasing level: level of aliasing by side. (i.e if aliasing level equals to 2, compute the mean of 2x2=4 pixels)
  • reflection_max_depth: the maximum depth for the reflection

Features

Translatable Geometric figures

  • Plan
  • Sphere
  • Raybox
  • Triangle

Aliasing

According to the aliasing level (supposed n here), compute the mean color of nxn subpixels of the current pixel

Reflection

The return of light. The reflection is restricted to the maximum reflection depth given as arguments.

Scenes

The raytracer reads a specific file format .scene.

A scene consists of a camera, a collection of lights and a collection of translatable and intersectable objects (geometric figures)

Sample

A scene file scenes/sample.scene describes how to write a scene file for each geometric figures, camera and lights.

Examples

Several more samples can be found in scenes/*:

  • scenes/frames: scenes are static (thus it is not needed to render more than one frame)
  • scenes/video: scenes are static (thus it is not needed to render more than one frame)

Tools

  • tools/build.py: wrapper to build on Windows. See usage above.
  • tools/ppm_to_png.sh: convert a ppm to a png (with the least compression). Usage: tools/ppn_to_png.sh input.ppm output.png
  • tools/ppm_to_video.sh: convert a collection of ppm stored in a output folder. Usage: tools/ppm_to_video.sh output.mp4

Output

Video Rendering

Watch the video Watch the video

Frame Rendering

About

Raytracer in CUDA

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published