pyRT - The Python Raytracer
PyRT (pronounced pirate) is a raytracer/image generator for Python 3.5. This project is mainly done with the following in mind:
- Ray Tracing in the Jupyter Notebook
- Teaching ray tracing
- Exploring ray tracing concepts for geo data using Python.
- Rendering geo data, including large point clouds.
- Implementing new algorithms for rendering large 3D city models.
- Creating 3D-Maps from OpenStreetMap data
- Server-side rendering / cloud based rendering
PyRT is work in progress.
Installation can be done with pip. Please note that pyrt is still under heavy development and not yet meant for production. (API breaks are frequent!)
pip install pyrt
PyRT doesn’t have any dependencies. Generated images are just RGB or RGBA Arrays. To create jpg or png or other images, many demos use Pillow (PIL). So it is highly recommended to install it.
Getting Started: Try the examples
There are a lot of examples available how to use this module. This is the recommended way to get started with pyRT.
PyRT is not a 3D-modelling package. It is all about rendering from code.
In PyRT you create a scene first. Scenes consist of atleast one camera and geometry. Creation of scenes is done in an object oriented way:
from pyrt.math import * from pyrt.geometry import Triangle, Vertex from pyrt.material import PhongMaterial from pyrt.camera import PerspectiveCamera from pyrt.renderer import SimpleRT camera = PerspectiveCamera(640,480) scene = Scene() scene.add(Triangle(Vertex(position=(0, 0, 0)), Vertex(position=(0, 5, 0)), Vertex(position=(1, 5, 0)), material=PhongMaterial())) scene.setCamera(camera) engine = SimpleRT() imgdata = engine.render(scene)
PyRT has an open rendering concept, you can create your own renderer. In the example above “SimpleRT” was used, which is a minimalistic reference implementation.
Python & RayTracing, isn’t that too slow ?
No. Custom renderers can be written in C with Python bindings. This is planned in future, later versions will even support the GPU using OpenCL and/or other libraries, but at the moment the primary focus is to create a “pythonic” ray tracer.
PyRT is released under MIT. More information about this license can be found under: https://opensource.org/licenses/MIT