Skip to content

A ray tracing engine developed in C++ that renders realistic 3D scenes.

License

Notifications You must be signed in to change notification settings

mirzaim/ray-tracing-renderer

Repository files navigation

Ray Tracing Renderer

This project is a ray tracing engine developed from scratch in C++ without any external dependencies. It focuses on rendering scenes with realistic lighting and reflections, using core principles of ray tracing. The renderer supports various materials and recursive reflections, showcasing how basic geometric shapes like spheres can be accurately rendered in 3D space.

ray tracing render output

Overview

This ray tracer implements key features including:

  • Ray-sphere intersections
  • Recursive reflections and refractions for realistic lighting effects
  • Support for various materials like diffuse (Lambertian), metal, and dielectric (transparent)
  • Anti-aliasing for smoother image quality
  • Multi-threaded rendering using OpenMP (available in the openmp-support branch)

It was designed to explore the fundamentals of ray tracing, with additional optimizations such as OpenMP for faster performance.

Installation

  1. Clone the repository:

    git clone https://github.com/mirzaim/ray-tracing-renderer.git
    cd ray-tracing
  2. Create a build folder for the compiled output:

    mkdir build
  3. Use the provided Makefile to compile the project:

    make

For OpenMP support, switch to the openmp-support branch and compile using the same process.

Usage

Run the ray tracer with the default scene:

./build/main > image.ppm

For a high-quality scene (this takes much longer and uses OpenMP for faster performance):

./build/main 1 > image.ppm

Open the image.ppm file with an image viewer to see the rendered result.

Useful Resources

During the development of this project, I found several resources helpful in understanding ray tracing concepts and improving the implementation. The following is a list of materials I used:

  1. Ray Tracing in One Weekend
  2. The Ray Tracer Challenge
  3. Computer Graphics from Scratch