Placeholder Image

Subtitles section Play video

  • 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.

Lights.

Subtitles and vocabulary

Click the word to look it up Click the word to find further inforamtion about it