 Now, let's jump back to recursion. So if I would like to compute multiple bounces, I need to handle this somehow. And we have talked about this briefly. If I intersect the first object, I need to reflect the way off of this object in some way. And after the shading is done, diffuse specular ambient shading, then we can trace the light further. And this tracing step can be both reflection and refraction. You remember, for now, as law and as law, we are going to put them in use in a second. But what I need to tell you is something super weird, but you won't feel why this is weird. So in a ray tracer, in a recursive ray tracer, not normal illumination, the indirected relation, and these goodies that we are going to start with, next lecture. In a ray tracer, if you encounter a mirror, an ideal specular reflector, you will bounce the ray back in the ideal reflection direction. So exactly what you would see in the mirror. It's 45 degrees, it is 45 degrees back. And you do the same with diffuse surfaces as well. So you continue the ray in ideal reflection direction. And now this sounds reasonably okay. But when you will study global illumination and how the whole thing is done, how real men compute the rendering equation and images, you will see that this is a super, super huge simplification. I remember the faces of students when they think back, when they know all about global illumination, when we talk about simple recursive ray tracing. And I asked them how is this reflecting? And they are science. Because they will know that in global illumination, it's going to be so natural that the diffuse surface means that it will reflect right in every direction with the very same probability. So the perfect reflection direction has the same probability as coming back the same direction where it enters the surface. They all have the same probability, all directions. And then suddenly our ray tracer says that even a diffuse object I'm going to treat as a mirror. So this is going to be super weird. And please remember that I say this later on if you take a look at ray tracer's after global illumination. Now how does the recursion work? I hit something, I reflect away. So the ray tracer always the perfect reflection direction. And I'm going to restart the whole process. I'm going to start to trace a new ray that starts on the object. Remember, this is when you get the self intersection t equals 0. I increment this maximum ray depth value to show how many bounces I have computed so far. And I start again. So I start a new ray. I imagine that this object is now the camera. And this is where the ray is starting from. Is there a question or okay. So we got everything. How does it look like in terms of mathematics? This is the illumination equation without recursion. But now I need to add one more term. Let's quickly recap this. The first term is the ambient term. This is to warmen up the completely black shadows. This is basically a bunch of hex that it looks good. So we are going to be okay with this for now. Then we scale the amount of incoming light with the material properties. So a diffuse and a specular shading model. These are weighted by KD and KS. These are values that tell you how diffuse or house-packular this object is. And not only house-packular it is, but what color does it absorb? What color does it reflect? So what is the color of the object? What is the diffuse and specular or beetle of the object? I'm using so many terms not because I'm inconsistent, but because people use all of these terms. And therefore you should be familiar with this. And there's some weird stuff that I now added. And this is the recursion part. So KT is the Fresmission coefficient. This is the probability of refraction. Because you remember that I hit this hair glass interface from different directions. And if I hit them from different directions, then the probability of reflection and refraction is different. So depending on incoming direction you have seen, this laser is stronger in one direction than the other. And we have to account for this with these transmission coefficients. And the IT is the intensity that is coming from that direction. The kr and IR are the other way around. So if there is reflection, not refraction, then I'm going to go in that direction. And I'm going to scale this with the intensity of the incoming lights from the reflection direction. A quick example. Where if I have a glass that's blue? So some kind of glass that looks almost entirely blue. Then this Fresmission coefficient is going to describe the color that's blueish. Therefore all the energy that comes through this ball is going to be colored to blue. And the final reflection coefficient can be whatever. So we are now interested in the transmission. So this is how I can define materials like that. This is the recursion part. And for this, I need to start perhaps multiple rays. So if I hit this object and I say that, hey, but this is a transmissive object, this is a glass. What do I do? Because there is a probability, positive probability usually for reflection and refraction. Do I start two recursions? Do I start two new rays? What do I do exactly? And in the assignment that I'm going to talk about, you will see a piece of code that does something. And then you will see the effect of something. I'm not going to spoil anything. And just a quick introduction to headverse notation. This is important because if you know this kind of notation, then you will be able to discuss what kind of ray tracing algorithm can render, what kind of light paths. So as a status quo, all light paths go between light sources and the eye. If it doesn't hit, if it doesn't hit the lens of the camera, it's not going to be recorded in the image. So every light source is every light path is going to be written as L, something, something E. Or as this is by direction, or you can imagine the other way around. So you can say, E something, something L. The notes once one diffuse interreflection during the way, S is one specular interreflection during the way. And the asterisk means any amount of diffuse bounces, perhaps even zero. So LDE means that either I hit the eye from the light immediately, or there is one diffuse bounce, or maybe an arbitrary number of diffuse bounces. This is what the asterisk tells you. And we can also denote the choice. The choice means that there is only one either specular or one diffuse bounce. And with this small but powerful notation, we can discuss all the algorithms there are to render photo realistic quality images. So for now, some of this will be intuitive. Some of this will be not so intuitive because we don't know global illumination yet. But first, ray casting means that we hit at most one diffuse object. As all it can render no recursion, nothing. I just hit one diffuse object. I do the diffuse shading and the bi. Radiosity can compute something like indirect illumination because multiple diffuse bounces are possible. So remember the example. The light comes in to the classroom through the window, hits the white wall, and then hits the over. And therefore, the over is not going to be perfectly black. This is called indirect illumination. Radiosity is got that covered. Recursify tracing what we are doing with this for now transmission and reflection thing. We know that what we can do is indirect illumination definitely not because we treat a diffuse object also as a mirror. We just use a different shading function for it. So we don't trace rays all along the hemisphere of the object because it collects light from every direction. This is why it doesn't change if I move my head. This is why the sight of it doesn't change. But we cannot account for that. This would be a huge dimensional integration problem that we are going to solve in the rendering equation. So at most one diffuse bounce, but you may have as many specular bounces as you need. So this is why recursive ray tracers usually show you mirrors and glass balls and reflective things like that because it is capable of rendering it, but not so much more. And global illumination that's the full package, an arbitrary number of diffuse or specular bounces. This can also be glossy, whatever kind of complicated material model you have here. This DS can be anything and in any amount. Well, let's take a look at an example with the hardware notation. So here we have light paths and they start up from the light source. So on the right I have something like LDDE. That's exactly what I have been talking about. So I start from the light source. I hit a diffuse wall. I hit the diffuse ground and then I hit the camera afterwards. So that's LDDE. Let's take a look at for instance LSSE. So I start from the light source. I hit the glass ball from the outside, this left glass ball. And then I go inside the ball. There's going to be reflection at least. Let's imagine that there's going to be a reflection. And then I hit it on the other side as well and I come out. So this is two specular bounces, LSSE. So we can denote light paths and understand what algorithms can render what exactly. So here if we imagine that this is a ray tracer, this is an image with a ray tracer. The question is what did they do? And this is a rather low quality image. But let's, it seems to me that the shadows are not completely black. Therefore in their shading models, they definitely use the what kind of term? Raise your hand if you know the answer. So normally this would be completely black because I should a shadow ray towards the light source and it is going to be uploaded by the table. So intensity is 0. Imagine that like all possible shadow rays are blocked. But this is still not completely black because I'm adding a term to it in order to warp up and make the image appear more realistic. So this would be which term I'm doing. This would be the ambient