Note: I built a similar engine in C++ with more functionality and vastly better performance here.
1000 x 1000 Cornell box rendered with 1500 samples per pixel
- Monte Carlo Ray Tracing
- Colorable volumetric light sources
- Multiple materials:
- Diffuse (Lambertian)
- Metallic (with color and fuzziness)
- Dielectric (glass) with refractive index
- Multiple textures:
- Single color
- Checkered
- Perlin noise (marble-like)
- Image (from file)
- Multi-process rendering for multi-core CPUs
- Bounding volume hierarchy for faster rendering
- Customizable camera:
- Change position and target
- Depth of field using aperture and focus distance
- Field of view and aspect ratio
Uses only helper functions from standard Python libraries, except for loading images to the image texture with the Python Imaging Library.
Run from command prompt:
C:path_to_folder> python main.py
Optional argument for specifying the number of processes to spread the render over:
C:path_to_folder> python main.py -p 4
Can also be compiled with PyPy using Just-in-Time compiling (JIT):
C:path_to_folder> pypy3 main.py
In main.py
the camera and scene settings can be adjusted. scene.py
contains several pre-made scenes, but more can easily be added by copying one of these functions.
Created using "Ray Tracing in One Weekend Series" (v3.2.0) for C++ by Peter Shirley (Steve Hollasch, Trevor David Black).
With snippets from Arun Ravindran ArunRocks series Puray.
2000 x 864 render showing the fuzziness parameter from 0 to 1 (left to right)
1600 x 1080 render showing three materials: metal, diffusive and dielectric
1000 x 1000 render showing of a sphere with an Earth image texture applied
1000 x 1000 render showing a marble-like material generated with Perlin noise