Skip to content

A raytracer built from scratch in c++. Featuring refraction, reflection, and shadow rays, as well as point lights, spot lights, polygonal meshes, adaptive supersampling, and the bounding volume heirarchy acceleration technique.

Notifications You must be signed in to change notification settings

eversolea/Raytracer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

Raytracer

A raytracer built from scratch in c++ using the OpenCV and Eigen libraries. Featuring shadow, refraction and reflection rays (using the hall shading model) as well as point lights, spot lights, polygonal meshes and spheres, limited 2D texture map support, adaptive supersampling, and the bounding volume heirarchy acceleration technique.

Images from each step of building the raytracer: https://www.cs.drexel.edu/~ae588/index.html

Code:

  • raytracer.cpp - Main Raytracer code, runs independently
  • raytracer_post_acceleration.cpp - Early BVH implementation of raytracer (see limtations section below), runs independently

Setup for OpenCV and Eigen

Include Opencv build folder in the Include Directories and Opencv build/x64/vc15/lib folder in the library directories. The following link may help: https://learnopencv.com/code-opencv-in-visual-studio/#Step-4 Also include Eigen in the Additional Include Directories

Limitations and bugs

  • Texture maps are only enabled for spheres right now
  • Normals are being interpolated on flat surfaces of polygonal meshes, which can cause undesired effects if the flat surface is made reflective
  • Only one 3D Procedural texture has been implemented (see the "tex.type ==" if conditions in getPixelColorFromRay)
  • Cylinder entity is not fully implemented yet and is buggy
  • Bounding Volume Heirarchy is not implemented in the main raytracer program (raytracer.cpp) but instead in raytracer_post_acceleration.cpp which only includes the phong shading model and nonadaptive pixel average supersampling. I had trouble getting my BVH implementation to work well with shadow rays so I moved on without BVH for now.

Render examples:

Inspired by Pixar image Inspired by the video game Halo image image

About

A raytracer built from scratch in c++. Featuring refraction, reflection, and shadow rays, as well as point lights, spot lights, polygonal meshes, adaptive supersampling, and the bounding volume heirarchy acceleration technique.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages