Sombra is simple Raytracer written in pure Python. It's main purpose is to help understand how raytracing works with a clean code. If you are looking for an efficient Raytracer you should probably use something like C++. The equations used are taken from the Image Synthesis class at Texas A&M University taught by professor Ergun Akleman.
The main program creates a raytraced image of a scene with simple objects like spheres and planes. It's using a resolution of 288x192px by default and random jitter anti-aliasing with 4 samples per axis.
- Install all dependencies by running
python -m pip install -r requirements.txt
- Run
python -u main.py
orpython -u main.py -d
to use debug mode which will not use Anti-Aliasing (-u is for displaying print messages in the console) - The output image will be stored in the project folder
- (Optional Parameters)
python -u main.py -h
orpython -u main.py --help
will display the available commandspython -u main.py -d
orpython -u main.py --debug
for image without anti-aliasing (would be much faster)python -u main.py -m
orpython -u main.py --multi
will use multi-threadingpython -u main.py -a
orpython -u main.py --animation
will create an 8 seconds animationpython -u main.py -f
orpython -u main.py --dof
will use Depth of Field to simulate camera focus
- Sphere, Plane and Triangle objects
- Diffuse, Specular and Border shaders
- Area, Directional, Point and Spot lights
- Change Field of View of camera by changing d (distance) and scale x and y parameters of the projection view window
- Anti-Aliasing using Random Jitter
- Reflection by setting Ks value to materials
- Image textures
- Normal Maps
- Environment Sphere Map
- Animation by running a physics simulation of a moving sphere
- Multi-Threading
You can see the documentation in the wiki
To run the tests use unittest in this way python -m unittest -v tests
.
This will run every test in the "tests" module, if you add new tests make sure to
import them into the "__init__.py" file of the "tests" folder.
You will need to install
- Python
And external Python modules
- numpy
- pillow
- progress
You can install the required python modules by running:
python -m pip install -r requirements.txt
or installing them individually:
python -m pip install numpy pillow progress
Developed by Jesús Henríquez