
A minimal raytracer - ingve
https://mzucker.github.io/2016/08/03/miniray.html
======
dr_zoidberg
I remember reading a _very similar_ article, a few years back (4-5 years ago).
The fact that text is "written" with spheres, some of the images, writing it
in a business card.

Edit: googling "ray tracer on a business card" gave me this link[0] which is
what I had read before.

But actually _reading_ (and not skimming) the submitted link, gave me this
paragraph:

> Sometime around September 2009, I posted a version of my program to the now-
> defunct ompf.org (whose demise is lamented here among other places), a web
> forum dedicated to the real-time raytracing community.

So that's why it sounded so familiar. Oh and the "spher-y" text was just the
first image, which is also cited in the other post from 2013 that google
found.

~~~
gens
Since you didn't give a link, is it this one ?

[http://fabiensanglard.net/rayTracing_back_of_business_card/i...](http://fabiensanglard.net/rayTracing_back_of_business_card/index.php)

~~~
dr_zoidberg
Yes, that was the one -- I was a bit distracted and didn't notice that I
didn't include the link. Can't edit my comment now.

------
mzucker
Author here - woke up this morning and saw a big bump in site traffic which
led me back to HN -- nice to see folks are reading! Happy to answer any
questions here or in the Disqus comments on my blog.

------
iamleppert
Raytracers are really cool! On the other side of the (not so minimal or
efficient spectrum) I made my own javascript-based raytracer using canvas and
webworkers:

[https://github.com/jleppert/raytracing.js](https://github.com/jleppert/raytracing.js)

It was based off the excellent introduction Ray Tracing in One Weekend
([http://in1weekend.blogspot.com/2016/01/ray-tracing-in-one-
we...](http://in1weekend.blogspot.com/2016/01/ray-tracing-in-one-
weekend.html)).

------
SixSigma
While it is nothing to do with obfuscation, I can recommend Peter Shirley's
blog [http://psgraphics.blogspot.com/](http://psgraphics.blogspot.com/)

and the "Build a renderer in a weekend"

[http://in1weekend.blogspot.com/2016/01/ray-tracing-in-one-
we...](http://in1weekend.blogspot.com/2016/01/ray-tracing-in-one-weekend.html)

I've recently been making a Julia version from the C++ source code

[https://github.com/lawless-m/Jender](https://github.com/lawless-m/Jender)

~~~
solidangle
I can also recommend the more in-depth, Academy Award winning, book
"Physically Based Rendering: From Theory to Implementation" [1] by Matt Pharr
and Greg Humphreys (and Wenzel Jakob for the soon-to-be-released third
edition). The book has nearly 1200 pages though so, unlike Shirley's book, you
probably won't be able to read it in a single weekend. It covers both the
theory and the implementation of rendering techniques which are close to the
state of the art and it provides many pointers to interesting papers.

[1] [http://pbrt.org/](http://pbrt.org/)

~~~
herbstein
I have a question about this book. How are you supposed to follow along with
it? Peter Shirley's book encourages the reader to program the renderer along
with the explanations. It doesn't seem like that is possible with PBRT, but I
might be misunderstanding something.

~~~
sclangdon
PBRT is big because it is written using literate programming and therefore
includes (almost[1]) the entire source code for the ray tracer in print, which
arguably makes it easier to follow than other books on the topic.

The PBRT ray tracer is also a production quality ray tracer and uses many
advanced techniques you won't find hobby ray tracers, such as differential
geometry, which naturally increases it's size.

[1] Some utility classes are left out.

------
sean-duffy
Must admit, when I first saw the url I started wondering how on earth Mark
Zuckerberg has the time to be writing raytracers. Made more sense when I
scrolled to the bottom.

~~~
blacksmythe
Also:

    
    
      >> Once I made a robot to play video games for me.

~~~
kristianp
This is the link

[https://www.youtube.com/watch?v=-AP0de3yZTs](https://www.youtube.com/watch?v=-AP0de3yZTs)

------
fizixer
Can someone comment on the appeal or utility of a raytracer when path-tracing
produces infinitely better results in offline, and real-time path-tracing has
started to appear (and will likely be mainstream in a matter of years)?

Also, a path tracer in 100 lines of C++:
[http://www.kevinbeason.com/smallpt/](http://www.kevinbeason.com/smallpt/)

~~~
apeddle
I'm no graphics programmer but I was under the impression path-tracing is a
subset of ray tracing that came out of this paper:
[http://artis.inrialpes.fr/Enseignement/TRSA/CookDistributed8...](http://artis.inrialpes.fr/Enseignement/TRSA/CookDistributed84.pdf)

Is this not correct?

~~~
ykl
Distribution ray tracing is not exactly pathtracing. Proper physically correct
pathtracing was formulated by James Kajiya in this paper:

[http://www.cse.chalmers.se/edu/year/2011/course/TDA361/2007/...](http://www.cse.chalmers.se/edu/year/2011/course/TDA361/2007/rend_eq.pdf)

------
erichocean
If you're interested in a non-minimal, production-quality, blazingly fast
Apache 2-licensed raytracer, you could do worse than Intel's Embree project:
[https://embree.github.io](https://embree.github.io)

~~~
yuriks
Worth noting that Embree is a ray tracer in a different sense of the word:
It's a library to accelerate the tracing of rays _only_. All other behavior
(such as light transport, materials, etc.) is left to the user. They do have
an example renderer implemented in it though.

As for open source path tracing _renderers_ , some well known ones are:

    
    
      - LuxRender: http://www.luxrender.net/
      - Mitsuba: https://www.mitsuba-renderer.org/
      - Tungsten: https://github.com/tunabrain/tungsten (uses Embree)

------
ericjang
I highly recommend checking out the winning entry of the 2016 ShaderToy size
coding competition - they implement a full raytracer in 584 chars
[https://www.shadertoy.com/view/4td3zr](https://www.shadertoy.com/view/4td3zr)

~~~
jlarocco
That's an apple and orange comparison. Not that it isn't impressive in it's
own way, but having a huge library of built in vector math and graphics
primitives makes it a lot easier than doing it in a language like C.

------
ythl
That moment you add a few bytes to your char array to make your program leet.

------
6DM
A few months back was the first time I've ever endeavored on making code
smaller regardless of readability. It's for the home page of my website, it
took hours to get it under 1 mb, but it felt very rewarding.

This is when I came across my second lesson, mentioned in this article, it
doesn't render fast. In my case even though all the assets are downloaded,
it's still too heavy.

Either way, when you get time to work on this type of stuff it can be pretty
fun.

------
firefoxd
Ok i will say it since no one else is saying it. Why do C programmers keep
writing one letter variables?

We have hard drives with terabytes of storage, and making descriptive variable
names do not increase the file size of the binary by the way.

So if your program is 1kB because you shaved the white space and made it
illegible, don't boast. Instead, shame on you.

It is still an impressive piece by the way, and i would have been fine with it
if it was a few tens of kilobytes.

~~~
edwinjm
It was a submission for IOCCC, you know, the International Obfuscated C Code
Contest.

