GitPedia

Python Raytracer

A basic Ray Tracer that exploits numpy arrays and functions to work reasonably fast.

From rafael-fuente·Updated June 10, 2026·View on GitHub·

A basic Ray Tracer that exploits numpy arrays and functions to work reasonably fast compared with a pure Python implementation. The code is written keeping as much readability as possible. The project is written primarily in Python, distributed under the BSD 3-Clause "New" or "Revised" License license, first published in 2020. Key topics include: 3d-engine, compile-time, fun, learning-python, python.

Python-Raytracer

A basic Ray Tracer that exploits numpy arrays and functions to work reasonably fast compared with a pure Python implementation.
The code is written keeping as much readability as possible.

animation

  • Refraction
  • Thin film interference
  • Textures
  • Monte Carlo Ray Tracing with importance sampling

Installation

Just clone or download this repo. You'll need to install two packages.

  1. Pillow is a fork of the PIL package. It provides the Image module for this application.
    to install it run the following.
pip install pillow
  1. Numpy is a scientific package that helps with mathematical functions.
pip install numpy

Examples

See the examples to see how to render the following images:

python example1.py

N|Solid

python example2.py

N|Solid

python example3.py

N|Solid

python example4.py

N|Solid

python example_cornell_box.py

N|Solid

Some animations:
https://www.youtube.com/watch?v=vt9vAcZQT4A

A basic version of this raytracer can be found here:
https://www.excamera.com/sphinx/article-ray.html

A C++ version of this raytracer can be found here:
https://github.com/rafael-fuente/sightpy-weekend-raytracer

Contributors

Showing top 2 contributors by commit count.

View all contributors on GitHub →

This article is auto-generated from rafael-fuente/Python-Raytracer via the GitHub API.Last fetched: 6/17/2026