|
| 1 | +# Simple ray tracer |
| 2 | + |
| 3 | +This is the code from Paul Graham's ANSI Common Lisp, tidied with my comments plus a few tweaks. |
| 4 | + |
| 5 | +In particular, I added the ability to move the light source. |
| 6 | + |
| 7 | +# Output |
| 8 | + |
| 9 | +This is the basic output with the world as per the book, at 4x scale to be more impressive. |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +Emphasis of this code is on simplicity and correctness, not speed. |
| 14 | + |
| 15 | +Note though, [Ray tracing](https://en.wikipedia.org/wiki/Ray_tracing_(graphics)) in general is very amenable to parallelisation because the calculation |
| 16 | +of each ray can be considered computationally distinct. This code is many thousands of times slower than it could be done on your GPU. |
| 17 | + |
| 18 | +We can pan the eye position left which is quite trivial: |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | +But moving the light source is quite nice (this is the bit I added to the code in the book). |
| 26 | + |
| 27 | +Here the light source is moved left by log scale increments: |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | +Personal next steps? I plan to check back in on this code after reading |
| 35 | +[7 Concurrency Models](https://pragprog.com/book/pb7con/seven-concurrency-models-in-seven-weeks). |
| 36 | + |
| 37 | +--- |
| 38 | +#### Running the code |
| 39 | + |
| 40 | +Obviously there's no system definition (`.asd` file) here, all I was doing is evaluating |
| 41 | +each source file directly into a REPL. Be warned it does take about a minute on my 2015 macbook |
| 42 | +pro to generate an image even at the smallest size. |
| 43 | + |
| 44 | +There is more info in comments in the source files. |
0 commit comments