From the course: Cert Prep: Unity Certified Associate Game Developer Materials and Lighting

Standard lights

- [Illustrator] In this chapter, we're going to consider a critically important topic in Unity, generally, not just the HD Render Pipeline or any pipeline for that matter. It's the topic of lighting. No matter which kind of scene your building lighting is really important for whatever visual style you are aiming for. To demonstrate the way lighting works here, inside Unity in the HD Render Pipeline, I've created a new project which I've adapted slightly. You can find this project in the exercise files in the light box folder. This project has a scene inside it called main scene. It's known as the Cornell box. It's room with some colored walls and it demonstrates easily how light can bounce around and illuminate a scene. If this is the first time you're opening this scene it may look something like this. Depending on your settings, you may not see this dark box here. Instead, the lighting may be deactivated by toggling the lighting icon and you can actually see the scene minus all of the lighting. You may also see or not see the gizmos the camera, for example, on this cube, inside the viewport and you can toggle their visibility on and off using the gizmos icon. I'm going to leave these active because they're useful when we're working with lights. In addition to that, you'll notice inside the hierarchy panel, we have some pretty basic objects here. We have a scene camera. We have two volume objects here which we're going to be exploring later in this course. And we also have the light box itself which consists of all of the meshes here. That includes the cube at the center and all of these walls and this entire scene has been saved inside main scene here. So you can easily open that or save that scene to view these changes. This is a scene minus lighting. You'll notice inside the hierarchy panel that we don't have any lights active in the scene. That's why when we enable lighting we don't see anything at all, we just see darkness because there are no lights. Let's take a look at some of the basic light types that Unity offers. Let's see how to access them and how to add them to the scene, to begin to add some illumination. Notice that I've deliberately removed all lighting from the scene because I want to build up a scene from scratch with lighting so you can see how lighting works and how we can improve upon the basics. Let's start by adding some basic light types. To do this, I'm going to move to the menu here and choose game object light. Now under the light menu, we've got a range of different lights that we can add to the scene. Not all of these objects are strictly speaking lights. For example, we have the planner reflection probe the reflection probe, the light probe group. These bottom three are related to lights but not lights themselves. The key light types of these top three or four objects here. Let's take a look at the directional light. I'm going to click to select that to, add that to the scene and bring that into view here. The directional light consists fundamentally of two things. I can position the light wherever I want within the scene but its position is actually irrelevant to the light itself. A directional light just represents a massive light source infinitely far away casting light in a particular direction. They're really great for creating sun or moon or other natural light sources. We're not really seeing the implications and the effects of that light, but that's simply because the brightness and the intensity haven't been tuned yet. I'm going to make sure the light is selected here and then move over to the panel here on this side to take a look at the settings. We have the emission section that controls the illumination being cast from this light. Right now, the intensity is set to 3.14 in sums of Lux. I'm going to change that to be a much larger value the unit is okay, but I'm going to change the value here to increase in intensity. And as I start to do that, as I start to crank up that intensity, notice is getting here to about let's say 180 and we can begin to see illumination here inside the scene. It's pretty faint but we can easily continue to increase the intensity. I'm going to set this to a value of 1,200 and we can begin to see the effects that is having here. The illumination being cast into the scene. I can also rotate the light to control the direction in which this intensity is happening. And if I rotate around the other side you can see that here the scene is representing the direction from which this light is coming here. Now we can also do things like move to the shadows field and enable the shadow map option to begin to cast shadows. Notice that we're also getting shadows from this wall and remember the position of the light doesn't matter. So that even if I bring this inside the cube we're still getting the shadows of this because the only thing that matters with a directional light is its direction and not its position. So I can just move this out just to move that out of the way, like so, looks pretty good. So here we have some interesting properties for the directional light. I can also move to the emissions field and to the color settings and tweak the color of the light if I want to some really bizarre shades but I'm not going to do that. I'm going to select the directional lights right click and delete it to take a look at some of the other light types that we have. Now, in deleting the directional light, the illumination has reset itself back to darkness since the light has been removed. I'm going to add a new light by choosing game object, light. And this time let's take a look at the points light. I'm going to select the point light here and bring that into the scene. Now with the point light two properties are critically important. The position of the light and then this surrounding sphere that allows us to control the range of the light. And point lights are really great for simulating artificial light sources things like lamps, ceiling lights, and wall lights. So I'm going to bring this inside our room here and for this light, I'm going to make sure it's selected. And I'm going to move to the intensity fields here. Now with this light, we have a range of different units that we can use. I'm going to be using EV 100 and that simply just allows me to crank up the value easily with relatively low numbers to increase the brightness of this light here. We can already begin to see the effects that the point light is having. We can also see how much its position within the scene matters. So I can bring it over to this side, looking good, bring it over to that side, looking good. Can change the intensity slider here, that's perfect. And also here in the shadows field I can enable shadows and you can see that the shadows are being applied to this object you can see them here from the floor. Great. So we've now applied some shadows to this objects in the game. We can change things around and you'll see the shadows updating. I'm going to delete the point light here, going to add the third and final light type. And that's going to be the spotlight. So I'm going to choose game object, light, and then select spotlight. Now the spotlight has different properties. One, it has a position. It has a direction. So I can also change the rotation. And it also has this cone of influence that allows us to control the effect of the spotlight within this cone. So I'm going to position this to the front of our Cornell box and raise that up inside the viewport here. Again, move to the emission section here inside the inspector. I'm going to change the values to EV 100 and then increase the intensity slider so we can begin to see the effect of the spotlight here inside the scene. And just bring that up into view. I might rotate that a little bit more and rotate it in this direction here and also increase the cone just by clicking on these handles to expand them. You can also tweak the outer cone slider here inside the viewport. So I can also increase the inner cone here the most intense area and then the outer cone being the distance over which the light attenuates from full intensity to nothing at all. I may also increase the radius field and again, that allows us to choose how close to the light the illumination is being cast from the size of the light source itself. So I'm just going to give that some volume here to something looking kind of like this. And that's looking actually pretty nice. So you can see the effect of the spotlight here. Now, if you have studied lighting carefully, you may notice in our model, in this scene here that there are some important problems. Take for example this spotlight casting illumination on this cube here inside of this room. You'll notice that outside of this cone shape we're getting no illumination at all. The entire scene is transitioning from fully illuminated from within the cone to completely black outside. This scene is not accounting for indirect illumination. That is the light that is emitted from the light source and continues to bounce around to illuminate other areas not directly in the way of the light. We'll see in a later movie how we can add the indirect illumination to our scene, but next up, we're going to take a look at area lights.

Contents