1 00:00:02,635 --> 00:00:06,218 Lighting in Unity is more fully featured than ever. 2 00:00:07,635 --> 00:00:11,786 The lighting pipeline includes realtime global illumination, 3 00:00:11,786 --> 00:00:15,109 in addition to traditional baked light mapping techniques. 4 00:00:16,621 --> 00:00:19,710 These combined with physically-based rendering 5 00:00:19,710 --> 00:00:21,297 and the standard shader 6 00:00:21,297 --> 00:00:25,421 give more power and versatility to light more complex scenes. 7 00:00:28,492 --> 00:00:32,688 Unity uses physically-based rendering, or PBR 8 00:00:32,688 --> 00:00:35,699 to create a friendly way of achieving a consistent 9 00:00:35,699 --> 00:00:39,956 plausible look for materials under all lighting conditions. 10 00:00:39,956 --> 00:00:44,764 In order to do so, Unity models how light actually behaves 11 00:00:44,764 --> 00:00:46,764 and follows the laws of physics on how 12 00:00:46,764 --> 00:00:48,764 light interacts with materials. 13 00:00:49,612 --> 00:00:53,704 These materials are usually created using the standard shader. 14 00:00:53,704 --> 00:00:55,704 The standard shader makes physically 15 00:00:55,704 --> 00:00:58,749 based rendering easy and accessible to use. 16 00:01:01,322 --> 00:01:03,322 One of the most powerful tools in the Unity 17 00:01:03,322 --> 00:01:07,195 pipeline is Unity's realtime global illumination, 18 00:01:07,195 --> 00:01:08,948 or GI. 19 00:01:08,948 --> 00:01:12,404 Using GI, all lights in the scene can effect 20 00:01:12,404 --> 00:01:14,923 the object's within range with both 21 00:01:14,923 --> 00:01:17,928 direct and indirect illumination. 22 00:01:17,928 --> 00:01:19,928 Direct illumination comes from lights 23 00:01:19,928 --> 00:01:23,564 shining directly on the objects in the scene. 24 00:01:23,564 --> 00:01:25,564 Indirect illumination however 25 00:01:25,564 --> 00:01:28,780 is the light reflected, or bounced off of 26 00:01:28,780 --> 00:01:30,780 the light surfaces in the scene. 27 00:01:31,364 --> 00:01:33,364 This bounced indirect light 28 00:01:33,364 --> 00:01:35,364 can illuminate nearby objects 29 00:01:35,364 --> 00:01:38,694 mimicking how light behaves in the real world 30 00:01:38,694 --> 00:01:40,694 This indirect light is effected 31 00:01:40,694 --> 00:01:43,551 by the colour of the surfaces it bounces off of, 32 00:01:43,551 --> 00:01:47,375 taking a contribution of that surface's colour with it. 33 00:01:47,375 --> 00:01:49,375 Direct and indirect light will 34 00:01:49,375 --> 00:01:52,971 blend together to create a much more realistic look. 35 00:01:56,368 --> 00:01:58,368 In addition to the default main camera 36 00:01:58,368 --> 00:02:00,368 a new scene in Unity comes with 37 00:02:00,368 --> 00:02:02,368 a default sky box 38 00:02:02,368 --> 00:02:04,368 and a default directional light aligned 39 00:02:04,368 --> 00:02:06,368 with that sky box. 40 00:02:09,609 --> 00:02:11,609 Each scene also contains default 41 00:02:11,609 --> 00:02:13,609 values for ambient light. 42 00:02:14,683 --> 00:02:17,974 Ambient light illuminates all surfaces in the scene. 43 00:02:19,435 --> 00:02:22,015 Ambient light is controlled by the settings in the 44 00:02:22,015 --> 00:02:24,523 lighting panels Environment Lighting tab. 45 00:02:27,783 --> 00:02:29,783 Ambient light can be created by either 46 00:02:29,783 --> 00:02:31,783 using a sky box, 47 00:02:32,650 --> 00:02:35,917 a user generated gradient of 3 colours, 48 00:02:44,208 --> 00:02:46,208 or a single colour. 49 00:02:54,593 --> 00:02:56,593 All objects added to the scene 50 00:02:56,593 --> 00:02:58,499 will receive ambient light 51 00:02:58,499 --> 00:03:01,881 unless the ambient intensity value is set to 0 52 00:03:02,898 --> 00:03:06,265 or the ambient light's colour values are set to black. 53 00:03:08,093 --> 00:03:10,093 It is rare, if not impossible 54 00:03:10,093 --> 00:03:12,093 for any real-world material 55 00:03:12,093 --> 00:03:15,638 to have absolutely no reflectivity. 56 00:03:15,638 --> 00:03:18,676 By default all objects in the scene 57 00:03:18,676 --> 00:03:21,433 will also receive reflection information. 58 00:03:22,055 --> 00:03:25,630 Even though the cube, sphere and plane in the scene 59 00:03:25,630 --> 00:03:28,970 are unlit and ambient light is none 60 00:03:28,970 --> 00:03:30,970 they still receive lighting information 61 00:03:30,970 --> 00:03:33,631 in the form of reflections. 62 00:03:33,631 --> 00:03:37,015 The default reflection source is the sky box. 63 00:03:37,015 --> 00:03:40,034 This can be changed to a custom cube map. 64 00:03:40,034 --> 00:03:42,352 To receive no default reflections 65 00:03:42,352 --> 00:03:44,352 either set the custom cube map to none, 66 00:03:47,084 --> 00:03:49,084 or remove the sky box. 67 00:03:52,024 --> 00:03:54,024 It is worth noting that the default sky box 68 00:03:54,024 --> 00:03:56,494 is procedurally generated 69 00:03:56,494 --> 00:03:58,494 and new procedural sky boxes 70 00:03:58,494 --> 00:04:00,494 can be created and saved as assets. 71 00:04:13,646 --> 00:04:15,646 When lighting scenes in Unity 72 00:04:15,646 --> 00:04:17,646 we can work with realtime lighting, 73 00:04:18,475 --> 00:04:19,881 baked lighting, 74 00:04:20,475 --> 00:04:22,053 or a mixture of both. 75 00:04:22,607 --> 00:04:26,129 Realtime lighting is more easily modified at run time. 76 00:04:26,129 --> 00:04:28,129 but it comes at a cost to performance. 77 00:04:29,429 --> 00:04:31,562 Baked lighting on the other hand pre-calculates 78 00:04:31,562 --> 00:04:34,004 much more detailed lighting information 79 00:04:34,004 --> 00:04:36,961 and saves it to a light mapped texture on disc. 80 00:04:37,470 --> 00:04:39,470 This light map information is then 81 00:04:39,470 --> 00:04:41,470 read from the texture at run time, 82 00:04:41,470 --> 00:04:43,470 avoiding the need to do any lighting 83 00:04:43,470 --> 00:04:45,470 calculations when the project is running. 84 00:04:46,450 --> 00:04:48,450 This saves performance, 85 00:04:48,450 --> 00:04:51,846 but at the cost of dynamic changes in the scene. 86 00:04:51,846 --> 00:04:54,722 Baked light maps are not updated at run time. 87 00:04:55,363 --> 00:04:58,975 Lights can be switched between realtime, baked, 88 00:04:58,975 --> 00:05:00,975 and mixed lighting on a per-light basis. 89 00:05:02,256 --> 00:05:04,256 Using baked lighting exclusively 90 00:05:04,256 --> 00:05:07,020 would be more appropriate for target platforms 91 00:05:07,020 --> 00:05:10,844 such as mobile devices with lower performance capabilities. 92 00:05:13,674 --> 00:05:16,011 The light mapping system can either work 93 00:05:16,011 --> 00:05:18,011 continuously or on demand. 94 00:05:19,575 --> 00:05:22,081 When continuous baking is selected 95 00:05:22,081 --> 00:05:25,019 lighting changes will be baked in the background while editing. 96 00:05:25,754 --> 00:05:27,754 These changes can either be properties 97 00:05:27,754 --> 00:05:29,242 adjusted in the inspector, 98 00:05:29,242 --> 00:05:31,926 or objects changed in the scene. 99 00:05:43,058 --> 00:05:45,343 When continuous baking is not selected 100 00:05:46,189 --> 00:05:48,686 changes will only preview on demand. 101 00:05:50,137 --> 00:05:53,426 When the Build button in the lighting panel has been selected. 102 00:06:00,360 --> 00:06:02,360 In this scene there is a directional light 103 00:06:02,360 --> 00:06:05,004 coming in through the skylight in the ceiling. 104 00:06:05,607 --> 00:06:09,488 This light contributes to the illumination of the entire scene 105 00:06:09,488 --> 00:06:11,488 as the light bounces off of the surfaces 106 00:06:11,488 --> 00:06:13,127 it lights directly, 107 00:06:13,127 --> 00:06:16,096 on to other nearby surfaces in an indirect manner. 108 00:06:17,445 --> 00:06:19,445 This light continues to indirectly 109 00:06:19,445 --> 00:06:21,445 illuminate nearby surfaces 110 00:06:21,445 --> 00:06:23,445 until the strength of the light fades 111 00:06:23,445 --> 00:06:24,993 and it can bounce no more. 112 00:06:25,860 --> 00:06:27,594 Decrease the intensity of the light 113 00:06:28,048 --> 00:06:31,132 and the illumination of the scene decreases accordingly. 114 00:06:34,693 --> 00:06:36,693 Likewise, if the directional light 115 00:06:36,693 --> 00:06:38,693 is rotated to directly light a 116 00:06:38,693 --> 00:06:40,562 different part of the scene, 117 00:06:40,562 --> 00:06:43,349 it will now illuminate the scene in a different way, 118 00:06:43,349 --> 00:06:45,971 with both it's direct and indirect lighting. 119 00:06:49,306 --> 00:06:51,948 As materials created with a standard shader 120 00:06:51,948 --> 00:06:55,297 can mimic a wide variety of physical surfaces 121 00:06:55,297 --> 00:06:57,297 and different materials can have different 122 00:06:57,297 --> 00:06:59,030 amounts of reflectivity 123 00:06:59,030 --> 00:07:01,030 this can effect the scene's lighting. 124 00:07:01,690 --> 00:07:05,475 To help balance this the Bounce Intensity can be adjusted 125 00:07:05,475 --> 00:07:07,832 on either a per-light basis 126 00:07:07,832 --> 00:07:09,832 or globally by adjusting the settings 127 00:07:09,832 --> 00:07:11,832 in the lighting panel. 128 00:07:12,981 --> 00:07:15,338 Adjustments can be made here to artificially 129 00:07:15,338 --> 00:07:18,705 change the potential bounce of light from a lit surface. 130 00:07:20,307 --> 00:07:22,307 Adjust the mount of indirect light 131 00:07:22,307 --> 00:07:24,307 in the scene, and more. 132 00:07:26,982 --> 00:07:28,982 In addition to lights we can use 133 00:07:28,982 --> 00:07:32,328 emissive surfaces to contribute to the scene's lighting. 134 00:07:33,421 --> 00:07:35,421 This scene is lit with a variety of lights 135 00:07:35,421 --> 00:07:39,297 and light types, including emissive surfaces. 136 00:07:39,297 --> 00:07:42,550 Emissive surfaces are a light source, 137 00:07:42,550 --> 00:07:46,836 but they behave very much like indirect bounced light. 138 00:07:46,836 --> 00:07:48,836 The primary emissive surfaces in the scene 139 00:07:48,836 --> 00:07:50,836 are in the main corridor junction. 140 00:07:51,194 --> 00:07:54,044 But additional panels are located throughout the scene. 141 00:07:56,644 --> 00:07:58,644 All of these emissive surfaces use 142 00:07:58,644 --> 00:08:00,872 the standard shader's Emission property 143 00:08:01,814 --> 00:08:04,255 by adjusting the Emissive scale. 144 00:08:04,255 --> 00:08:07,382 The float value next to the Emission property 145 00:08:07,382 --> 00:08:09,229 and by adding a touch of colour, 146 00:08:09,229 --> 00:08:11,229 the mood of our scene changes. 147 00:08:13,697 --> 00:08:16,996 As these lights can participate in realtime light mapping 148 00:08:16,996 --> 00:08:18,996 they can be controlled at runtime using 149 00:08:18,996 --> 00:08:20,996 code or animation to create 150 00:08:20,996 --> 00:08:22,996 complex changes in mood 151 00:08:22,996 --> 00:08:24,996 while our projects are running. 152 00:08:28,200 --> 00:08:30,200 The final contributing factor in lighting 153 00:08:30,200 --> 00:08:32,200 a Unity scene are probes. 154 00:08:32,822 --> 00:08:34,822 There are 2 types of probes in Unity. 155 00:08:35,425 --> 00:08:36,931 Light probes 156 00:08:37,915 --> 00:08:39,915 and reflection probes. 157 00:08:41,121 --> 00:08:43,121 Light probes sample the lighting in the scene 158 00:08:43,121 --> 00:08:45,121 at different positions in the world. 159 00:08:46,892 --> 00:08:49,568 The information in these probes can be used 160 00:08:49,568 --> 00:08:51,568 to light dynamic elements in the scene 161 00:08:52,944 --> 00:08:55,912 such as characters or other moving objects 162 00:08:55,912 --> 00:08:57,912 at a low cost to performance. 163 00:09:02,492 --> 00:09:04,492 Reflection probes on the other hand 164 00:09:04,492 --> 00:09:06,492 act as a single point of reference to 165 00:09:06,492 --> 00:09:08,492 calculate reflections from 166 00:09:09,114 --> 00:09:11,114 Surrounding each reflection probes 167 00:09:11,114 --> 00:09:13,114 is a cuboid that specifies 168 00:09:13,114 --> 00:09:15,618 what should be included in that reflection. 169 00:09:16,522 --> 00:09:19,840 These probes sample the elements surrounding them 170 00:09:19,840 --> 00:09:21,840 using box projection, 171 00:09:21,840 --> 00:09:23,840 and store that information in a cube map. 172 00:09:26,779 --> 00:09:28,779 Materials with reflective surfaces 173 00:09:28,779 --> 00:09:32,656 that are on objects within the reflection probe's volume 174 00:09:32,656 --> 00:09:34,656 can then reference this cube map to 175 00:09:34,656 --> 00:09:36,352 create reflective surfaces. 176 00:09:36,939 --> 00:09:38,939 By default there is one built-in 177 00:09:38,939 --> 00:09:41,070 reflection probe in every scene. 178 00:09:41,070 --> 00:09:43,070 This default reflection probe 179 00:09:43,070 --> 00:09:46,486 reflects the sky box to create basic reflections. 180 00:09:46,486 --> 00:09:48,486 For more detail in the reflections 181 00:09:48,486 --> 00:09:50,486 additional reflection probes 182 00:09:50,486 --> 00:09:52,486 should be added and positioned appropriately 183 00:09:52,486 --> 00:09:54,486 for the reflective objects. 184 00:09:57,124 --> 00:09:59,919 It is worth noting that phyically-based rendering 185 00:09:59,919 --> 00:10:01,919 works best in linear colour space. 186 00:10:02,484 --> 00:10:04,484 Linear colour space will give 187 00:10:04,484 --> 00:10:07,621 a more realistic and mathematically correct result. 188 00:10:09,788 --> 00:10:11,788 For best results make sure that 189 00:10:11,788 --> 00:10:13,788 the colour space is set to linear 190 00:10:13,788 --> 00:10:15,788 in the project's 191 00:10:15,788 --> 00:10:17,788 Player Settings window. 192 00:10:18,919 --> 00:10:22,065 Linear colour space is the default setting. 193 00:10:22,988 --> 00:10:24,988 Be aware that not all platforms 194 00:10:24,988 --> 00:10:26,988 support linear colour space however, 195 00:10:26,988 --> 00:10:28,988 and that gamma is currently the 196 00:10:28,988 --> 00:10:31,964 required colour space for most mobile platforms,. 197 00:10:35,280 --> 00:10:37,280 When looking at all these aspects 198 00:10:37,280 --> 00:10:39,280 to lighting a scene in Unity 199 00:10:39,280 --> 00:10:41,906 they can be summed up effectively 200 00:10:41,906 --> 00:10:44,210 with the main contributory factors. 201 00:10:46,544 --> 00:10:47,914 Ambient light. 202 00:10:48,762 --> 00:10:50,762 Reflections. 203 00:10:50,762 --> 00:10:52,762 And light sources. 204 00:10:53,271 --> 00:10:55,271 Working with materials created 205 00:10:55,271 --> 00:10:57,271 with the standard shader being 206 00:10:57,271 --> 00:11:00,182 drawn using phyically-based rendering 207 00:11:00,182 --> 00:11:02,182 with global illumination to calculate 208 00:11:02,182 --> 00:11:04,182 the indirect light and create 209 00:11:04,182 --> 00:11:07,308 more complex, more realistic scenes.