Edit: And at least right before I go to bed my post technically made it on the front page in the very last slot :)
I'm also glad people like my ray tracer, it was super satisfying to build, and nice to have a project that I know I put substantial effort into and can really be proud of.
Oops! Your tweet about that blog post was in my feed but I clicked your profile and saw your pinned tweet about your path tracer, so I submitted it. It is quite impressive and you did a good job writing it up.
Cool, I actually wrote that eye tracking thing back when I was in high school myself. It's cool that people still find it useful, it's definitely not up to my current quality standards, but I remember scouring the internet for something like it back then and not finding anything so I guess nobody else has put something better online since.
Ayyyy, CS488. Lovely renders, and great write-up! What learnings from this assignment/course do you feel will be the most useful in future projects (graphics or otherwise)?
P.S. I wish Trains (CS452) had something so demo-able. ;)
Half of google’s engineers are 3D graphics aficionados and can make compelling 3D scenes? There’s a scale of programmer out there: and whatever that scale is for you I put those who canary physics and computer graphics at the top.
Given your nickname that reads like you would put yourself at the top. Programming is programming. I've done 3D graphics, real time machine control, OS development, device drivers, game engines and whatever else I've come across in my professional career to date and none of it struck me as being on a different scale as other software development: it all boils down to meticulously specifying your thinking to a machine so that it can repeat what you dreamed up at a much higher speed than a human ever could.
The person that comes up with a sorting algorithm is not on some different scale than the person that makes a game or controls a machine. BTW, I'm not quite sure how to interpret the bird in your sentence.
You’re also the first in a very long time to figure out where my handle comes from. I was so intrigued by reading about the first graphics card capable of hardware transform and lighting (GeForce 256)
I built a device driver for the BBC micro for one of the earliest 2D graphics accelerators. Computer graphics and acceleration are super interesting sub-fields.
I used that exact card to do real time rendering of simulated toolpaths for a 3D mill. That was mind-blowing at the time, to have an array of voxels large enough that you could do something meaningful with it and to be able to display the results as it was running.
Fun story about the OP: We brought Tristan on as a high school intern at Shopify. I heard about how fantastic he was off and on during his internship (I’m founder and CEO).
So when I heard that he was giving a town hall talk at the end of his stint I definitely wanted to check it out.
What I walked into was a 30 minute take down of Liquid, the template language that I wrote. He systemically took every single design decision I made and dismembered it based on language design fundamentals.
That was still one of my favorite townhalls. As a self taught programmer it also send me to read about compiler and language theory for the next years to better understand all the errors of my ways. Thanks Tristan!
I remember hearing you mention my talk when I was back at Shopify a couple years later (context for others: my first internship I was in grade 11 but I went back 2 times, Shopify is great) and realizing that at many other companies giving a talk in front of everyone about design flaws in the CEO's code would be a career limiting move. But I think it's a testament to Shopify's culture that this never occurred to me in grade 11 and in fact it was instead appreciated.
Fancy seeing your comment just as I’m listening to Shane Parrish interviewing you on his podcast (to others: The Trust Battery episode, recommended). Respect & keep up the good work!
Basically, all the parsing is based on unanchored regexes. This means that Liquid will just ignore syntax that doesn't match what it expects instead of giving a syntax error.
One example is `{% if this && that %}`, which is not the correct syntax for logical and but people write in Liquid templates and see that it doesn't give an error so expect it to work, but actually it acts the same as `{% if this %}` and just ignores the invalid suffix.
Somehow my brain didn’t catch Steve and the pig coming out of the monitor in the top hero picture, and I spent most of the article thinking that first render was a photo of the authors desk.
When the Mandelbox came up I was fully expecting some sort of explanation about how they thought it was so cool the author had to 3D print it.
At this point I was like “I wonder if they are going to model their desk from earlier?” I was actually delighted and ecstatic when I figured out my mistake! Wonderful work, truly.
Yah PBRT was my most important resource for completing this project, way more important than anything I learned in course lectures.
I read it cover to cover before doing much, but then made sure I wrote things how I wanted without referencing the book except for a few bits of formula-heavy code I mention in the credits.
Definitely the best technical book I've ever read.
Have you tried reading it? Because PBRT is by far one of the best programming-oriented books I've read.
The literate programming style used works very well, making it easy to follow the code as the authors works it out and how it connects with the math or more abstract ideas.
Of course, it's not light reading so reading it in bed might indeed be sleep inducing. But that's hardly something you can hold against it.
I used to read programming books cover to cover 25 years ago when I was in High School/College. I don't do it so much these days, the books aren't as useful and I know too much so most of it ends up being redundant now.
If you're learning something new you can consume voraciously.
I'm just wondering how people retain the content? I've read a lot of books over the last few years to learn AI/programming ranging from Sutton/Barto's Reinforcement Learning to Scott Meyer's Effective C++ series, and so much of it ends up flying away from my brain.
I'm like this. I find topics fascinating, but I don't have good memory retention. I find that I allow the subjects to influence me rather than creating a catalog of stuff to reference in my brain.
Agreed. I let the author’s brain temporarily take over mine by thinking the words of the book for so long. And, instead of copying the material to my brain, it becomes more of an index. I know these ideas exist, can be referenced, and roughly where to find them if necessary.
You just have to actually use what you read/learn to retain it. But that's common in all fields, not just software. It can be fun to read things without plans to retain/use the information, because that is a skill in its own right: devouring and soaking up knowledge.
I did a ray tracing based project in high school and can also confirm that PBRT is awesome. Gets the point across really well and the authors are (was) active on the mailing list.
I'm not sure if this was done in all the years, but one of the interesting (and slightly unfair) aspects of the final project was that you were not only graded on the quality of the final render, but also how closely you aligned to your plan as stated up front. That is, if you planned an ambitious render BUT had to scale down to something slightly less ambitious (due to difficulty or time-constraints), your mark would be lower than the individual who planned a simple render and executed that.
I'm not sure if they changed the marking scheme by the time I took the course, but I think they added advice to pick 10 easy things for your plan even if you are ambitious, because the elements of your plan are only marked on completion not difficulty or quality. Then just do the other things as bonus objectives which have their own category, and the quality will be put in a different category.
There's also marks for artistry and humour, and getting perfect in the other categories doesn't require as much work as I put in. I didn't get a perfect mark and I suspect it's because I blew past the cap for technical difficulty but lost some marks on artistry and originality.
That seems like quite the wrong incentive for learning. A lot of ambitious plans fail. To be graded only on the final delivery gives adequate incentive to execute. I perhaps get the education signal that executing successfully on a plan is a worthwhile skill, but isn't learning also experimenting?
You're graded only in part by aligning with the proposal. You're also graded on innovation, technical depth and software design. The TAs compare it to figure skating / high diving -- you should be able to say what you can do, and then nail it.
In my experience, the students who take the project courses at UW are ambitious and driven. I suspect the chief effect of this policy is an ambitious project whose plan has been fleshed out by a healthy back-and-forth with the TAs upfront, vs a ridiculously ambitious project that hasn't been fleshed out.
The path tracer is impressive, doing it in a month's worth of work is impressive too :) I took a ray tracing course in second grade, and had to leave everything else and write ray tracers during the term.
And, as an item of nostalgia, here is some of my glossy mirror code:
I'm guessing that they're from a country where second grade means something different. That or I should have been looking for this school that teaches ray tracing in grade 2...
Nice work and presentation, always fun with ray tracing. Bonus points for the fractal :)
I assume you did this in RGB space, so no pretty prisms? I couldn't find any explicit mention. From the report I guess you didn't implement refraction at all?
Spectral leads to great images, but the color space conversions are such a pain to get correct.
Also makes it a lot slower. For a really nice/readable (but therefore also “naive” and slow) spectral one, look at this one: https://github.com/TomCrypto/Lambda
It’s a lot easier to learn from than the pbrt one in my opinion.
There are ways to avoid having to do single wavelength rays (hero wavelengths or basis functions) but it’s tricky.
This is amazing work. It is very well written and very well presented. Congratulations!
Ray tracing is fun! Writing code that simulates physical optics and generates a photorealistic image can be very gratifying. Many years ago, I dabbled in ray tracing briefly and it was exciting. I have archived some of the code here, in case, you want to take a look:
First of all, great work. In the "Final Scene" with DOF, the reflection of the mandelbox on the stapler seems to be more in focus than the stapler itself, is that actually correct?
Yes, it would be. The virtual image in the reflection would be "behind" the reflecting surface (with the distance being the sum of the camera-to-stapler distance and the stapler-to-mandelbox distance). You're not focusing on the reflecting surface, but on the object being reflected.
Apparently my senses are burned from the years of hedonism, because the “no tone mapping” pic is the one I want to touch. “Auto levels” in Gimp on the “high contrast” pic also gives a result similar to the “no mapping.”
It must have been very impressive in 2014, but nowadays DIY keyboards are a big thing. Of course most people just build a kit but designing and building isn't that hard with 3d printers, the QMK firmware and all.
Disclaimer: I'm in the middle of my first keyboard build, modified from an existing 3d-printable design. The left half works already. I'll probably blog about it when it's finished.
If you start coding in middle school, and consistently work on stuff, you're kind of bound to get a impressive resume by age 20. I only know a handful of coders like that, and they all have wildly impressive projects and resumes - just like OP.
This is cool. I want to start learning this. What programming language would you suggest to write my code while I learn this? Is C++ pretty much necessary for performance reasons or other languages would be okay too? Any specific recommendation?
Check out Peter Shirley's book series, starting with Ray Tracing in One Weekend. It's about ray tracing, not path tracing, but it's a fun introduction to the broader topic.
As for languages, I guess that depends on how long you are willing to wait for results. You might be able to use Go or something on the JVM without driving yourself insane.
I would have used Rust if I hadn't already put 10 hours of work into an assignment to write a basic ray tracer, which had to be in C++ unlike the final project.
> I just wonder why author named ray tracing as path tracing..
Ray casting (1968) was simply casting rays from camera, one per each image pixel, until the ray hits the closest object. Then the pixel gets the color from the object.
Ray tracing (1979) made ray casting recursive for three cases:
1. Reflection: The object surface is a perfect mirror, so we calculate the reflection angle from the incoming ray angle, and continue the process.
2. Refraction: The object is transparent, like glass. The Fresnel equations give the refraction (transmission) and reflection angles and the distribution of energy between them. For some angles, one of these can be 0.
3. Shadow ray: Shadow rays are traced towards each light source. If the shadow ray is blocked by any other object, we're in shadow in respect of that light source. If a light source is visible, both the light source color and the object surface color contribute to the color of this pixel. The object surface can also have a reflectance model (BRDF) so it doesn't need to be a matte Lambertian surface, but the BRDF is only applied to light coming directly from the light sources.
An object can have partially reflective surface (like glossy plastic), and it can also be partially transparent (like colored glass). So at each intersection, we may generate up to all 3 types of rays.
What we miss here, is that all surfaces diffusely reflect light to some amount, and that the colors in all diffuse incoming light from every direction contributes to the color of a surface, not just direct light from visible light sources. (We also miss caustics. Most notably, a transparent glass ball between the surface and a light source will only give a shadow in ray tracing.)
Historically, there was a time when computers were too slow for sampling, even statistically weighted importance sampling, of diffuse light coming from all directions to all surfaces. So the above model of handling only 3 types of rays (mirror reflection, transparent object refraction, light directly from a light source) became both popular, and established as ray tracing.
Then later, advances towards including all kinds of physically possible light rays, adopted names other than ray tracing. They are still tracing rays, but they are not called tray tracing, because the name ray tracing is understood to mean only the first method that got widely popular, with all its limitations.
You almost touched photon mapping there but as long as rays start only from the screen, there is nothing wrong calling anything varying as ray tracing. Limiting reflection count or having multiple rays (monte-carlo) are often aligned with priciples you described.
Simplified, photon mapping is a technique where you shoot rays from the light sources and then record the hits on geometry. Name comes from pretending you're tracing a photon bouncing around.
Then, when doing the regular ray/path tracing, at each intersection of the camera-ray, you see if the intersection location is near any of the light-ray hits. If so, add in some contribution from the light-ray hits.
This avoids you having to explicitly check each light at each intersection point, saving you quite a number of visibility tests. Also, due to the smoothing kernel used when the "photon contributions" are added up, it leads to low-frequency noise rather than high-frequency noise that is normal in regular path tracing. This is especially noticeable when caustics are involved.
Edit: And at least right before I go to bed my post technically made it on the front page in the very last slot :)
I'm also glad people like my ray tracer, it was super satisfying to build, and nice to have a project that I know I put substantial effort into and can really be proud of.