Skip to content

Commit e6a8cc4

Browse files
authored
Create README.md
1 parent 4196f17 commit e6a8cc4

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
![screen shot canvas](/output-png/spheres-4.png?raw=true "")
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+
![screen shot canvas](/output-png/spheres-eye-left-10.png?raw=true "")
21+
![screen shot canvas](/output-png/spheres-eye-left-20.png?raw=true "")
22+
![screen shot canvas](/output-png/spheres-eye-left-30.png?raw=true "")
23+
![screen shot canvas](/output-png/spheres-eye-left-40.png?raw=true "")
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+
![screen shot canvas](/output-png/spheres-light-source-left-100.png?raw=true "")
30+
![screen shot canvas](/output-png/spheres-light-source-left-200.png?raw=true "")
31+
![screen shot canvas](/output-png/spheres-light-source-left-400.png?raw=true "")
32+
![screen shot canvas](/output-png/spheres-light-source-left-800.png?raw=true "")
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

Comments
 (0)