Skip to content

A simple Ray Tracer with basic geometry, lighting, reflection, and cubemap.

Notifications You must be signed in to change notification settings

DharshanV/Ray-Tracing

Repository files navigation

Ray Tracing

A simple Ray Tracer with basic geometry, lighting, reflection, cubemap, and supersampling.

I also wrote a book, that covers building a ray tracer from scratch. I walk through step by step on what all the code means and how they work. The book can be found be found above, or the link here.

How to run

The project comes with a tasks.json. So pressing Ctrl + Shift + b, should compile the program and create a exectuable "renderMain".

Without using the tasks.json. We can compile using g++.

In the root folder, type the commands:

mkdir build
cd build
cmake ..
make

This will also create a exectuable "render" inside the build folder.

To run the exectuable, expected arugments are:

./build/render width height fileName OR

./build/render width height splitCount fileName

What I learned

  • Ray Intersections with sphere and plane.
    • Vector operations: dot product and cross products.
    • Usefulness of normal vectors. Such as shadows and lightings
  • Getting pixel color value of cubemap from normal vector direction
  • Going form pixel coor (u,v) to view direction from camera (x,y,z)
  • Multithreading
    • Breaking down screen into different parts for parallel ray tracing

What can be improved

  • Biggest improvment is to implement path tracing
  • Putting scene data (triangles) into spatial data structure (Octree)

All Rendering

Output sample

About

A simple Ray Tracer with basic geometry, lighting, reflection, and cubemap.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages