WEBVTT 00:00:02.635 --> 00:00:06.218 Lighting in Unity is more fully featured than ever. 00:00:07.635 --> 00:00:11.786 The lighting pipeline includes realtime global illumination, 00:00:11.786 --> 00:00:15.109 in addition to traditional baked light mapping techniques. 00:00:16.621 --> 00:00:19.710 These combined with physically-based rendering 00:00:19.710 --> 00:00:21.297 and the standard shader 00:00:21.297 --> 00:00:25.421 give more power and versatility to light more complex scenes. 00:00:28.492 --> 00:00:32.688 Unity uses physically-based rendering, or PBR 00:00:32.688 --> 00:00:35.699 to create a friendly way of achieving a consistent 00:00:35.699 --> 00:00:39.956 plausible look for materials under all lighting conditions. 00:00:39.956 --> 00:00:44.764 In order to do so, Unity models how light actually behaves 00:00:44.764 --> 00:00:46.764 and follows the laws of physics on how 00:00:46.764 --> 00:00:48.764 light interacts with materials. 00:00:49.612 --> 00:00:53.704 These materials are usually created using the standard shader. 00:00:53.704 --> 00:00:55.704 The standard shader makes physically 00:00:55.704 --> 00:00:58.749 based rendering easy and accessible to use. 00:01:01.322 --> 00:01:03.322 One of the most powerful tools in the Unity 00:01:03.322 --> 00:01:07.195 pipeline is Unity's realtime global illumination, 00:01:07.195 --> 00:01:08.948 or GI. 00:01:08.948 --> 00:01:12.404 Using GI, all lights in the scene can effect 00:01:12.404 --> 00:01:14.923 the object's within range with both 00:01:14.923 --> 00:01:17.928 direct and indirect illumination. 00:01:17.928 --> 00:01:19.928 Direct illumination comes from lights 00:01:19.928 --> 00:01:23.564 shining directly on the objects in the scene. 00:01:23.564 --> 00:01:25.564 Indirect illumination however 00:01:25.564 --> 00:01:28.780 is the light reflected, or bounced off of 00:01:28.780 --> 00:01:30.780 the light surfaces in the scene. 00:01:31.364 --> 00:01:33.364 This bounced indirect light 00:01:33.364 --> 00:01:35.364 can illuminate nearby objects 00:01:35.364 --> 00:01:38.694 mimicking how light behaves in the real world 00:01:38.694 --> 00:01:40.694 This indirect light is effected 00:01:40.694 --> 00:01:43.551 by the colour of the surfaces it bounces off of, 00:01:43.551 --> 00:01:47.375 taking a contribution of that surface's colour with it. 00:01:47.375 --> 00:01:49.375 Direct and indirect light will 00:01:49.375 --> 00:01:52.971 blend together to create a much more realistic look. 00:01:56.368 --> 00:01:58.368 In addition to the default main camera 00:01:58.368 --> 00:02:00.368 a new scene in Unity comes with 00:02:00.368 --> 00:02:02.368 a default sky box 00:02:02.368 --> 00:02:04.368 and a default directional light aligned 00:02:04.368 --> 00:02:06.368 with that sky box. 00:02:09.609 --> 00:02:11.609 Each scene also contains default 00:02:11.609 --> 00:02:13.609 values for ambient light. 00:02:14.683 --> 00:02:17.974 Ambient light illuminates all surfaces in the scene. 00:02:19.435 --> 00:02:22.015 Ambient light is controlled by the settings in the 00:02:22.015 --> 00:02:24.523 lighting panels Environment Lighting tab. 00:02:27.783 --> 00:02:29.783 Ambient light can be created by either 00:02:29.783 --> 00:02:31.783 using a sky box, 00:02:32.650 --> 00:02:35.917 a user generated gradient of 3 colours, 00:02:44.208 --> 00:02:46.208 or a single colour. 00:02:54.593 --> 00:02:56.593 All objects added to the scene 00:02:56.593 --> 00:02:58.499 will receive ambient light 00:02:58.499 --> 00:03:01.881 unless the ambient intensity value is set to 0 00:03:02.898 --> 00:03:06.265 or the ambient light's colour values are set to black. 00:03:08.093 --> 00:03:10.093 It is rare, if not impossible 00:03:10.093 --> 00:03:12.093 for any real-world material 00:03:12.093 --> 00:03:15.638 to have absolutely no reflectivity. 00:03:15.638 --> 00:03:18.676 By default all objects in the scene 00:03:18.676 --> 00:03:21.433 will also receive reflection information. 00:03:22.055 --> 00:03:25.630 Even though the cube, sphere and plane in the scene 00:03:25.630 --> 00:03:28.970 are unlit and ambient light is none 00:03:28.970 --> 00:03:30.970 they still receive lighting information 00:03:30.970 --> 00:03:33.631 in the form of reflections. 00:03:33.631 --> 00:03:37.015 The default reflection source is the sky box. 00:03:37.015 --> 00:03:40.034 This can be changed to a custom cube map. 00:03:40.034 --> 00:03:42.352 To receive no default reflections 00:03:42.352 --> 00:03:44.352 either set the custom cube map to none, 00:03:47.084 --> 00:03:49.084 or remove the sky box. 00:03:52.024 --> 00:03:54.024 It is worth noting that the default sky box 00:03:54.024 --> 00:03:56.494 is procedurally generated 00:03:56.494 --> 00:03:58.494 and new procedural sky boxes 00:03:58.494 --> 00:04:00.494 can be created and saved as assets. 00:04:13.646 --> 00:04:15.646 When lighting scenes in Unity 00:04:15.646 --> 00:04:17.646 we can work with realtime lighting, 00:04:18.475 --> 00:04:19.881 baked lighting, 00:04:20.475 --> 00:04:22.053 or a mixture of both. 00:04:22.607 --> 00:04:26.129 Realtime lighting is more easily modified at run time. 00:04:26.129 --> 00:04:28.129 but it comes at a cost to performance. 00:04:29.429 --> 00:04:31.562 Baked lighting on the other hand pre-calculates 00:04:31.562 --> 00:04:34.004 much more detailed lighting information 00:04:34.004 --> 00:04:36.961 and saves it to a light mapped texture on disc. 00:04:37.470 --> 00:04:39.470 This light map information is then 00:04:39.470 --> 00:04:41.470 read from the texture at run time, 00:04:41.470 --> 00:04:43.470 avoiding the need to do any lighting 00:04:43.470 --> 00:04:45.470 calculations when the project is running. 00:04:46.450 --> 00:04:48.450 This saves performance, 00:04:48.450 --> 00:04:51.846 but at the cost of dynamic changes in the scene. 00:04:51.846 --> 00:04:54.722 Baked light maps are not updated at run time. 00:04:55.363 --> 00:04:58.975 Lights can be switched between realtime, baked, 00:04:58.975 --> 00:05:00.975 and mixed lighting on a per-light basis. 00:05:02.256 --> 00:05:04.256 Using baked lighting exclusively 00:05:04.256 --> 00:05:07.020 would be more appropriate for target platforms 00:05:07.020 --> 00:05:10.844 such as mobile devices with lower performance capabilities. 00:05:13.674 --> 00:05:16.011 The light mapping system can either work 00:05:16.011 --> 00:05:18.011 continuously or on demand. 00:05:19.575 --> 00:05:22.081 When continuous baking is selected 00:05:22.081 --> 00:05:25.019 lighting changes will be baked in the background while editing. 00:05:25.754 --> 00:05:27.754 These changes can either be properties 00:05:27.754 --> 00:05:29.242 adjusted in the inspector, 00:05:29.242 --> 00:05:31.926 or objects changed in the scene. 00:05:43.058 --> 00:05:45.343 When continuous baking is not selected 00:05:46.189 --> 00:05:48.686 changes will only preview on demand. 00:05:50.137 --> 00:05:53.426 When the Build button in the lighting panel has been selected. 00:06:00.360 --> 00:06:02.360 In this scene there is a directional light 00:06:02.360 --> 00:06:05.004 coming in through the skylight in the ceiling. 00:06:05.607 --> 00:06:09.488 This light contributes to the illumination of the entire scene 00:06:09.488 --> 00:06:11.488 as the light bounces off of the surfaces 00:06:11.488 --> 00:06:13.127 it lights directly, 00:06:13.127 --> 00:06:16.096 on to other nearby surfaces in an indirect manner. 00:06:17.445 --> 00:06:19.445 This light continues to indirectly 00:06:19.445 --> 00:06:21.445 illuminate nearby surfaces 00:06:21.445 --> 00:06:23.445 until the strength of the light fades 00:06:23.445 --> 00:06:24.993 and it can bounce no more. 00:06:25.860 --> 00:06:27.594 Decrease the intensity of the light 00:06:28.048 --> 00:06:31.132 and the illumination of the scene decreases accordingly. 00:06:34.693 --> 00:06:36.693 Likewise, if the directional light 00:06:36.693 --> 00:06:38.693 is rotated to directly light a 00:06:38.693 --> 00:06:40.562 different part of the scene, 00:06:40.562 --> 00:06:43.349 it will now illuminate the scene in a different way, 00:06:43.349 --> 00:06:45.971 with both it's direct and indirect lighting. 00:06:49.306 --> 00:06:51.948 As materials created with a standard shader 00:06:51.948 --> 00:06:55.297 can mimic a wide variety of physical surfaces 00:06:55.297 --> 00:06:57.297 and different materials can have different 00:06:57.297 --> 00:06:59.030 amounts of reflectivity 00:06:59.030 --> 00:07:01.030 this can effect the scene's lighting. 00:07:01.690 --> 00:07:05.475 To help balance this the Bounce Intensity can be adjusted 00:07:05.475 --> 00:07:07.832 on either a per-light basis 00:07:07.832 --> 00:07:09.832 or globally by adjusting the settings 00:07:09.832 --> 00:07:11.832 in the lighting panel. 00:07:12.981 --> 00:07:15.338 Adjustments can be made here to artificially 00:07:15.338 --> 00:07:18.705 change the potential bounce of light from a lit surface. 00:07:20.307 --> 00:07:22.307 Adjust the mount of indirect light 00:07:22.307 --> 00:07:24.307 in the scene, and more. 00:07:26.982 --> 00:07:28.982 In addition to lights we can use 00:07:28.982 --> 00:07:32.328 emissive surfaces to contribute to the scene's lighting. 00:07:33.421 --> 00:07:35.421 This scene is lit with a variety of lights 00:07:35.421 --> 00:07:39.297 and light types, including emissive surfaces. 00:07:39.297 --> 00:07:42.550 Emissive surfaces are a light source, 00:07:42.550 --> 00:07:46.836 but they behave very much like indirect bounced light. 00:07:46.836 --> 00:07:48.836 The primary emissive surfaces in the scene 00:07:48.836 --> 00:07:50.836 are in the main corridor junction. 00:07:51.194 --> 00:07:54.044 But additional panels are located throughout the scene. 00:07:56.644 --> 00:07:58.644 All of these emissive surfaces use 00:07:58.644 --> 00:08:00.872 the standard shader's Emission property 00:08:01.814 --> 00:08:04.255 by adjusting the Emissive scale. 00:08:04.255 --> 00:08:07.382 The float value next to the Emission property 00:08:07.382 --> 00:08:09.229 and by adding a touch of colour, 00:08:09.229 --> 00:08:11.229 the mood of our scene changes. 00:08:13.697 --> 00:08:16.996 As these lights can participate in realtime light mapping 00:08:16.996 --> 00:08:18.996 they can be controlled at runtime using 00:08:18.996 --> 00:08:20.996 code or animation to create 00:08:20.996 --> 00:08:22.996 complex changes in mood 00:08:22.996 --> 00:08:24.996 while our projects are running. 00:08:28.200 --> 00:08:30.200 The final contributing factor in lighting 00:08:30.200 --> 00:08:32.200 a Unity scene are probes. 00:08:32.822 --> 00:08:34.822 There are 2 types of probes in Unity. 00:08:35.425 --> 00:08:36.931 Light probes 00:08:37.915 --> 00:08:39.915 and reflection probes. 00:08:41.121 --> 00:08:43.121 Light probes sample the lighting in the scene 00:08:43.121 --> 00:08:45.121 at different positions in the world. 00:08:46.892 --> 00:08:49.568 The information in these probes can be used 00:08:49.568 --> 00:08:51.568 to light dynamic elements in the scene 00:08:52.944 --> 00:08:55.912 such as characters or other moving objects 00:08:55.912 --> 00:08:57.912 at a low cost to performance. 00:09:02.492 --> 00:09:04.492 Reflection probes on the other hand 00:09:04.492 --> 00:09:06.492 act as a single point of reference to 00:09:06.492 --> 00:09:08.492 calculate reflections from 00:09:09.114 --> 00:09:11.114 Surrounding each reflection probes 00:09:11.114 --> 00:09:13.114 is a cuboid that specifies 00:09:13.114 --> 00:09:15.618 what should be included in that reflection. 00:09:16.522 --> 00:09:19.840 These probes sample the elements surrounding them 00:09:19.840 --> 00:09:21.840 using box projection, 00:09:21.840 --> 00:09:23.840 and store that information in a cube map. 00:09:26.779 --> 00:09:28.779 Materials with reflective surfaces 00:09:28.779 --> 00:09:32.656 that are on objects within the reflection probe's volume 00:09:32.656 --> 00:09:34.656 can then reference this cube map to 00:09:34.656 --> 00:09:36.352 create reflective surfaces. 00:09:36.939 --> 00:09:38.939 By default there is one built-in 00:09:38.939 --> 00:09:41.070 reflection probe in every scene. 00:09:41.070 --> 00:09:43.070 This default reflection probe 00:09:43.070 --> 00:09:46.486 reflects the sky box to create basic reflections. 00:09:46.486 --> 00:09:48.486 For more detail in the reflections 00:09:48.486 --> 00:09:50.486 additional reflection probes 00:09:50.486 --> 00:09:52.486 should be added and positioned appropriately 00:09:52.486 --> 00:09:54.486 for the reflective objects. 00:09:57.124 --> 00:09:59.919 It is worth noting that phyically-based rendering 00:09:59.919 --> 00:10:01.919 works best in linear colour space. 00:10:02.484 --> 00:10:04.484 Linear colour space will give 00:10:04.484 --> 00:10:07.621 a more realistic and mathematically correct result. 00:10:09.788 --> 00:10:11.788 For best results make sure that 00:10:11.788 --> 00:10:13.788 the colour space is set to linear 00:10:13.788 --> 00:10:15.788 in the project's 00:10:15.788 --> 00:10:17.788 Player Settings window. 00:10:18.919 --> 00:10:22.065 Linear colour space is the default setting. 00:10:22.988 --> 00:10:24.988 Be aware that not all platforms 00:10:24.988 --> 00:10:26.988 support linear colour space however, 00:10:26.988 --> 00:10:28.988 and that gamma is currently the 00:10:28.988 --> 00:10:31.964 required colour space for most mobile platforms,. 00:10:35.280 --> 00:10:37.280 When looking at all these aspects 00:10:37.280 --> 00:10:39.280 to lighting a scene in Unity 00:10:39.280 --> 00:10:41.906 they can be summed up effectively 00:10:41.906 --> 00:10:44.210 with the main contributory factors. 00:10:46.544 --> 00:10:47.914 Ambient light. 00:10:48.762 --> 00:10:50.762 Reflections. 00:10:50.762 --> 00:10:52.762 And light sources. 00:10:53.271 --> 00:10:55.271 Working with materials created 00:10:55.271 --> 00:10:57.271 with the standard shader being 00:10:57.271 --> 00:11:00.182 drawn using phyically-based rendering 00:11:00.182 --> 00:11:02.182 with global illumination to calculate 00:11:02.182 --> 00:11:04.182 the indirect light and create 00:11:04.182 --> 00:11:07.308 more complex, more realistic scenes.