10 ms·
Photorealistic Path Tracer
- trishume 7y agoWell I hoped to be on HN today for my high-effort blog post on generics and metaprogramming (http://thume.ca/2019/07/14/a-tour-of-metaprogramming-models-for-generics/ http://thume.ca/2019/07/14/a-tour-of-metaprogramming-models-...) but at least I'm on HN for something :P 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.
- gigatexal 7y agoHah you’re obviously capable. Some big firm will scoop you up no problem.
- Radim 7y agoTruly capable people rarely want to be “scooped up by some big firm”, much less “no problem”.
- gigatexal 7y agoI meant someone with the op’s skills will have companies vying for and paying handsomely for
- jacquesm 7y agoHalf of Google's employees would probably disagree with you.
- gigatexal 7y agoHalf 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.
- jacquesm 7y agoGiven 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.
- gigatexal 7y agoAhh then I’m still a novice programmer at this stage and overestimated something I don’t even have the math to be able to do. And nope, I wouldn’t know where to start to do anything in 3D graphics. But I can throw together a microservice API
- deleted 7y ago[deleted]
- gigatexal 7y agoYou’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)
- jacquesm 7y agoI 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.
- azhenley 7y agoOops! 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.
- JabavuAdams 7y agoGreat stuff! Aside from having the technical chops, you've done a remarkable job documenting your work, and honing your writing.
- deleted 7y ago[deleted]
- spencerflem 7y agoOh no way, you're Tristan Hume! My high school science research project was based on the eye tracking thing you made a while back :)
- trishume 7y agoCool, 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.
- endergen 7y agoWould love to see a link to what you are talking about
- jacobolus 7y agoProbably https://github.com/trishume/eyeLike https://github.com/trishume/eyeLike
- endergen 7y agoYup. Was a lazy Google on that one. Here’s his blog entry on it: http://thume.ca/projects/2012/11/04/simple-accurate-eye-center-tracking-in-opencv/ http://thume.ca/projects/2012/11/04/simple-accurate-eye-cent...
- User23 7y agoI also have a tungsten cube, although I rather like the archaic name wolfram. I fully second your 10/10 recommendation. Best paperweight I ever owned. Oh yeah and your webpage has plenty of other great pieces too. Thanks for this!
- robbrown451 7y agoYou're in the very first slot now. Congrats, this is super impressive, both in implementation and documentation.
- nagarajns 7y agosadhghsgd asdgsad
- deleted 7y ago[deleted]
- isoprophlex 7y agoIn - fucking - credible, the amount of attention to detail in your implementation and in compositing the scene. I haven't read the meta programming thing yet but I really enjoyed reading the thing about the path tracer.
- Frost1x 7y agoI'm completely amazed this was accomplished in one month's time.
- dblotsky 7y agoAyyyy, 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. ;)
- azhenley 7y agoFor those curious, CS452 is Real-Time Programming: https://www.student.cs.uwaterloo.ca/~cs452/ https://www.student.cs.uwaterloo.ca/~cs452/
- dhruvil1514 7y agohii
- vkazanov 7y agothe metaprogramming post is very, very good, btw, thank you
- lazzlazzlazz 7y agoExceptionally well-documented. A very interesting read, an renewed inspiration for my work ethic.
- magicalhippo 7y agoOne of the best books I've read on the subject is https://www.pbrt.org/ https://www.pbrt.org/ (which the article also mentions). It manages to tackle both the math and the gritty details of implementing the math. Blew me away the first time I read it.
- trishume 7y agoYah 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.
- person_of_color 7y agoHow did you read it without falling asleep?
- bmurphy1976 7y agoHe liked the content? 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.
- colmvp 7y agoI'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.
- delinka 7y agoI'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.
- magicalhippo 7y agoNice 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.
- deleted 7y ago[deleted]
- alkonaut 7y agoAlso 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 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.
- aasasd 7y agoApparently 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.”
- macspoofing 7y agoI recognized the final project structure of CS488. Great class, though quite time-consuming. The author links to past year galleries: https://www.student.cs.uwaterloo.ca/~cs488/gallery-A5.html https://www.student.cs.uwaterloo.ca/~cs488/gallery-A5.html 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.
- wjnc 7y agoThat 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?
- cldellow 7y agoYou'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.
- trishume 7y agoI'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.
- leowoo91 7y agoI just wonder why author named ray tracing as path tracing..
- iamnotacrook 7y agoThey didn't; they're talking about path tracing.
- leowoo91 7y agook found few answers: https://www.quora.com/Whats-the-difference-between-ray-tracing-and-path-tracing https://www.quora.com/Whats-the-difference-between-ray-traci...
- sampo 7y ago> 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.
- 2_listerine_pls 7y agoImpressive resume
- person_of_color 7y agoThe definition of 10x
- tachyonbeam 7y agoApparently, 10x developers even design and build their own keyboards so they can type faster (he really did that): http://thume.ca/2014/09/08/creating-a-keyboard-1-hardware/ http://thume.ca/2014/09/08/creating-a-keyboard-1-hardware/
- dancek 7y agoIt 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.
- TrackerFF 7y agoIf 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.
- person_of_color 7y agoTrue that - it's a sign of privilege.
- susam 7y agoThis 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: - https://github.com/mycask/java-ray-tracing https://github.com/mycask/java-ray-tracing (A very rudimentary orthographic ray tracer written from scratch in Java) - https://github.com/mycask/pov-ray-tracing https://github.com/mycask/pov-ray-tracing (Examples written while learning POV-Ray)
- zokier 7y agoFirst 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?
- stan_rogers 7y agoYes, 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.
- androidfantasy 7y agocongrtas for achivement. this is super impressive
- 200px 7y agoThis 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?
- sfkdjf9j3j 7y agoCheck 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.
- hellofunk 7y agoHis books are all about path tracing, which is a subset of ray tracing.
- namibj 7y agoThere are many recent languages that seem suitable. Like Julia and such.
- alkonaut 7y agoIf you don’t already know c++ I’d go for Rust.
- duck2 7y agoThe 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: if(matl->t == M_GLOSSMIRROR){ double θ0 = acos(cosθ), Δθ = M_PI * matl->rough / 2, lθ, dθ = 2*Δθ/ray->w, dφ = 2*dθ, θ, φ; lθ = (θ0 - Δθ) < 0 ? 0 : ((θ0 + Δθ) < M_PI ? (θ0 - Δθ) : (M_PI - 2*Δθ)); θ = lθ + (p+RAND1)*dθ; φ = -2*Δθ + (q+RAND1)*dφ; v4 z = hit->n, x = norv4(subv4(ray->p, scv4(dotv4(ray->p, z), z))), y = crv4(x, z); ...
- sfkdjf9j3j 7y agoNow that is impressive. When I was in second grade I was still wrapping my head around addition and subtraction.
- dhruvil1514 7y agohii
- xal 7y agoFun 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!
- rhaksw 7y agoHah, that's great. This is the kind of humility that keeps me coming back to hN.
- mberning 7y agoCan you share the critique? It would be an interesting read.
- xal 7y agoIt’s been a long time. If you ever saw the JavaScript “wat” talk, you get the idea. We have since rewritten liquid mostly in C and it has a strict parser mode that’s done with proper approach instead of my hacky regexp based approach.
- trishume 7y agoBasically, 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.
- mberning 7y ago
- p0nce 7y agoI feel a bit old now :) Really appreciate the ethics of citing sources, explaining in much detail and presenting choices from first principles.
- donatj 7y agoSomehow 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.
- danielbigham 7y agoUWaterloo CS488! Some of the funnest 200 hours of my life. Here's what I produced 17 years ago. Kind of embarrassing next to your slick work! http://www.danielbigham.ca/raytracer/raytracer.htm http://www.danielbigham.ca/raytracer/raytracer.htm
- Guthur 7y agoIt looks good except for a few standout things. The reflection of the cube in the stapler is too sharp, like a perfect mirror finish. The book in the background seems to lack and sort of ambient occlusion. Still a good scene, it's the fact these stand out so much to me is evidence of how good it is :)
- tempodox 7y agoSo, no code and no math, just some nice pictures. How utterly boring and disappointing. Oh well, at least we know it can be done with Blender.