A raytracer which uses left-hand coordinate system and in which camera looks in +Z
direction by default. Supports normal (pixel-based) and terminal-based rendering!
Features:
- Sphere primitive
- Variety of light sources (point, ambient, directional)
- Shininess
- Reflections
Visualization of the simple scene I made in GeoGebra: https://www.geogebra.org/calculator/zfexqajh
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:
-
alpha
parameter is changing duringcolor_t
arithmetic (should it?)