Skip to content

a-vinod/ray-tracer2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ray-tracer(2)

ray-tracer(2) is my second implemention of a ray tracer. My first implementation was in C but I wanted to move faster so I switched to Python. I pay for this crime in obnoxious runtimes, but premature optimization is the root of all evil.

Setup

  1. Set up virtual environment
$ python3.12 -m venv .venv
  1. Install requirements
(.venv) $ python3.12 -m pip install -r requirements.txt

Usage

Ray trace default world (defined in ray_tracer2/main.py) with default settings:

(.venv) $ python3.12 ray-tracer2.py
(.venv) $ python3.12 ray-tracer2.py --help
Ray Tracer in Python!
usage: ray-tracer2.py [-h] [-o OUTPUT_IMAGE] [-w IMAGE_WIDTH] [-a ANTI_ALIASING]

Ray Tracer in Python

options:
  -h, --help            show this help message and exit
  -o OUTPUT_IMAGE, --output-image OUTPUT_IMAGE
                        Path to the output image file
  -w IMAGE_WIDTH, --image-width IMAGE_WIDTH
                        Output image file width
  -a ANTI_ALIASING, --anti-aliasing ANTI_ALIASING
                        Anti-aliasing samples

Performance

Currently this application is single-threaded and a single process. My laptop CPU is an 11th Gen Intel i5-1145G7 @ 2.60GHz.

(.venv) $ python3.12 ray-tracer2.py -w 400 -a 100
100%|███████████████████████████████████████████████████| 9000000/9000000 [18:09<00:00, 8259.10it/s]

References

About

A ray tracer in Python.

Resources

License

Stars

Watchers

Forks

Languages