TU Wien Rendering #4 - Diffuse, Specular and Ambient Shading

A TU Wien lecture on basic shading models breaks down how light interacts with surfaces using three terms: ambient (constant), diffuse (Lambertian, depends on surface angle), and specular (view-dependent highlights). The excerpt then covers ray tracing fundamentals: shooting rays from the camera, intersecting objects, computing shading, and recursively tracing reflections and refractions.
Chapters
Lets go with a simplified version of the whole thing. We're gonna talk about simplified BRDF models. Well, there's going to be the ambient brdf. How does it look like? Well, first, first on the left side I see, I. This is intensity. Well, what is this? Well, no one knows because we have not radians, not something very physical here. This is going to be a simplified version of the whole rendering equation. Basically a bunch of hacks, if you will, something that is vastly simplified. It doesn't really have a physical meaning, it doesn't have physical units, but it works. It's beautiful and it's a good way to understand what's going on. So the intensity that we measure is going to be an ambient, the product of an ambient coefficient of an object. This is dependent of the object. This means something like the color of the object. And the eye is going to be the intensity, the ambient intensity of the scene or the light source. And later on we are going to be talking about why. This is interesting. So this is an example. We have a blue object over here and it's the same color everywhere. Why? Because the formula doesn't depend on anything. There's just one coefficient that's multiplied by this intensity of the scene. So that's an ambient shading. What else is there? There's the diffuse brdf. This is what we compute is a diffuse coefficient. What is the diffuse color, the diffuse albedo of this thing. And there's going to be a product of L and M. This is what we did before. Diffuse objects look like that. Please raise your hand if you have ever done any kind of diffuse Lambertian model in graphics. Okay, excellent. Great. And just another thing. This diffuse coefficient is the very least rgb. Okay? So this is how much light is not absorbed on every different wavelength. Because I cannot describe colors in one number at the very least RGB or a continuous spectrum, just for the record. And now it's looking better because I can more or less see where the light source is for this diffuse shading. There's also a specular BRDF. What I compute is v.r times the specular coefficient and V is the vector pointing towards the viewer and R is the reflected. There's going to be examples of that. So just that you see the formula here and there's an M, which is a shininess factor. In the next assignment you will play with this yourself. So for now I will keep this a secret. What this exactly does. And whoops. I'm going to jump through this because I would like to ask A question later on and you're going to find out the solution. Excuse me. So this is how the specular highlights look. And if I end up all the way these things ambient and diffuse and specular, I get some complex looking model that looks something that is, that approximates physical reality. So I just simply add all these terms up. Okay, well, I have something like this here and I have on purpose removed the light source from this image. But probably everyone can tell where the light source is expected to be. Right? So raise your hand if you know where the light source should be. Okay, cool. Where should it be? Above. Exactly. Exactly. So it's going to be above the spheres and this is exactly where it is. So these material models are descriptive in a way that, that I get images that have some physical meaning that resemble physical reality. Well, let's take a look at an actual example. The question is what would this region look like, the one that I marked, like this pixel. If pixels existed in the real world, would it look the same if I moved my head in reality? And that sounds like, it sounds like a tricky question. Yeah, I, I have seen the answer. Yes. Well, let's say that this part is purely diffuse. I don't see many specular reflections in there. Diffuse is l dot N so light vector direction times the normal. Does it change if I move my head? Well, how to answer this question? You don't only need to see what is in an equation. You are of you, you have to be aware of what is not in there. Does it change if I move my head? Raise your hand if you know the answer. It's very apparent to many of you. Yes. So I answer yes, it does not change if I move the. Okay, but it might change because the specularity might move over there. Yes, yes, that's very true. So it doesn't change because we know that it doesn't change. I mean the walls look the same if I move around. I'm not talking about shapes, I'm talking about colors. They don't change. A mirror, however, does change. And the mathematical reason for this is that the view direction is not in this equation. I can change the view direction all I want and nothing will change in the diffuse beyond here. So this is like a general mathematical trick or principles that you can use in a number of different things. Don't just, don't just look at what variables are in there. Try to think of variables, what you would imagine that would be there and okay, why are they missing? And that's, that's also information that's what there, not only what's there, but what is missing is valuable information. So what about these regions? These are specular highlights. These are described by the specular BRDF v. R. So viewing direction times the reflected light direction and let's actually compute what's going on. So I would be interested in the intensity this fake something of this point where this is the light vector, this is where it points to. It is probably reflected somewhere there because it comes in and it's an indeed out ideal reflection. So it's going to be reflected in this direction. And this is where I am just for example. So I'm interested in V dot R. Well, this is going to be a cosine. There is a small angle between V and R. So if there's a small angle that's cosine of a small number, that's large, that's close to one, and that's going to be a huge scalar product. Therefore this point is bright and this is indeed bright. And the question is, which is very easy to answer in a second, is does it change if I move around, does it change? Obviously it does change because V is in the equation. And if I change this around, you see something different for the specular brdf. This is going to be bright. Just one of my favorite intuitions of this v dot R. Because otherwise this is just letters. This means how much am I standing in the way of the light? So, life lesson, if you can't find the water droplets on the floor after having a shower, move your head around, because that's specular. If the windshield of a car is too bright and you just can't take it anymore, move your head around. This connects to the physical reality around us. And that's good tips, in case you didn't know that you need to move your head around. Things aren't too bright. And now you know. Okay, so this is the point where we can just for a second stop and marvel at how beautiful things we can create with such simple equations. And the rendering equation is going to be even more beautiful than that, like infinitely more beautiful. And there is some additional beauty that you can think about when you look at images like that. Okay, how would I shade this point? Is this diffusive? Is this specular? Why does it look the way it does? So if you have nothing better to do, you can think about these things when on public transport. Let's call this thing the illumination equation. This is the fake, simpler version of the rendering equation. Now what is in there? Most of this is Familiar. There is an ambient shading term and then there is the diffuse L M. There is the specular V. R. We add all these together and we multiply this by the amount of incoming light. Because if there is no light sources in the scene, there is no light. Light is not coming from anywhere. Therefore this is all multiplied by zero. If there's a bright light source, then things get brighter. So we multiply by, by this incoming light. And what is important to know is that this is only the direct effect of light sources. This sounds a bit esoteric at the moment, but later on, a few lectures down the road, we're going to be all about indirect illumination and goodies like that. And this is neglected and the ambient term is used to make up for it. You will see examples of this in the next lecture. And this is a crude approximation, but it's still beautiful. It's easy to understand. It's. And it serves as a stepping stone to solve the real rendering equation. But this is not done. One thing is that if there are multiple light sources, the scene is expected to be brighter. So I would compute the whole thing for multiple light sources. So there's going to be a sum in there, and inside the sum, the indexes, are the number of light sources. Basically just. I just didn't want to overcomplicate this. But still, something is still missing. This is not done. I arrive to a point, I compute this specular ambient and diffuse shading and I am not done. Let's discuss how ray tracing works and we'll find out. So the first thing is that what you see here is non trivial. Because what you would imagine is that you start shooting rays from the light source and then some of the rays would make up to make it to the camera to your eye, and most of them won't. So we go with a simple optimization that we turn the whole thing around and then we start tracing rays from the camera. Because if I start tracing from there, I can guarantee that I deal with rays that are not wasted, because I'm not interested in the light rays that do not make it to the camera. So if I start from there, I can guarantee that this is not wasted computation. So how do we do this? There is this camera plane. We will discuss how to construct such a thing. And we construct rays through this camera plane. And what I'm interested in is the projection of the 3D world to this plane. This is what you will see on your model. So I should raise from this camera and I intersect this against objects that are in the scene. I want to know where is the light stopping, what object does it hit and where does it get reflected? So the second is intersection with scene objects. I have to realize that it hits this sphere. Then I stop there. I compute the basic shading terms like the diffuse and the rest of the. And then I don't stop there, but I'm interested in where the light is reflected. I need to continue from here. And this light ray may be reflected or refracted, and I need some kind of recursion in order to account for that. And the recursion works in the following way. I stop at this point where I hit the ball, the sphere. And what I do is that I imagine that this is now the starting point of the ray and. And I'm shooting the ray outwards and I start this ray tracing algorithm again. So this is how the recursion works. This was missing from the formula. And this is just the text version of what I have set for those who are reading this at home. And you will deal with refractions yourself.










