From 7e1063f4c3ec31703972a2a8de154c3ce81486bf Mon Sep 17 00:00:00 2001 From: rodri Date: Thu, 4 Jun 2020 12:26:55 +0000 Subject: change from binary (P6) to ascii (P3) format to make it work. --- bcardrt.c | 4 ++-- readme.md | 8 +++----- rgl.png | Bin 0 -> 232202 bytes 3 files changed, 5 insertions(+), 7 deletions(-) create mode 100644 rgl.png diff --git a/bcardrt.c b/bcardrt.c index a8bb86c..c7d3b66 100644 --- a/bcardrt.c +++ b/bcardrt.c @@ -93,7 +93,7 @@ main() vec cam_forward, cam_up, cam_right, c, color, delta; int x, y, r; - print("P6 512 512 255 "); + print("P3 512 512 255\n"); cam_forward = vnorm(v(-6,-16,0)); cam_up = vmul(vnorm(vcross(v(0,0,1), cam_forward)), 0.002); @@ -107,7 +107,7 @@ main() delta = vadd(vmul(vmul(cam_up, R() - 0.5), 99), vmul(vmul(cam_right, R() - 0.5), 99)); color = vadd(vmul(Sample(vadd(v(17,16,8), delta), vnorm(vadd(vmul(delta, -1), vmul(vadd(vadd(vmul(cam_up, R()+x), vmul(cam_right, R()+y)), c), 16)))), 3.5), color); } - print("%c%c%c", (int)color.x, (int)color.y, (int)color.z); + print("%d %d %d\n", (int)color.x, (int)color.y, (int)color.z); } exits(nil); } diff --git a/readme.md b/readme.md index e49d357..b596e4a 100644 --- a/readme.md +++ b/readme.md @@ -1,12 +1,10 @@ -# The Business Card Ray Tracer (Not Working) +# The Business Card Ray Tracer + +![png version of the ppm output image](rgl.png "6.out | ppm -e9t | topng") This is a more readable adaptation of Andrew "aek" Kensler's original 1337-size ray tracer written in plan 9 C. -Sadly it doesn't work yet. I'll have to go through it more thoroughly -to find out the quirkyness that makes it generate a smaller, wrong -file. - You can read an updated version of his [here](http://eastfarthing.com/blog/2016-01-12-card/). diff --git a/rgl.png b/rgl.png new file mode 100644 index 0000000..5c3db4e Binary files /dev/null and b/rgl.png differ -- cgit v1.2.3