Wednesday, January 27, 2016

New mini-book: Ray Tracing in One Weekend

Ray Tracing in One Weekend is a $2.99 Kindle book with an associated blog in1weekend.com where I will outline some other one weekend projects (or promote yours-- this is a fun thing to do).  It is very much book for novices to get to a cool picture ASAP.  

Here's the image it ends with:
And interesting aspect of that image is the glass balls seem to float because they may focus light but with a diffuse field that mostly cancels out.  That was news to me and it took me a while to confirm it is no bug.     Try it with a real glass sphere next time it is cloudy :)


4 comments:

Unknown said...

Please publish it on https://itch.io/ in a pdf or some other format besides kindle (i.e. epub, mobi...)!

Neto said...

Finished the book. Got the refraction broken. x_x I'll try again.

Mark said...

I really enjoyed the book, and the project.

So far, I've had a few problems. My dielectric surfaces don't work properly. I keep getting self collisions with reflection rays, resulting in black reflections. I've played around with a few things, including adding a surface_id to the hit_record, and ignoring "this" object on reflected rays. It helps a little, but there's still something odd going on.

I've have code for everything except depth-of-field, and now I've noticed that my shadows are wrong. They're much too intense, and they are acting like shadows cast from a distant light source near the horizon. This one will take me a while to figure out. :)

I've uploaded an example here: http://ibin.co/2WyObMiDl8Py

Are you interested in corrections to your code? You have a few places where it seems you've left in old versions of code, but then added new versions. The code still works, but you're assigning to a variable, and then assigning to the same variable again. For example, in your first camera code that uses vup, you assign to lower_left_corner twice.

Thanks for the fun project!

Mark said...

I've fixed the shadows. My lambertian scatter function was generating the wrong rays.

I had:
scattered = ray(rec.pos, target);
instead of:
scattered = ray(rec.pos, target - rec.pos);

It didn't matter much on small scenes where rec.pos was small, but failed badly on larger scenes.