I like the walls made of spheres! The real Cornell box is about 2 feet cubed IIRC... that would make the units of this scene file something close to centimeters... which would mean the walls are spheres with a diameter of about 1.2 miles.<p>Last time I saw the box in person, I made sure to leave some fingerprints. :P<p>> Realistic Ray Tracing, by Peter Shirley
> Almost 100% of smallpt is derived from this book.<p>FWIW, Peter Shirley distilled all the fun parts of Realistic Ray Tracing into an easy quick e-book available for $3, or free with the trial. "Ray Tracing in One Weekend."<p><a href="https://www.amazon.com/gp/product/B01B5AODD8/" rel="nofollow">https://www.amazon.com/gp/product/B01B5AODD8/</a><p>Blog post about it w/ more code & lots of resources: <a href="http://in1weekend.blogspot.com/2016/01/ray-tracing-in-one-weekend.html" rel="nofollow">http://in1weekend.blogspot.com/2016/01/ray-tracing-in-one-we...</a>
I don't understand the fascination with writing/presenting the code with as few lines as possible. I'd be just as impressed if they said the code was 120 lines and formatted so it was just a bit more pleasant to read.
Interestingly enough, this code is replicated in Scala Native as an example for use of the language superset[1].<p>[1] <a href="https://github.com/scala-native/scala-native-example/blob/master/src/main/scala/smallpt.scala" rel="nofollow">https://github.com/scala-native/scala-native-example/blob/ma...</a>
<p><pre><code> FILE *f = fopen("image.ppm", "w"); // Write image to PPM file.
</code></pre>
Useless comment. Could've used that space for error checking.
This a good example of the kind of computational tasks that have me staying on the top of the line of the latest generation of intel's desktop chips, and overclock them when I'm running compute intensive stuff.<p>If I want to try out something new like this and play around with it, I want it to be snappy.<p>I am vehemently opposed to the idea that PC's are "fast enough" -- more speed, less waiting!<p>The only compromise I make is avoiding the extreme versions of their chips, as they can almost $1,000 more. But in the future I might change my mind on that.<p>Time is the one thing you can't buy more of.
Very cool with small code pieces that does a lot. I was a big fan of the Amiga Boot sector intro's back in the 80-90s where the programmers had to make entertaining pieces of digital art where compiled code, music, and graphics all had to fit inside 1 KB boot sector of a 3.5" floppy disks. Here are some examples <a href="https://www.youtube.com/watch?v=GPTkTobvsaw&list=PLDAE2D6D92098FF88" rel="nofollow">https://www.youtube.com/watch?v=GPTkTobvsaw&list=PLDAE2D6D92...</a> . Thanks for sharing! :)
I personally wish the code was just written cleanly and idiomatically. I wouldn't mind "300 lines of simple, idiomatic C++". What's the use of making code dense if you're going to reformat it anyway?<p>(I say this in contrast to something which was explicitly "code golfed", which this code seems not to be.)
Looks like it would make a nice glsl/WebGL fragment shader (might be even shorter as the vector operations are predefined). Can't see one listed on the page, but then it's mostly from a few years back.
Great work and thanks for sharing the source! I love when I can see the output from someone's program, get the source code, compile it myself and then get the same results! :)
> 99 lines of 72-column (or less) open source C++ code<p>> #include <math.h><p>> #include <stdlib.h><p>> #include <stdio.h><p>After g++ -E smallpt.cpp, how many lines is it? :0