Skip to content

Latest commit

 

History

History
32 lines (16 loc) · 1.67 KB

README.md

File metadata and controls

32 lines (16 loc) · 1.67 KB

python-raytracer

This project, built from the ground up using TDD, was a great way to learn more about the mathematics that goes into building a basic raytracer. It was a good opportunity to learn more about matrices and transformations, which are essential to the implementation.

I used a book called The Ray Tracer Challenge as a guide - The book describes the tests you need to write, and then it's up to the reader to build an appropriate implementation to ensure the tests pass. By providing the material in this manner, the book is fully language-agnostic (There's not a single line of real code provided!)

Being written in pure Python, the raytracer is inevitably slow, due to the way that Python handles arithmetic operations. This could be improved significantly by swapping out CPython for a JIT implementation, such as PyPy - Although I haven't been able to test this due to Apple Sillicon compatibility issues.

Screenshots

A basic shaded sphere with coloured surface, displaying ambient, specular and diffuse lighting from a point light.

Three shaded spheres, translated along the x-axis, with unique colours.

A demonstration of multiple coloured point lights, with correct blending of colours.

A basic scene with shadows.

Two spheres on a plane, with translated stripe patterns.