Lights – Unity Official Tutorials


Lights. Just like the real world, in Unity we use lights to illuminate our scenes. Without lights nothing would be visible to the cameras in our scene. Broadly there are two types of lighting in Unity dynamic and baked lighting. Dynamic lighting is calculated in real time while our game is running. This can be achieved simply by adding lights to our scene. Baked lighting is calculated offline and saved to a texture. These lighting texture maps are then applied to the baked objects in the scene for improved performance. For more information on baked and dynamic lighting see the lesson linked below. To light our scene we use the Light component. Like all components in Unity the light component is attached to a game object. We can move the light within our scene using the game objects transform. The light component has four different types of lights. The Point Light, the Directional Light, the Spot Light and for baked lighting only, the Area Light. Each of these types behave completely differently in the way they effect the look of our game. The point light behaves like a bare light bulb. The point light illuminates objects in the scene based on the light’s position in the scene. Rotation has no influence on the light as this light shines equally in all directions. The directional light behaves like the sun. Directional lights effect all the objects in the scene lighting them based on the direction of the light set by the game object’s rotation. Position in the scene is irrelevant. Spot lights behave like a flashlight or headlamps on a car. They point in a direction based on their transform’s rotation and illuminate all objects within a cone. So spot lights respond to both rotation and position. Area lights only work when baking a light map. Area lights shine in all directions to one side of a rectangular plane. In addition to these four main types of lights there are two other items that can influence the lighting in the scene. Ambient light and emissive materials. Ambient light controls global non directional lighting in the scene. Ambient light works with both dynamic and baked lighting. For complete control set the ambient light to black and use only the lighting in the scene. Emissive materials are created by setting the emission property in an appropriate self-illuminating shader. Emissive materials work only with baked lighting. For more information see the lessons link below. There are several properties that let us customise the light. Range determines how far a light is emitted from the centre of the game object holding the light component. Range only works with point and spot lights. When we have spot selected as our light type we also have access to the spot angle property. Spot angle determines the angle of the cone used by the spot light in degrees. Colour will control the colour of the light. Note the scene gizmo colour will change to match the colour property. Intensity controls the brightness of the light and this is independent of range. When trying to light a scene, a combination of all of these properties are needed to create effective lighting. Our lights may appear brighter as we increase both intensity and range. But they both have different behaviours in the way that they light our scene. As well as simple illumination lights can also use a number of effects. Shadows, flares, halos and something called a Cookie. A cookie acts like a virtual mask or flag in front of the light to create a patterned shadow. Cookies use the alpha channel of a texture to give the light a projected shadow pattern. Cookies must be a 2D texture when working with spot and directional lights. Cookies must be a cube map when using a point light. This makes sense when you think about the fact that both spot and directional lights are shining in one direction and point lights are shining in all directions. When using directional lights there is an option to change the cookie’s size, scaling the pattern in the scene. Cookies do not work with area lights. When using baked lighting cookies only work with spot lights and are ignored for baked point lights and baked directional lights. Shadows. There are two types of shadows available when casting shadows from a light. Hard and Soft shadows. Hard shadows are the most efficient. Soft shadows are often more convincing. But they’re most expensive to render. When rendering shadows there are several options. Strength sets the value of the darkness of the shadow. Adjust this value until the shadow seems correct in the scene. Full strength, or the value of 1 is often too strong. Resolution is simply a quality setting. By default a light will use the value you set in quality settings. These values can be overridden here on a per light basis. For more information see the lesson on quality settings. Bias controls an offset value to optimise shadow rendering from any given light. Bias is a setting that effects how far from objects the shadows will start. Values that are too low will produce artefacts, but values that are too high will mean that the objects appear to be hovering. When using directional lights with soft shadows there are two additional settings. Softness and softness fade. The softness is how harsh the lines of the shadow will be and the softness fade is a measure of how far from the camera the soft shadows are drawn. For more information please see the documentation on lights linked below. Draw Halo will draw the default scene halo around the light. Halos respond to both the range and intensity of the light. Details for the default halo can be set in the scene’s render settings. To override the default halo this setting should be left off and an individual halo component should be used instead. A flare is similar to a halo but imitates a bright light source seen through optical glass. When a flare asset is loaded in to the flare slot the light will render using a lens flare. Flares only respond to the intensity of the light. A lens flare component can be attached directly to the game object but then the flare property on the light should remain empty or there will be two flares rendered on the light. A flare layer component must be attached to a camera for that camera to render a flare element. Render Mode. There are two different methods of rendering dynamic lights using vertex lighting and using per pixel lighting. Vertex lighting is usually the fastest and calculates the scene’s lighting at the vertices of an objects mesh. The lighting is then interpolated over the surface of the mesh. Per pixel lighting is calculated at every screen pixel which is more expensive. While pixel lighting is slower to render it does allow for some effects that are not possible with vertex lighting. Normal mapping, light cookies and real time shadows are only rendered for pixel lights. Spot light shapes and specular highlights are much better when rendered in pixel mode as well. Lights have a big impact on rendering speed. The number of pixel lights can be limited in the quality settings by using the pixel light count property. When you are in the forward rendering path render mode gives explicit control over whether a light should be rendered as a vertex or pixel light. Important will force the light to be rendered per pixel and not important will force the light to be rendered in a faster mode using per vertex or spherical harmonics. For more information on render mode and render path see the documentation link below. Subtitles by the Amara.org community

27 thoughts on “Lights – Unity Official Tutorials

  1. Great Tutorial. Unity really needed to do some of there own videos for new comers to the engine, with these I feel they hit the nail on the head. THANK YOU!

  2. How did you guys get those light rays to shine off objects? 😀 tnx in advance

  3. Dear Unity, how come game scenes like the one shown in this tutorial look amazing and realistic, while the scenes that I create always look have those 'Slenderman' graphics (bad, unrealistic, ugly)?

  4. beacause those post processing effects (and most of the pretty stuff) are only on the pro edition

  5. Holy shit, I just tried the free Pro trial and you're right.. just dragging a few scripts around does turn your game into a masterpiece with Far Cry 3 graphics! O.o!

    I would buy the pro version if it didn't cost so freaking much.. damn…

  6. My goodness… Cookies, and baked? All these food references are making me hungry ): WHYYY OH WHY

  7. Unity offers subscription-based access to Unity Pro now. You can make smaller monthly payments to access Pro features. It's a new option available to make Unity Pro more accessible to more developers, as an option in addition to buying the full version as standalone at full price.

    Gotta love dat' Unity!

  8. I have pro, but I tried EVERY quality setting but my shadows won't show up

  9. In the inspector of the lights theres an option for what type of shadow you want, No shadows, Hard shadows, soft shadows, pick from there as the video shows

  10. Can you tell me how can I make button with on/off light? I have hover script, but it's for changing scenes and sound when clicking. I really need it, can you help me? Thanks!

  11. Is there a way to detect the brightness where a game object is placed for dynamic shadows? Something like in the Thief or Splinter Cell games!

  12. When I use a Point light and enable shadows, Unity 3D saids "only directional lights have shadows in forward rendering".
    Help please, thanks.

  13. This is out of date, please remove / archive out of date videos, it is very confusing.

  14. I like the idea of light darkening everyhing to be illumiated by other lights

  15. also dont forget to say that mixed mode with light probes after baking does not render realtime shadows at all. This engine is just too frustrating. And a year after that bug is found you still did nothing

  16. I am working on a game that will take place in one area, and I'm not sure how to make the texturing any good. How can you have different material properties for pieces of the same texture?

  17. Does anyone know where i can find a video that teaches you how to use light?

Leave a Reply

Your email address will not be published. Required fields are marked *