top of page

Lighting in UE4

Types of Lights

Directional Light

A Directional Light emulates a light source that is far away, and all shadows cast by this light are parallel. This type of light is most commonly used to simulate sunlight in UE4. Where the directional light is placed defines the location of the sun. A Day / Night cycle can be simualted using a directional light and the light can rotated to the preferred angle.

A variety of settings can be changed to directional lights to give them different features and change the way they interact with the scene.

As well as being able to change the mobility of directional lights by setting them as static, stationary or movable, you can choose the light intensity, colour, roughness, shadow bias and other settings by selecting the light and then changing the settings in the details panel. Directional lights can also be used as the sun light, by ticking Atmosphere Sun Light in the details panel, this effect is turned on. Ticking or un-ticking Atmopsphere Sun Light, Affects world, Cast Shadows and Use Temperature will change how the light affects the scene accordingly.

Here is a list of the details and settings that can be changed for directional lighting:

Spot Light

A Spot Light creates a cone shaped light that emits from a single source. This type of light works like a flash light or a stage spotlight. There are 2 cones of light emitted from a spot light, the Inner Cone Angle and the Outer Cone Angle. The Inner Cone Angle has the brightest light, then the light softens as widens going towards the edge of the Outer Cone Angle.

Left: Point Light Right: Spot Light

Spot Lights are often used as flashlights in games. By creating a spot light component and setting the parameters that are wanted for the flashlight and attaching it to the character mesh, it can be used as the characters main light source - this is especially good for creating a dark/creepy atmosphere for horror games.

Various settings can be changed in the details panel for spotlights, as with directional lights. Here is a list of settings that spot lights can have:

Point Light

A Point Light works like a lightbulb, it will emit light equally in all directions from a single point. In UE4, we can control the radius of a point light, so we can control how far the light reaches. Point Lights can be used as bulbs in a scene but can also be used for different types of light like flames.

Point lights have a uniformity that means the light emitted from them will go the same amount in each direction. The size, shape and radius of a point light can be changed in the settings.

Below are a list of settings for point lights.

Sky Light

A Sky Light applies to the whole scene, and will match the lighting and shadows on the scene to the sky's appearance. It creates an even light to all the surfaces in the level. Sky Lights also stop indoor areas from getting lit by the sky through it's use of local shadowing.

When lighting a scene with both outdoor and indoor areas, a sky light should always be used as it supports local shadowing, meaning that it will differentiate between indoors and outdoors, making sure that the lighting won't go through into indoor areas and the the lighting and shadows will look more realistic.

A sky light will change how it captures the scene dependent on the settings. Static Sky Lights will automatically capture the scene when lighting is updated, while Stationary or Movable Sky Lights will only capture the scene when 'Recapture Sky' is called using the option in the details panel or adding the node in the blueprints.

The mobility settings of the sky light will change the way it is rendered.

A static sky light will be baked into the lightmap, the same as other static objects. Changes to a static sky light will only be visible when lighting is rebuilt. In mobile game development, sky lights will only be supported in static mobility.

A stationary sky light is also baked into the lightmap and lighting will need to be rebuilt to display the baked shadowing. Stationary sky lights can also use Bent Normals. Using Bent Normals will improve the look of lighting in areas with cracks or small slightly shadowed areas.

A movable sky light uses Distance Field Ambient Occulsion for creating shadowing. To turn on Distance Field Ambient Occulsion, it need to be enabled in the Distance Field features.

One of the settings that can be changed for a Sky Light is Sky Lighting Bounces; this can be changed in the details panel. This decides the number of times the light will bounce off surfaces, with less bounces giving a dimmer look and more bounces creating a lighter look.

Sky Light settings are spilt into Light Settings and Sky Light Settings, and can be accessed from the details panel.

Sky Lights do have some limitations: they cannot capture soft shadowing from moveable objects onto the environment and there is not dynamic recapturing of the scene for staionary and movable Sky Lights.

Rect Lights

A Rect Light emits light in a rectangular shape. The source height and width can be determined by the user in UE4. They are good for simulating televisions or monitor screens, or for any rectangular shaped object that needs to emit light.

Static Lighting

Static lighting creates static shadows that are rendering in place into the lightmap. I have written more about static lighting futher down in the section titled, Light Mobility Settings.

Dynamic Lighting

Dynamic Lighting is a type of rendering in UE4. It is the rendering of scenes using in program calculations. Using Dynamic Lighting creates details for lighting and shadowing that would otherwise be lost. These calculations are constant as a player moves through the game, and change the lighting depending on where the player is and other changing variables.

Eye Adaptation (Auto-Exposure)

Eye Adaption (aka Auto-Exposure) is a setting in UE4, that will adjust the light exposure automatically to type of environment. This replicates what the human eye does naturally, as when moving from a dark area to a bright one, our eyes adjust. In darker environments, our pupils expand to take in more light, and when in brighter environments our pupils retract to take in less light. As this is what we as humans are used to, and dark area would seem too dark and bright areas too bright without it, it is useful to replicate this in games.

The amount of eye adaption can be changed in the level editor, as there is a slider that lets us do this, as well a tick box to turn this feature off. A developer might want to have this off if they want an area to seem particularly dark or bright. The slider will change whether it supports bright or dark scenes more.

As with cameras which try to mimick the human eye, UE4 takes this and uses a lot of the same settings that cameras use to control the light exposure. By having adjustable settings such as shutter speed, ISO, Aperature, etc which were originally all ways of changing the exposure in camera lenses, UE4 takes what people have learnt about mimicking the human eye with cameras and adds it into game development.

There are 3 metering modes for Auto Exposure: Auto Exposure Histogram, Auto Exposure Basic and Manual.

Manual works out the exposure from the Shutter Speed, ISO and Aperture, the same way that manual focus would work on a camera. A Shutter essentially mimics an eyelid, and shutter speed is how fast a blink would be - the slower the shutter speed, the more light is taken in. ISO is the sensitivity to the light. Lower ISO is better for outdoors on a bright day and high ISO is better for dark scenes. Aperture mimics the pupil in our eyes so the higher the aperture, the more light is taken in - like how bigger pupils take in more light. While these settings sound like they do similar things and that having them set automatically would better than adjusting them manually, different effects can be accomplished by using different combinations of settings of Shutter Speed, ISO and Aperture. In UE4, the relationship between the surface luminance and pixel brightness before the tonemapper and exposure compensation are applied are defined by the exposure. The exposure can be tested by turning off tonemapper and comparing the scene brightness with the pixel inspector.

Pre-Exposure, a.k.a Auto Exposure Basic, is the fastest setting, as it uses sampling to calculate the exposure. It does this by using the previous frame's exposure to simulate a similar range of colour.

Auto Exposure Histogram, uses a histogram to work out how to display the exposure. It does this by working out the current luminance which is the average of the pixels darker than 2 set values. Using this, it works out how much it should adapt to changes in the brightness of the environment and how quickly it should adapt. The settings of the histogram can be changed.

With metering mode switched on, the settings can be changed to adjust the brightness and darkness limits as well as the speed in which it adapts, this works for both types of auto exposure, while manual exposure uses the other settings to adjust these properties.

Light Mobility Settings

There are 3 light mobility settings in UE4: Static, Stationary and Movable

Static Lighting

Static lighting (also known as baked lighting) uses lightmaps, which means that their lighting and shadows are baked. This is most often used for ambience lighting or lighting of static models as the shadows cannot move in gameplay. The shadows can be changed during the design process by changing the source radius. Using static lighting can be very useful for creating games designed for lower power devices such as mobile games. Static lighting can offer indirect lighting, give static models high quality shadows and the lighting for all static models can have one lightmap.

The harshness of static lighting can be controlled by light source radius. A smaller light source radius will cast harsher shadows and a larger light source radius will cast softer shadows.

Lightmap Resolution controls the amount of detail. Lightmap resolution at a higher value means it will be more detailed, but it also takes longer to build and takes up more memory.

Stationary Lighting

Stationary lights are lights that are designed to stay in one place, they are different from static lights as stationary lights can change runtime brightness during gameplay while static lights can't change anything during gameplay. However, indirect lighting is still precalculated in a lightmap with stationary lights and won't change during gameplay.

Stationary lights are usually high quality, medium mutability, and medium performance cost. They also use Distance Field Shadows which create detailed shadows. Stationary lights store all the indirect lighting and shadowing in the lightmap.

If stationary lights overlap, they may not all show shadowing. The lights that are being affected by this display a red cross over the light icon. This can also be checked in the StationaryLightOverlap view mode.

Movable Lighting

Moveable Lights are also Dynamic Lights, they cast dynamic light and shadows and can also change their properties and move during gameplay. Moveable lights do not use lightmaps and they don't have any indirect lighting.

These lights have a high performance cost because of the number of meshes affected by the light, and because it renders per frame - the more meshes it affects, the higher the performance cost. Only spot or point lights can be used for movable lighting.

Build Settings and Light Settings in UE4

The quality of the lighting build can be chosen inside UE4 before rendering the lighting - higher quality has a higher render cost. Each light that is placed also has the option to be static, stationary or moveable. The intensity, colour and radius can be changed from the details panel as well. Exposure (how much light is taken in from the viewpoint of the player) can be edited, or can be set as off or auto. The light and shadow maps can also be accessed in UE4.

To change the build settings, the light should be selected and the settings can be changed in the details panel. Some of the settings can be accessed through the level editor. Each type of light has different settings. For each type of light, I have added a list of settings that can be adjusted for that light - see Types of Lights above. Using fog, diffuse boost or other similar affects will also change how the light is distributed and can soften shadows.

Build Configuration Settings can be chosen before the start of a project. There are different build settings for PC and different consoles, and there are also build settings used specifically for debugging.

Scalability

The scalability settings allow the adjustment of quality of different features. Adjusting scalability affects the performance on different platforms and devices, depending on the specs and what the hardware is equipped to run. Higher settings will visually look better but will take more to run, while lower settings will not look as good but will run smoother.

In UE4, the scalability settings can be accessed from the settings menu in the toolbar. The scalability settings that can be changed here are: Overall Quality, Resolution Scale, View Distance, Anti-Aliasing, Post Processing, Shadows, Textures, Effects and Foliage. These can all be set as Low, Medium, High or Epic - with the exception of View Distance which can be set as Near, Medium, Far or Epic and Quality, which has an Auto option.

Material Quality level can also be set in settings menu just under the Scalability settings, this can be set as low or high, and will control how much of the materials will be rendered.

Lightmap UVs and Texture UVs

A Lightmap UV is a separate UV that is specifically for baking lighting and shadowing information onto a static or stationary object. A lightmap can be created either using UE4's Lightmap Auto-Generation tool or by using UV editing tools.

To auto-generate Lightmap UVs for an object, Generate Lightmap UVs needs to be ticked when importing, and a lightmap will be automatically generated based on the objects UVs. Then in the Through the Lightmap Generation settings in the static mesh editor, the lightmap can be adjusted. The Lightmap Generation Settings can also be used to repack existing lightmap UVs as well as create new ones.

A Lightmap UV can also be created manually in the modelling software, such as Maya. Manually creating a Lightmap UV like this is more complicated and time consuming, but can be beneficial to do as there are a bigger range of features to create neater UVs.

Setting up a texture UV is different to setting up Lightmap UV. Lightmap UVs must be laid out flat and can have no overlapping and need padding in between each UV chart to stop light leaking. Texture mapping doesn't have these limitations as textures can be assigned to different parts of the geometry or titling textures can be used.

Lightmap Resolution

Another setting that can be changed in UE4 is the Lightmap Resolution. This controls the efficiency with which the UV space is filled and it sets the default texture resolution for the baked light and shadow texture generated by lightmass. Once set, the resolution will be used for all of the placed static meshes in the level.

Higher powered hardware such as desktops can run higher lightmap resolutions while lower lightmap resolutions are better for consoles and mobile platforms, where there is a more finite amount of memory.

Lightmap Resolution settings are found under the general settings.

Lightmass

Lightmass creates complex lightmaps that use more complicated light interactions like area shadowing and diffuse interreflection and precomputes them. It works with static and stationary lighting. Lightmass can affect indirect lighting bounces, environment colour, environment intesity and diffuse boost.

Lightmass can be found in UE4 by following: settings > world settings > lightmass.

Global Illumination

Global Illumination is the group of algorithms that add more realistic lighting to scenes. Using Global Illumination creates much more realistic lighting than direct illuminations.

Diffuse Interreflection, Character Lighting, Ambient Occlusion, Masked Shadows, Bent Normal Sky Occlusion, Distance Field Shadow Maps, Area lights and Shadows and Translucent Shadows are some lighting techniques used in Global Illumination.

Swarm Agent

The swarm agent communicates between the editor and the lightmass; it can distribute the lighting build to remote machines and manage the lighting build locally. Swarm Agent can be opened to track lighting build progress and manage lighting build progress for various machines.

Lightmass Importance Volume

Lightmass Importance Volume controls the area that Lightmass emits photons in - focusing on areas that are going to be playable and closer to the player; areas not in the Lightmass Importance Volume limits will have a singular light bounce, while areas inside the Lightmass Importance Volume limits will be able to have more light bounces. Many maps have areas with meshes that are at the edge of the level and aren't going to be interacted with, so detailed lighting won't be as important for these areas. By only concentrating on the areas that need it, Lightmass Importance Volume will save running power.

Lightmass Importance Volume can be found by following the menu: Modes > Volumes > Lightmass Importance Volume.

When adding Lightmass Importance Volume, lighting will need to be rebuild for it to take effect.

Lightmass Importance Volume can be added as a cube that covers the area you want to have the most light detail.

Stationary Lights v Movable Lights

There are different situations when stationary lights should be used over movable lights and vice versa.

Movable lights can change most of their properties including position, rotation, colour, brightness, falloff and radius. As none of the light from movable lights is baked into lightmaps, they don't have any indirect lighting. Because of this, movable lights have a higher performance cost, so it is not reasonable to use them unless you need to be able to change a specific function. A few examples of good uses for movable lights are headlights, flashlights, swinging lanterns. Movable lights will also cast dynamic shadows on everything, as none of its light data is baked into a light map.

Unless there is something specific that you need to use a movable light for, Stationary lights are a better option as they have a much lower performance cost.

Dynamic Lighting

Dynamic lighting can be used to create a full sun cycle. By having movable dynamic lighting, the lights can change colour and movement to give the impression of the sun rising and setting and night coming in. As mentioned above, dynamic movable lights are useful for lighting things that would need to move like flashlights, and things that would change colour.

Depending on the settings, dynamic lighting can have more strenuous effect on the performance. Attenuation Radius, Outer Cone Angles, Intensity and the amount of assets that the light effects can change performance and so can be optimised.

I have written about dynamic lighting in more detail further up this blog post.

Fog

Exponential Height Fog can be placed in a scene to create atmosphere. Once it is placed in a scene, many aspects of it can be changed to give it different effects. The Fog Density, Colour, Height Falloff, Max Opacity and Start distance can all be changed in the details panel.

Light and Reflection

Different materials will light differently in UE4. Shiny surfaces will reflect light more intensely while matte surfaces will diffuse the light more. The light will only reflect what it hits so it will leave cracks and crevices dark.

A Sphere Reflection Capture Actor can be placed in a scene with almost no performance cost. This can blend into a scene to capture light reflections. The size of the Sphere Reflection Capture Actor will control how many assets are effected. However, if they overlap, it can create a higher performance cost, so it is better to make sure that they are the right size and in the right position to not overlap.

Distance Field Ambient Occlusion

Distance Field Ambient Occlusion (DFAO) is shadowing for movable sky lights created by using Signed Distance Field Volumes calculated around each still mesh to generate Ambient Occlusion. DFAO supports dynamic scene changes as it will change if meshes are moved or hidden.

DFAO creates very soft shadows and is used for simulating shadows between geometry, it is especially good for cracks and crevices, that other types of shadowing might miss. DFAO bakes this information into an Ambient Occlusion map that is used to simulate the soft shadowing.

To use Distance Field Ambience Occlusion in UE4, follow: Project Settings > Rendering > Lighting > Generate Mesh Distance Fields. Then after restarting UE4: Show > Visulise > Distance Field Ambient Occlusion.

Distance Field Shadows

Distance field shadows can be set once Distance Field Occlusion has been set up. Distance Field Shadows can be edited in the details panel when the directional light is selected.

Light Shafts / Bloom

Light Shafts (or Bloom) replicates the light phonmena of lights appearing very bright, blurred and overwhelming to the eye with the surrounding area appearing much darker when looking at something bright when previously being in a darker area. The Bloom effect makes a light appear much brighter than it actually is by simulating the effect it has on the eye instead. Different light sources could create different varients of bloom, such as lens flare and streaks.

Bloom can be added to a light in UE4 by selecting the directional light, ticking bloom in the details panel and modifying the light shaft settings.

Emissive Lighting

Emisisive Lighting is adding a glow to an asset. This type of lighting doesn't effect the area around the asset, only the asset itself.

To add emissive lighting to an object, it has to first be added to the material. In the material blueprint, emissive lighting can be added by dragging out from Emissive Colour. From here, nodes can be added to control the colour and the brightness of the emissive light. Once this is completed, the material needs to be added to the chosen asset. Use emissive for static lighting must be ticked. The emissive lighting will appear on the object in the scene once lighting has been rebuilt.

 RECENT POSTS: 
 SEARCH BY TAGS: 
No tags yet.

Tip: Press on any item to see the full post.

bottom of page