Skip to main content

Educational Python ray tracer with a modular architecture, visualization tools, example scenes, and support for shadows, reflections, refractions, and Blinn-Phong shading.

Project description

EduRay: Educational Ray Tracer in Python

Last Commit Open Issues Open PRs MIT License

PyPI package GitHub Stars GitHub Forks


Scene

Rendered image of the demo scene included in the educational notebooks series.


EduRay is an educational ray tracer implemented in Python. It is designed to be simple, readable, and modular, making it suitable for learning the fundamentals of ray tracing and computer graphics.

The project focuses on clarity rather than performance. It includes the source code of the ray tracer, visualization tools, example scenes, and educational Jupyter notebooks.


Installation and setup

You can install the package from PyPI without the notebooks as rendering and visualization software:

pip install eduray

Or clone the repository to use the educational notebooks and install the package in editable mode:

git clone https://github.com/HonzaSik/eduray.git
cd eduray
python3.13 -m venv .venv

# macOS/Linux
source .venv/bin/activate

# Windows
.venv\Scripts\activate

# Option A: Library only — for use in IDEs like PyCharm or VS Code
pip install -e .
# You need to set your interpreter to the virtual environment you just created for the editable install to work in your IDE.

# Option B: Library + Jupyter — for running educational notebooks in the browser
pip install -e ".[all]"
  • PyCharm: Settings → Project → Python Interpreter → Add Interpreter → Add Local → Virtualenv → Existing, then select <repo>/.venv/bin/python (macOS/Linux) or <repo>\.venv\Scripts\python.exe (Windows).
  • VS Code: Cmd/Ctrl+Shift+P → Python: Select Interpreter, pick the .venv from this project.

To run the educational notebooks in your browser, start a Jupyter server in the project directory:

jupyter notebook

Or open the notebooks directly in an IDE with Jupyter support, such as VS Code or PyCharm.

Then open educational_notebooks/1_data_visualizer.ipynb to start with the first lesson. The notebooks are numbered and meant to be followed in order.

Note The project was developed and tested on Python 3.13. Requires Python 3.11 or newer.


Quick start

The smallest working example:

from eduray import *

sphere = Object(
    geometry=Sphere(),
    material=PhongMaterial()
)

scene = Scene(
    camera=PinholeCamera(),
    objects=[sphere],
    lights=[PointLight()],
)

rt = LinearRenderLoop(scene=scene)
rt.render("hello_world.png")

To try the library, open the Hello World notebook. It demonstrates how to set up a minimal scene and render an image using only a few lines of code.

jupyter notebook ./hello_world.ipynb

Educational notebooks series

A series of educational Jupyter notebooks is available in the educational_notebooks directory.

The notebooks explain selected ray tracing concepts step by step, including:

  • camera construction
  • ray-object intersections
  • shading
  • rendering
  • reflections and refractions
  • procedural texturing
  • visualization of ray tracing concepts

More detailed description of the notebooks can be found in the introduction notebook.


For those who want to experiment

  1. Click "Fork" on https://github.com/HonzaSik/eduray
  2. Clone your fork:
    git clone https://github.com/YOUR_USERNAME/eduray.git
    
  3. Continue with the editable install steps from the Installation section above.

Troubleshooting

ModuleNotFoundError: No module named 'eduray' in PyCharm or VS Code

Make sure your IDE is configured to use the .venv you created above, not the system Python:

  • PyCharm: Settings → Project → Python Interpreter → Add Interpreter → Add Local → Virtualenv → Existing, then select <repo>/.venv/bin/python (macOS/Linux) or <repo>\.venv\Scripts\python.exe (Windows).
  • VS Code: Cmd/Ctrl+Shift+P → Python: Select Interpreter, pick the .venv from this project (workspace).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eduray-0.2.0.tar.gz (67.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eduray-0.2.0-py3-none-any.whl (92.7 kB view details)

Uploaded Python 3

File details

Details for the file eduray-0.2.0.tar.gz.

File metadata

  • Download URL: eduray-0.2.0.tar.gz
  • Upload date:
  • Size: 67.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for eduray-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c8aeebf5a7a6ab27b2f114323b91e1dd7faf96002192334f12b0aa79bcc36a58
MD5 5d8a660951d2dbcca83c0ef3b3209005
BLAKE2b-256 61935e38372c4c14abf92c8482a644609fbd207cb08593660c13cbe02f306ff1

See more details on using hashes here.

File details

Details for the file eduray-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: eduray-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 92.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for eduray-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ee83a7cb1e352cc704f7111288c17003622141662f3a4f35ef93178e05d2184
MD5 6fae9c0e3c9bbf399b9a96a07beaa061
BLAKE2b-256 36d19595db120df10c6009924c1b46a76b68778a5ea60e7efe3d0af45095b4ff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page