TU Wien Rendering #8 - Surface Normals

A TU Wien rendering lecture on computing surface normals from implicit functions using gradients. The instructor works through an elliptic paraboloid example and explains ray-surface intersections in ray tracing, including how to handle self-intersection with epsilon offsets.
Chapters
Okay, let's quickly study how to compute surface normals, because we are going to need that. If you remember the diagrams, we always had the surface normal for the diffuse, specular and the ambient shading. And just a quick remark, in the previous lecture we have talked about diffuse and specular shading and also ambient. But these are perhaps the most important ones for the simplified VRDF models and you can see them everywhere. So when you are on public transport, you can think about what object could be what exactly. Some objects are like a mixture of these VRDF models. It is possible that I have a diffuse object with a glossy or a specular coating on top of it. And you can move your head around like I told you before, and see how the look of the object changes. So a lot of beauty to marvel at. And you will be able to also understand that. For instance, if you watch someone performing stand up comedy, there are usually a lot of guys saying humorous things and they almost always wear makeup. And the makeup artist tells them that, yes, you need to wear makeup. And the artist says that, no, I'm a manly guy, I don't want to wear makeup. And they say, well, I don't care, you have to, because otherwise you are sparkly. And this means that they start sweating. And if they start sweating, the skin is going to get a bit oily and then it is specular, it's more specular. So it means that if I turn my head around, it will look a bit different. So there's going to be specular highlights. And if you use makeup, then these specular highlights disappear and the whole face is going to be almost perfectly diffused. Therefore it doesn't distract your audience. So light transport is everywhere. So if you ever wear makeup, then think about this. Specular and diffuse reflections. Okay, but I digress. So surface normals. I have an implicit equation, F. I would like to know the normals of this surface. How to construct the normal? Well, the normal is given by the gradient of the function. And. Just a quick reminder, the gradient of the function. This is a 3D function of x, y, z. And the gradient on every coordinate gives you the derivative of the function with respect to a given coordinate. Let's see an example. Imagine an elliptic paraboloid. You don't have to imagine that because it's going to be an image. So this is X squared over A squared, and so on. I'm not going to read formulae and this is how it looks like. And if I would like to put together something like this, then I have to know That A and B are the curvatures of this thing in different dimensions and therefore these values are scalar values. Well, let's compute the surface normal of this elliptic paraboloid. This would be includes differentiating the whole equation for the first coordinate with respect to X. So let's differentiate this with respect to X. Well, X squared is going to be 2x and a squared is going to remain there because it's a scalar multiplier. Why does it depend on X? It doesn't depend on X, therefore it falls out Z. It doesn't depend on X, therefore the first coordinate will be 2x over a squared. What about the second term? The second term is the function differentiated with respect to Y. Okay, Does X depend on Y? No. This term is going to be zero. What about this? Y squared is going to be two Y over B squared. Z doesn't depend on Y, therefore this is going to be the second term. What about the third term? I differentiate this function with respect to Z. The Z. Does it depend on X? Someone let me know. I mean, correct. It doesn't depend on it. Does Z depend on Y? It doesn't. Well, what's going to be the derivative of this expression? It's going to be minus. A bit louder. Minus one. It's going to be minus one. Okay, let's see. Okay, we got this. So we can construct the surface normal of an elliptic parabola. Excellent. So when we do this intersection routine in ray tracing, I have a ray and I would like to intersect this against every single object that is in the room. The question is, what is the first object that the ray hits? Which intersection am I interested in? So there may be many. So if I look somewhere, I may intersect many different objects. But if things are not translucent or things are not transparent, then I'm only going to see the first intersection and that's it. And the first should be the closest. So this should be easy because we are using parametric equations. They depend on T and T is the distance. So basically what we get as an output, this is going to be a list of T values that I am intersecting these objects. A list of t's 2, 5, 10, minus 2, things like that. Well, the question is, which one do I choose out of this list of T's? Someone help me out. Smallest positive T. The smallest positive T in E. So the negative ones I'm not interested in. Like I told you, no politics politics. Free zone. And I'm going to be interested in the smallest positive T. This is more or less true. Negative T'S. We are not interested in. We have discussed this and the question is, can we take T equals zero? And I'm not telling this because I would be an annoying mathematician, only half mathematician, and I'm among the kinder ones. Okay, so I'm not asking this because I would be an annoying mathematician. I'm asking this because this is going to happen if you write a ray tracer. So lots of people are, you know, something is not working and I have no idea what went wrong. It is possible that T equals zero and we need to handle this case. So just a second. Raise your hand if you. If you know what t equals zero means in an intersection. Okay, excellent. I will ask someone who I don't ask me so often. Do you mind? No. Okay. Have I asked you before? Yeah, just a minute ago. Okay, I'm already out of order. Who didn't raise their hands? You do. Okay. May I ask your name? My name is G. Okay, so what's happening when T0? I would sit directly the lens with the camera. Sorry, where we shoot. Yes, exactly. So if we have some amount of bounces, if I get T equals zero, this means that I am exactly on the surface of the object that I am bouncing off of. So if I intersect against the sphere and I bounce the ray back after the next intersection routine, I am almost guaranteed to see machine Precision matters. But mathematically I'm guaranteed to see T0 because it's self intersection. The ray comes to this direction, bounces back from the table, but it is on the top of the table. There's going to be like a trivial intersection which is from the starting point of the ray. So we are not interested in this. So we are going to take as a conclusion the smallest non negative and non0t. So in code we usually put there an epsilon like a very small number. And we say that if it's the very least this number, then I will take the intersection because it's not self intersection anymore. Okay, after we digested this, a small beauty break. This is an image rendered with Lux Render, our glorious renderer. We are going to use this later during the course and some more motivation, we'll be able to compute images like that. Isn't this beautiful? The previous image, the background, was it rendered or is it just a photo? That's cheating? Well, if you are in the mood to model like an extremely high polycount. Well, maybe it's procedural, I don't know. Yeah, people do that too. But it gives you a really realistic lighting of the scene. You can use this thing in a later assignment to create beautiful images. By the way, there's a course gallery. Make sure to take a look because from previous years, people have created some amazing, amazing scenes. Raise your hand if you have seen this gallery. Okay. From the people who are. From the people who haven't seen, raise your hand if you're going to take a look at this after the course. Okay. Excellent. I didn't see your hand. What's up? You have map look, but you have to. Okay. Because there's seriously some amazing things. I wouldn't say some people should have gone artists instead because this would say something about their knowledge. And it's not the case at all because these students are really smart guys, but they have some amazing artistic skills. And I'm sure that there are some artists inside some of you as well.










