2 ms·
Hi HN, first time posting here! I started this project last year when I was looking for something fun to learn Rust with and I had Peter Shirley's excellent Ra
by Dalamar42 6y ago
Hi HN, first time posting here!
I started this project last year when I was looking for something fun to learn Rust with and I had Peter Shirley's excellent Ray Tracing in a Weekend series of books recommended to me. In the process I got interested in learning ray-tracing for its own sake so I decided to finish all three books and I am now considering continuing this further on my own.
I am sharing in case this is useful to others who are on a similar path to where I was.
- ddevault 6y agoNice work!
- Dalamar42 6y agoThank you!
- gdubs 6y agoReally beautiful results. It’s interesting to see Ray Tracing’s durability. In the 90s it was so prohibitively expensive (computationally), that a whole bunch of techniques were developed to achieve realism in somewhat... hackier ways. Now we’re seeing GPU support, etc.
- Dalamar42 6y agoThis is my first attempt at graphics programming and as I went through it I was quite surprised by the simplicity of ray tracing. Before this, I hadn't imagined you could get beautiful pictures with so little code. I found the whole thing quite elegant.
- kd5bjo 6y agoThe same thing applies to lots of fields of computation. In fluid dynamics, for instance, a direct simulation of the Navier-stokes equations is quite straightforward and will produce the most accurate solution. All the complicated parts are layers and layers of tricks to save large amounts of compute time with (hopefully) negligable effects on the ultimate accuracy.
- conjectures 6y agoThis is often true in statistics also. It's high time monte carlo was brought earlier in the curriculum. It's the gift that keeps giving.
- ShamelessC 6y agoSince you seem knowledgeable about this - Can you explain what the difference between 3D graphics generated with Ray Tracing and without? My understanding is that Ray Tracing is essentially the brute force solution to the problem of lighting. We developed "hackier" approximations which run much quicker so our games can run at reasonable framerates. Is true Ray Tracing really that much better than the approximations we've developed? Is it really worth the significant drop in performance? As an old PC gamer, I've often revered clever optimizations and approximations as not only necessary, but undeniably clever and (in my eyes) cooler. Today it seems there's a shift in the other direction. Now that our GPUs can just barely run Ray Tracing in modern games, people are so hyped to use it. For me, it is strange that people would clamor over graphics which are less optimized. Is the visual benefit that high? Does a game that runs on lots of hardware like Minecraft really need Ray Tracing that requires very specific GPUs? I guess for me Ray Tracing feels like finding the primes by naively running divisions on every number less than the one you're looking at. It's the easy solution that is terribly slow. Existing lighting engines are (perhaps) like using a sieve?
- bryal 6y agoIt's not just that ray tracing looks better than rasterization for the same scenario, but that some scenarios are simply impossible / impractically complicated to render with only rasterized graphics. Just one example is specular reflections with non-screen space content and a dynamic environment. Rasterized graphics can do specular reflections quite well as long as the reflection only shows things that are currently in view. One can then perform a limited form of ray tracing in the depth buffer to detect which part of the screen is visible where in the reflection. However, as soon as we want to reflect things outside of the screen it gets tricky, as we can't simply perform this screen space ray tracing. Instead, we have to rely on pre-baked reflection map textures. This works well enough for static objects, like the environment, but you can't see dynamic content, like players, as they can't be pre-baked into the texture. Also, it's useless when there are no static objects, like in Minecraft where there's no such thing as a static environment -- every block can change dynamically. And this is where the limit of specular reflections of rasterization is basically hit. There are of course workarounds, like rendering the scene a second time from the mirrors perspective, and then combining the view render and the mirror render, but you can imagine it gets prohibitively expensive quite fast as you add a few more reflective objects to the scene. Also, this method doesn't work for glossy reflections -- that's even more complex. So this is just one example of how rasterized graphics limits us -- we can't have more than a few reflective objects in a scene which features dynamic geometry, which is a very sensible thing to want to have! In my opinion, ray tracing really is that much better than the approximations we've developed. Also consider how much faster / cheaper it would be for a studio to create new graphics engines when you only have to write 1000 lines of ray tracing code instead of 100'000 lines of rasterization hacks (for a worse-looking result!).
- drran 6y agoYou may want to look at this article for further inspiration: https://bheisler.github.io/post/writing-gpu-accelerated-path-tracer-part-3/ https://bheisler.github.io/post/writing-gpu-accelerated-path...
- Dalamar42 6y agoThanks for sharing. I'll have a look
- pvg 6y agoIn your sample images, why do you get some aliasing just on the white skylight sort of rectangles and seemingly nowhere else?
- boulos 6y agoThat’s pretty common, because the area lights are often very bright. So the subpixel values are either 0 or white hot (and much brighter than 1.0). If you model the light sources with actual physical units and do some sort of exposure process for the “film”, you can get a more natural result.
- Dalamar42 6y agoDo you happen to have a link to any reference material or paper explaining the technique you are describing or a term for it I can search for? I knew why this aliasing was happening, but I wasn't quite sure how to fix it.
- boulos 6y agoI’d actually search for “tone mapping” for the camera / film part. For physical light units you want to look for “lumens”, “lux” and “IES Lights” (though you probably don’t need to care about the directional profile). It’s super handy to be able to plug in real units sometimes like “oh, this lightbulb is 500 lumens, I’ll use that”.
- Dalamar42 6y agoThanks, I'll look them up
- pvg 6y agoI guess I assumed the apparent AA elsewhere was a result of some sort of post-processing but what you're describing makes more sense, thanks.
- 6y ago