A hobby-level raytracer written from-scratch, featuring:
- a sphere primitive
- a variety of light sources (point, ambient, directional)
- shininess
- reflections
Terminal-based rendering (just for fun):
Implementation details:
- left-hand coordinate system
- camera looks in
+Zdirection - a GeoGebra scene I used to debug this (proved very effective!)
clone https://github.com/fahlerile/raytracer-from-scratch
cd raytracer-from-scratch
mkdir build
cd build
cmake ..
make
cd bin
./raytracer--help- show help message--terminal-rendering- use terminal rendering
To configure your scene, you should change scene.json in bin/ directory. All available primitives and light sources are listed in Sphere and Light header files. In your JSON file you should put the same arguments as requested in these primitives/light sources constructors.
From Light/DirectionalLight/DirectionalLight.hpp
DirectionalLight(double intensity, color_t color, vec3d direction);That means if you want your directional light to be white, 100% intense and to "look" in +Z direction, you should put this in your scene file (to be more precise, in light_sources section):
{
"type": "DirectionalLight",
"intensity": 1,
"color": [255, 255, 255, 255],
"direction": [0, 0, 1]
}New features:
- Add other primitives
- Planes
- Mathematical functions
- Cylinder
- Cone
- Torus
- Polygon
- Camera transform (camera matrix)
- Camera configuration in
scene.json - Real-time rendering, camera movement
Potential bug causes:
-
alphaparameter is changing duringcolor_tarithmetic (should it?)

