TU Wien Rendering #9 - Hard and Soft Shadows

Shadows are regions not visible to a light source. Point lights create hard shadows (umbra), while area lights create soft shadows (penumbra). Ray tracers shoot shadow rays to test occlusion, and Monte Carlo sampling of multiple points on an area light approximates soft shadow effects.
Chapters
Okay, philosophical question. What is the definition of shadows? And we could run a long philosophical argument for now, but let's conclude for now, but only for now, that shadows are regions that are not visible from light sources. And again, if you're on public transport, or if you're bored on a lecture such as this one, but hopefully not this one, well, you can take a look at the shadowed regions, and you will immediately recognize that these are the regions that are somehow occluded with respect to the light source. Let's take a look at an example. This small red dot on the top, this is a light source. This is a point light source. And this black thing is a sphere. And behind that, with respect to the light source, we have an umbra. This is a completely shadowed region. This is the name of the completely shadowed region. And if we are going to shade these points in the raytracer, and if I want shadows, then I need to compute whether this ray where I am shading the point is obstructed or occluded from the light source or not. Now, this is very simple to do. So imagine that I would like to shade this point below on the plane. And what I would do is I would send a ray that I call a shadow ray towards the light source. What I'm interested in is, is it obstructed? Obstructed means that it hits something before it's blocked by something. So the first question is, is an incredibly difficult question. Is this obstructed or not? This first ray, it's obstructed. It is obstructed, indeed. Okay, what about this guy? What do you think? This is obstructed as well. Okay, what about these guys? These guys are good. Okay, cool. So it is, for now a very simple concept. Shadows. It means that I will also have a visibility signal that I multiply the intensity with. And this is binary. Obviously, the ray either hits an object or it doesn't. That's it. So very simple. This intensity, that is not radiance. But this is the hack that we use in ray tracing. This is the simpler version of things still. I'm going to set to zero. Whatever shading I have at that point, I don't care. It is in shadows. It's going to be completely black. So this is the simpler version. What about real life? Well, in real life, point light sources don't exist because the point, by mathematical definition is of measure zero that is infinitely small. And something that is infinitely small, well, we call it a light source. So this is something that's infinitely small, but it has a given amount of energy. Well, if you ask Stephen Hawking, he would say that this is a definition of a black hole. So we would have a black hole, and if this would happen, we would have much bigger problems than computing shadow rays. So that's definitely out of our interest at the moment. So we have an area light source, and we still have the umbra because none of the rays make it to the light source. But we have a different region that we call penumbra, which are partially shadowed regions. So things are going to get much more interesting. Now I'm going to shoot two shadow rays from the surface towards different regions of the light source. What about these guys? What about the right shadow ray? It's occluded. It's occluded. Okay, what about the left? It's not occluded. Okay, excellent. So this already doesn't seem binary anymore. And this visibility signal is going to be continuous. So there may be points which are visible from some part of the light source but not visible from another part of the light source. And therefore we have some kind of partial occlusion. And the question is, how do we compute this? How can we write a program that can give me a beautiful penumbra and not just hard shadows? So if we only have the umbra in the literature, this is called hard shadows, and penumbras is soft shadows. We're going to see examples of that in a second. So very simple. Let's try to approximate the area of the light source that is visible from that point over the whole area of the light source. Let's see an example of that. But first, I'm interested in how to approximate this because I'm talking about areas and this sounds like some kind of integration problem. And for now, we are not going to evaluate integrals over this. For instance, what we can do is we could shoot a lot of shadow rays and try to approximate this area. So the approximation is going to be the following. I'm interested in the visible shadow rays, the number of visible shadow rays over all the shadow rays that I have computed. Well, example, how is this region going to look like? Well, I'm going to shoot 100 shadow rays from these small black dots, and I'm interested in how many of them is going to make it to the light source. What do you think? Well, out of 100 shadow rays, does 100 hit the light source unobstructed? Definitely not. What about 50? Probably not. Okay, well, it's actually, it's quite reasonably Dark there. So let's say that three of them is the light source. It's very simple approximation. I shoot 100 shadow rays, three of them hits it. Therefore, this is what I'm going to multiply this intensity that I have computed with. Okay, what about the next region? This is a bit farther away. Out of 100, does 100 of them hit this region? Definitely not. Half of them. What do you think? Half of them, definitely. Okay, cool. And if we go even more out of the umbra, then I have this white dot and I'm interested in how many of these could hit the light source. Well, I think that there can be. There are regions which are definitely obstructed, but it's not too much. So let's say that 95% of these shadow rays hit the light source. So I can already compute in a way, soft shadows. Not only shadows, but now soft shadows. You're going to see examples of that. And what we have done here is actually Monte Carlo integration. And you're going to hear a lot about Monte Carlo integration. It's in every list. I don't know, some teenage people look up the top 10 billboard list of the best music clips of Lady Gaga and the others. What I do myself, I confess, I look up the top 10 mathematical techniques nowadays, and I tell you that Monte Carlo integration is always on the billboard top list. It's one of the most effective techniques to evaluate integrals, and we're going to study them extensively and it's going to make your life infinitely simpler. Now, a quick bonus question. Can such an image be physically correct? Well, obviously it's a drawing, so it's not correct. But there is something that's unbelievably so incorrect that it would need some attention. Who can tell me that? Yes, That is true, but unfortunately this is a mind reading exercise, so you would have to figure out what I have thought. No, no, no, I'm just kidding. That's absol. True. Yes, please tell me. Well, as far as I know physics, the light should bend a little bit inwards from the black object, but that's apparently not the. We are very far away from that physical correctness. But you are absolutely true. So if I say in terms of shadows. Wait. I would have said something about the shadows in the air. Shadows, indeed. Where? Well, the shadows between the object and the ground, like. Yes. Okay, what's up with. This area wouldn't be shadowed. That area wouldn't technically be shadowed itself. Which area? The area. The area. This one or. No, no, no. The air Part between the object and it's this. No. Okay, then I don't understand any of this. The dark area between the surface of the object, there's empty space, which is. Yeah. Okay, what about if I ask about this transition from here to the outside? So if you imagine these dots that we have, if I would put it in the umbrella and I would slowly move out of there, Would I experience such a jump that I see here? Okay. Why not? Because if I start from the umbra, it may be that. Yes, I cannot construct any kind of ray that hits the light source. And as I move outwards, it will continuously increase this probability. There is not going to be a jump that you see this abrupt color change. It is going to be a perfectly smooth gradient or almost perfect perfectly smooth gradient, depending on many other physical properties. But this is more or less what I would see. And there's going to be an example of that in a second. So this is what I have said for those who are reading this at home. And the question is very simple question. What kind of light source do we have on this image? It's a point light source. Excellent. Why? Because I don't see the. I see hard shadow. Excellent. So this should be a point light source. And well, technically you could say that if you have a smaller area light source, but only one shadow rays. So you don't do this integration, Just one shadow. You can have something similar to this. But generally these are point light sources. What about these guys? The left one is point, but the right one, the left one seems to be a point large source. The right one, I can see this beautiful continuous change. And this is definitely a penumbra. But if I take a look at this region below this object, then I can also see some kind of penumbra. So it might be that this is a small. On the left, it's a small area light source that is close to the object, perhaps. And this is why I don't see the penumbra. But other places I see it. And here on the right, it has a really pronounced effect. So this is definitely an area light source. Well, the next question is that in physical reality we usually don't see perfectly black shadows. So if I take a look around in this room, I see shadows, I see there a region that is lit and then some penumbra and the umbra, ish something. But this is anything but perfectly black because of the bounces. Always have some reflections. So you never have. Perfect. Yes, that's true. So there is an effect that we are going to Talk about next lecture. And it is called indirect illumination. And this basically means that in the ray tracing program we are only accounting for the direct effect of a light source. But in physical reality, it is possible that the light comes in through this window, hits the wall first, this white wall, and then hits the ground in this penumbra region and then it goes towards Maya. And therefore some of the energy is going to be picked up. So the effect of this white wall is, is going to make these black or dark shadows lighter. And this we cannot compute yet. This is multiple diffuse bounces after each other. We, we cannot take this into account. We would need to solve the full rendering equation for this. So what we have is direct illumination. And this is where the ambient term comes into place. What we have been talking about, this ambient term is just basically adding something to this intensity that I have. Why? Because this warms up the image a bit. So I would have perfectly black shadows. And for instance, for this classroom, I would have an ambient intensity that is a color that is grayish. And therefore these regions would not be perfectly black, but I would add this fixed gray number to it and therefore it would be a bit more gray. So. So this is a hacky. This is a really crude approximation of indirect illumination, but it more or less works. At least it is an accepted way to cheat back this lost energy in a ray tracer. Yes, I have a question for the Monte Carlo technique casting the shade arrays. How do we determine where at the surface of the light where we are shooting the points? Because there's a surface. How do we depict some random points on the surface? These are the difficult details of ray tracing programs. There are techniques that help you to pick a uniformly chosen random direction on a sphere, for instance, that I would shoot or uniform directions or points. So I choose a random point on the sphere and I'm going to connect these two that other point. And so perfectly uniformly chosen random points. This I need to generate on the surface of the light source. And this I would need to sample. And there's also optimizations for that. Because what if a light source has non uniform radiation? So some light sources are really intense in one direction, but not in others. How do I account for that? And there is even optimization technique for that. And the short beauty break. Well, we like Flex Render a lot, but it seems that apparently some nerds are living their dreams in our program and creating people like that. There is lots of programs that help you achieving these realistic things. And later on we will talk a bit about how skin realistic skin can be achieved, such as the one that you can see here, because skin is not a surface, skin is a volume. So not everyone knows, but some amount of the light is penetrating the surface of the skin, and it goes beneath the skin, it gets scattered and absorbed maybe even a thousand times there, and it may come out somewhere else from your skin. And this is why the older computer games, in the older computer games, this is why humans look really fake and plastic, because they don't account for this effect. And the newest computer games can compute this or something like this in real time, and this is what makes them so beautiful.










