ray tracer written in pure c++, which generates and renders simple three-dimensional objects. as this project is pretty hefty, myself and Darius Desta have created thorough documentation for you to read. enjoy some renders!
in this section, I'll be going over the must know mathematical concepts that one must grasp to understand the functionality of this ray tracer.
Three-dimensional (3D) vectors are mathematical entities used to represent quantities that have both magnitude and direction in three-dimensional space. They are fundamental in ray tracing, in a 3D space, objects, positions, directions, and movements are defined using coordinates and vectors. Three-dimensional vectors are used to represent points in space, directions of rays, positions of lights, positions of objects, and more.
The dot product, also known as the scalar product, is an operation that takes two 3D vectors and produces a scalar (single numerical value) as its result. The dot product is used to determine the similarity or alignment of two vectors and provides information about the angle between them. Here's how to calculate the dot product of two 3D vectors, typically denoted as A and B:
Given two 3D vectors:
The dot product
The cross product, also known as the vector product, is an operation that takes two 3D vectors and produces a third vector as its result. This new vector is orthogonal (perpendicular) to both of the original vectors and provides valuable geometric information about their relationship. Here's how to calculate the cross product of two 3D vectors, typically denoted as A and B:
Given two 3D vectors:
Calculate the x-component of the resulting vector:
Calculate the y-component of the resulting vector:
Calculate the z-component of the resulting vector:
The normalized vector reflection equation is used to calculate the direction of a vector after it reflects off a surface. This is a common concept in physics, computer graphics, and geometry, especially when dealing with light or objects bouncing off surfaces. The equation involves three main components: an incident vector, a surface normal vector, and the reflected vector.
Incident Vector
Surface Normal Vector
Reflected Vector
The normalized vector reflection equation is typically expressed as follows: R =
in this section, I'll be going over how to get, compile, and run this ray tracer, as well as other information.
to download the project locally, copy/paste and run the following in cmd:
git clone https://github.com/oskccy/raytracer_cpp.git
ls
to view the code's render (default or your own designs), install the g++ compiler then run:
cd raytracer_cpp
ls
g++ main.cpp
depending on your designs, this command could result in a 1 - 10 minute hang. (room for contributions here lmao)
macOS/Linux:
ls
open render.ppm
Windows:
ls
start render.ppm
contributing to this project would mean the world to me. make this better, sumbit pull requests, because im not a genius. thank you so much!