by Taylorious · 13y ago · 0 comments
> Their combination of a simple algorithm and stunning results are hard to beat.
that's exactly what fascinates me about raytracing. It's pretty straightforward, you literally emulate the light bouncing around, but given enough resources the results can be surprisingly good-looking.
Ray tracing, although very powerful, has some limitations because it goes the other way: It casts rays from the sensor into the scene.
From your comment and another one here, it seems to be the case that actually some of the photons that don't hit the sensor still affect the image (either that, or you can't get back to the source starting at the sensor for some of the photons). In other words, if a light source emits a trillion photons everywhere in the room, and your sensor (the idealized camera) catches ten million photons, then it's not strictly equivalent to trace back the ten million maths to the light source, and ignore the ones that didn't make it to the idealized camera.
If it were equivalent, you wouldn't need "photon tracing and ray tracing" or bidirectionality.
But I'm struggling at where the symmetry breaks down, since it seems that tracing a path back from the sensor along the same angles should produce the same result as tracing it forward from the light source - for the photons that directly or indirectly (after a certain number of bounces or passing through the materials) make it to the idealized camera.
But the ones that don't make it to the idealized camera - how can they still affect the frame? Or (equivalently), when is it the case that you can trace it forward to the camera but not backward from the camera?
Why do you need bidirectionality? Where does the symmetry break down?
photon tracing is quite different - instead of starting from the pixel you accumulate your results.
as such i consider the original comment not only accurate, but insightful. (if ambiguous)
// Non-minified source in 35 lines for HN, because it's the latest fad :)
https://www.hnsearch.com/search#request/submissions&q=%2235+...https://www.hnsearch.com/search#request/submissions&q=%2230+...
> Note that the goal here was to make the source code as small as possible, not clarity; so even the original code before minification is a horrible mess. This doesn’t do justice to the elegance and simplicity of proper raytracer code; I’m writing a book to right this wrong.
Raytracing is not exactly a lightweight calculation. My first raytracer was TurboSilver 3D on the Amiga, in 1990 (actually one of the first commercial raytracers ever produced). "Photorealistic" images at 7.5 Mhz. For an image like this, you'd set up the scene, hit the render button, and grab a quick lunch. When you came back, the scene would be about 2/3rds rendered, and you'd watch it for a while, thrilled by every new pixel that pushed itself onto the screen. Then you'd go get coffee and hope the scene was done when you got back.
Now, the same scene (say, 320x200px) renders in an eyeblink on my phone, driven by a high-level universal scripting language I can tweak at will. This is beyond amazing. It's fucking transcendent.
(Oy vey, I feel old. Where'd I put my dentures? BTW: get off my lawn, etc.)