 Let's talk about important sampling, because we have always been talking about uniform distribution. We will see that it's not usually a great idea to sample any function with uniform distribution. What I usually look for is that I have a function that I would like to reconstruct and I have a fixed sample project. From this project, like x samples or x samples per pixel, I would like to get the best estimation possible. Now, we have written the formula for important sampling. This important sampling was before when I divided by the P of x, because I don't only have the F, I also take into consideration the C. And there I can fly in and or reverse up to this distribution. It can be uniform distribution, it can be a Gaussian distribution, it can be many things. Now, take a look at this. I would like to integrate this function, which is the new line. So, it's a spiky function and imagine that the green bars is the actual sampling distribution that I use. It doesn't look like a good idea. Can anyone have a green bar? Because the green bars are too high on the right side and too low in the middle. Why is this a problem? It's not representing the actual distribution. Exactly. So, it has to represent the actual distribution that we would like to sample. Why? Well, let's give a few slides. So, if the function takes the higher value at some regions, this means that if I miss out on the reconstruction of this region, then my error is going to be high. So, what you can say is that if there is like a Gaussian function or spiky function, I would want to put more samples where the spiky is, because that's a large error. So, if I can reconstruct this large error better, I'm doing much better as if I would be sampling the parts that are actually have very small numbers. So, the flat regions that are almost zero. So, let's put more samples to the regions where the function is actually larger. And if we do this correctly, then what we're doing is called important sampling. So, what we're looking for is that I have these green bars and these green bars should match the blue function. So, if I can sample it again, I am looking for the expected value of f over p. So, I divided and multiplied with p of x in the expected value formula. And the question is, what should be the p that I applied in here? So, this can be the uniform distribution on a p or it can be allowed with very distribution. What would be a good distribution? Usually, what is proportional to the function? The function is large somewhere, the sampling distribution has to sample that region often. So, it also should be large. If it's small, in different regions, that it also should be small. And it's also said that if there are regions where the function is zero, I don't want to put samples there at all, because this must be reconstructed. The current below the function is zero. And we will deal with reconstructed functions like that. But for now, imagine that I have in my hand the function that is represent the people. Now, we have talked a bit about this. So, this better, this should give me quite a bit of an advantage, because otherwise it's not worth any bit. So, this is a rendered image with no important sampling. That look closely, you will see now results with important sampling. So, for example, butchered, it was running for the same amount of time. And this is the difference that you have in simple important sampling. So, this means, wherever there is more light, I will put more samples. And the darker regions, I will make a lecture with my samples. Let's take a look at another example. You can see how noisy this region is next to the car. And with important sampling, this is accounted for much better. Now, we are finally at the moment where we can attempt to solve the rendering equation. So, this infinite dimensional singular, this problem child of death, is so difficult that it seems at first that the one should ever block better than the drive. But now, it seems that we have every tool in order to solve it. So, just again, the intuition, the left side after the equality sign means that there are objects in the light sources, if you will. And this I have to account for. But this is not the only source of light. As these objects emit light, then these will be other objects that reflect this amount of light. This means that I am in an amount of light and I also reflect an amount of light, taking into consideration also light attenuation and the VRDF, which is the material properties of the object that I have at hand. So, let's say that I relate this to Monte Carlo integration. So, again, the formula, I am sampling F over E. This is equivalent for integrating F over X from A to B. Now, what is F? F is what you see up here on the right, this whole thing, sorry, just integral part. And P will be something. So, I just substitute the very same thing here on the right side. So, incoming light times the VRDF times the light attenuation factor. And there is going to be the P, which is now a sampling probability for outgoing direction. So, this means that I hit an object and I need to have a choice which outgoing direction should I set for? Where should I continue in this direction? Remindering. So, this is going to be one direction on the hemisphere. This is the Monte Carlo estimator for the actual integral. And let's imagine that we are trying to solve this for a diffuse object. So, a diffuse VRDF is rho over pi. Normally, it was 1 over pi, why? How can a VRDF be just a number? What you see? The perfect diffuse material means that all possible outgoing directions have the same probability. If I hit this table, if it would be perfectly diffuse, we talked about the fact that this is actually velocity. But if it would be perfectly diffuse, why is the light inverse? I have here. I will hit it somewhere and the outgoing direction can be anywhere from this illumination hemisphere. They all have the same probability. What does rho mean? rho is the orbital in the material. Because if I say 1 over pi, this means that every ray that comes in will have a outgoing rate. So, this object would be completely reflective. It wouldn't absorb completely why it wouldn't absorb any influence. Most objects are not like that. So, this absorption is way reflective dependent and we can represent this as rho. Now, how does the equation look like? I just substituted rho over pi for the VRDF. So, it seems that we know everything in this one just the incoming radius. So, what do we do with this sampling distribution? When we hit this diffuse object, we send out samples and we try to collect the incoming radians, which is the LI with this sampling distribution. And the question is, for this case, what would be a good sampling probability? Does it function to sample the diffuse here? Now, what we said is that this peak, the denominator, should be proportional to the numerator. Now, LI, we don't know. This is some part that we cannot really estimate. Because I would have to send many samples out on this hemisphere to know exactly how much light is coming. But by the time I get to know how much light is coming in, I've done the sampling. So, then I am not interested in the sampling distribution because I have a committee. So, this part will leave out for me for you sampling. This we cannot, I know as of now. But this rho over pi times cosine of theta, we can't deal with. So, let's imagine this sampling distribution, which is cosine of theta over pi. And the goal of this is that these people will kill each other. I have a cosine theta in the numerator and the denominator and the same in pi. So, this only, so only this part will remain there. I can technically also put the LV dough of this given material in the sampling distribution. But let's, let's be general for how? So, in the end, I have this simple equation. Look at this. This is what is going to be the solution of this new teni-dimensional integral. What it says is that I'm going to send samples on this hemisphere and I'm going to average it. Because we can identify by that. That's it. And then if you do something like this and you have the volume at very far, then you can render a mercury throughout from the gamemode slots.