Skip to content

A reimplementation of Ray Tracing in One Weekend by Peter Shirley in Python 3 🐍

Notifications You must be signed in to change notification settings

spoax/raytracer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Ray Tracer in Python

Final image

A reimplementation of Ray Tracing in One Weekend by Peter Shirley in Python 3 🐍.

Things to note for the Python implementation:

  • Initially each commit is an individual step, (or a chapter in Peter's book).
  • Vec3 class is a good example on operator overloading in Python, eg. left and right multiplication, different behaviour on the type of the operand. For example, you can multiple two vectors or a vector with a number.
  • After introducing antialiasing in chapter 6, it is painfully slow to run with CPython. Use of PyPy 3 is recommended, where JIT compiler shows its strength. Ray tracing is naturally very repetitive and optimization leads to impressive results compared to plain interpretation. On my machine, PyPy runs chapter 9 script in 4.38 seconds, whereas CPython runs the same script in 254.87 (!) seconds.

About

A reimplementation of Ray Tracing in One Weekend by Peter Shirley in Python 3 🐍

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages