I have a background in software design and at some point wanted to build a ray tracer from scratch just for the fun of it, before deciding it would be more fun to just create things with software that already exists. Anyway, unless Cycles is different, I believe rays are traced from the camera to the object and bounced to each light source, which is kind of the opposite of what was briefly explained in the video. I'm not trying to be picky, but it does mean that we don't have to trace rays that will never hit the camera, and it also gives a better respect for the number of bounces setting for when we should stop looking for that pesky light vs. stop looking for the camera.
A ray tracer from scratch just for the fun of it.... There's a sentence I'd never thought I'd hear. In you picture you look like Sean Astin from Lord of the Rings. Perhaps you're an actor and a math genius. I'm not smart enough to have this conversation, but I bet Martin is.
Hi
dbro0808 ,
"...rays are traced from the camera to the object and bounced to each light source..."
Yes, that's right!
I wish I was an actor or genius in any regard. I just have a lot of free time on my hands and like to make basic examples of complex things, like a simple 8-bit computer built on solderless breadboards.
Direct lighting is from camera to object then to light source. Indirect lighting goes camera to object to next object then to light or next object depending on how many bounces you have setup. Side note: cycles is a path tracer, which from a programming standpoint is a more advanced ray tracing from what I understand.
Ok, so my understanding is that path tracing is just ray tracing but using multiple samples per pixel and using Monte Carlo or some optimization technique to arrive at a final pixel color. When I was learning this, they just called it a ray tracing optimization, but I believe that is what is now commonly called path tracing. I think everything else is the exact same, just multiple samples that get averaged. As far as direct vs indirect lighting, I don't recall that as part of the process, maybe that is another optimization, but to my knowledge a ray is cast from focal point through the pixel center (or with path tracing, multiple rays are sampled over the pixel area) and if it hits an object, multiple new rays are cast from that point to every light in the scene, if it hits another object on its way then that is where indirect lighting comes in, and again multiple rays are cast from that point to every light, and the process continues until a light is reached or the max bounce limit is reached. Then they all collapse recursively back to the pixel, calculating the contribution of light that each bounce adds along the way.
So,
1. Focal point =====> pixel center (or sample area) =======> into scene :: was an object hit? If no, pixel is black. if yes, continue.
2. Object ======> each light in scene :: was an object hit along the way? If yes, repeat step 2, or return black if max bounce depth has been reached. If no, use light data to calculate contribution and return to previous object adding the values of the other rays at this level.
3. When all bounce levels have collapsed to the original object, calculate and set final pixel color.
That may be more confusing but I didn't have the patience to create a normal flow chart lol. But anyway, I could imagine a direct lighting pass just to get the base contribution through pixel center as a starting point optimization before sending all the sample rays in path tracing. I could also be wrong about everything lol, but that is my understanding of it all.
Just as a side question, is there a place to post general feedback? I would like to suggest that the quizzes include an explanation of the correct answer for clarity. There have been a few questions that didn't seem to be covered clearly in the lessons and it would be nice to have a concise explanation after each question.
Hi
dbro0808 ,
That sounds about right, the situation gets a bit more complicated, especially in a modern path tracer, of course, but that covers most of the basics. One thing to note, is that for each shading point, an extra ray is cast directly to one (random one) of the light sources. If something is blocking that ray, it is a shadow ray (in the Light Path Node; in some cases, the ray itself is called shadow ray), meaning there is a shadow contributon to that (surface) point. But you are right, when you write this down, it sounds a lot more complicated/confusing than it is (on this basic level).
As for your suggestion (which sounds great), you can make a separate Post here.