Unreal Engine 4 - Lighting

A lecture about lighting modes, shadows, Global Illumination, Lightmass, post process, fog and manipulation via materials

VFX
Unreal Engine
lightning
learning
graphics
games
  1. Home
  2. Google Slide
  3. Unreal Engine 4 - Lighting

Unreal Engine 4 - Lighting

A lecture about lighting modes, shadows, Global Illumination, Lightmass, post process, fog and manipulation via materials

VFX, Unreal Engine, lightning, learning, graphics, games

Hristo Enchev 171005

Unreal Engine

Lighting

Technical Overview

What will this lecture cover

2

The difference between the types of lighting modes

The difference between the types shadows

How does Global Illumination and Lightmass work, and what contributes to them

What else contributes to lighting: Post Process and Fog

Light manipulation via materials - light functions, lightmass replace, volume particles etc

Unreal Engine Docs link

2

Legend

3

Lightmass - The system which creates baked lightmaps. It computes complex light interactions like area shadowing diffuse interreflection, and indirect lighting contribution.

Global Illumination, GI for short - A system that models how light is bounced off of surfaces onto other surfaces (indirect light)

Mesh Distance Fields - Unreal’s version of Signed Distance Fields (SDF) that represent Static Meshes. They work by storing the distance to the nearest surface in a volume texture.

3

4

Lighting Types

and

Actors

4

Lighting modes

5

Static - Fully baked, which means that the light cannot be changed in game. This is the fastest method for rendering.

Stationary - Partially baked lighting which means static geometry baked by Lightmass and all other lighting will be dynamic. This setting also allows for the light to change color and intensity in game, as well as contribute to GI but, it does not move

Moveable - Dynamic lighting which means the light is totally dynamic and allows for dynamic shadows. This is the slowest in terms of rendering but allows for the most flexibility during gameplay.

Emissive* - The contribution emissive materials bring to GI when Lightmass is baked

docs

5

Lighting Actors

6

The Directional Light simulates light that is being emitted from a source that is infinitely far away. This means that all shadows cast by this light will be parallel.

Point Lights work much like a real world light bulb, emitting light equally in all directions from just a single point in space.

A Spot Lights emit light from a single point in a cone shape.

The Rect Lights (aka Area Lights) emit light into the scene from a rectangular plane with a defined width and height.

The Sky Light captures the distant parts of your level and applies that to the scene as a light. That means the sky’s appearance and its lighting/reflections will match, even if your sky is coming from atmosphere, layered clouds, skybox, etc.

docs

6

Directional Light

7

Hold Ctrl+L to move the directional light in your scene even if you don't have it in view/selected.

This light greatly influences GI

Enable Atmospheric/Fog Sun Light to allow it to influence

Atmospheric/Env Height Fog and to be able to access the

Light vector in any material.

By default the directional light uses cascaded shadow

Maps, they have a limited range of 20k uu, consider using

Distance Field Shadows to extend that to 100k if your

world is big

You can force baked shadows on movable objects thanks to the Volumetric Lightmaps

docs

7

Point Light

8

A single point light is roughly 6 times more computationally expensive than a spot light, think of it as a camera, in order to see 360 degrees, you need 6 lenses.

Only use a dynamic or stationary point light, if you can't achieve your desired effects with a spot light.

Holding L and clicking anywhere in the editor viewport will spawn a point light in that world location.

docs

8

Spot Light

9

Relatively 6 times cheaper than a point light

Volumetrics and light functions look best on it

Within the Inner Cone Angle, the light achieves full brightness.

while between Inner to Outer Cone Angle, a falloff takes place.

docs

9

Rect Lights

10

Within the Inner Cone Angle, the light achieves full brightness. While with Outer Cone Angle, a falloff takes place.

Useful for televisions or monitor screens, overhead lighting fixtures etc.

If you set your Rect Light to Stationary, you may be able to achieve better quality shadows by also enabling the Use Area Shadows for Stationary Light setting.

docs

10

More Rect Lights

11

If your Rect Light is set to Static or Stationary, Lightmass takes the width and height of the light into account when it computes the illumination cast from the light source.

If your Rect Light is set to Movable, the width and height of the rectangle are only used for specular reflections. The actual light is emitted outward from the center of the Rect Light, similar to a Point Light

docs

11

Sky Lights

12

Sky light requires scene data to work, so it needs either a cubemap or to capture the scene itself.

Directionality from cubemaps is possible, and it works on both Sky Lights and volumetric fog

Static Sky Lights capture automatically when building lighting. But for

Stationary or Movable updates happen once on load and when Recapture Sky is called.

Sky Lights contribute greatly to GI and supports multiple bounces

Only the emissive contribution of Materials can be captured with a Static Sky Light

docs

12

Sky Lights - Distance Field Ambient Occlusion

13

Sky lights use Distance Field Ambient Occlusion to calculate shadows and occluded areas when dynamic. This is disabled by default, hence you need to enable Mesh Distance Fields in your project to make use of DFAO

DFAO works best with uniformly scaled objects, and will loose detail on small and highly detailed objects

The global Mesh Distance fields are used for DFAO on all objects except ones close to the camera

You can visualize Distance Fields via

Show > Visualize > Mesh Distance Fields

Look up Bent Normals in the docs and their contribution if you want to use this approach

docs

13

Material Light Functions

14

Works only on Stationary and Movable lights

In essence it is a Material that can be applied to filter a light's intensity

It cannot change the color of lights using a Light Function, only the Light Color setting can do that

The caustics are done via light functions on spotlights

This illustrates a usage of LF, but doesn't necessarily mean caustics should be built using them for a game

docs

Simple Light Flicker in a LF

14

IES profiles

15

Illuminating Engineering Society profiles are a lighting industry standard method of diagramming the brightness and falloff of light as it exits a particular real world light fixture.

Significantly cheaper than Light Functions and physically accurate

Do not use IES where spotlight cone angles could create the same effect.

They are not an actual texture

You can download profiles from most official sites of light manufacturers

docs

15

Geographically Accurate Sun 4.24+

16

The Sun Position Calculator plugin gives you fine control over the Sun's position based on a geographic location and date in time

When adding a SunSky Actor to your scene, it's best to remove any Directional Light, Sky Light, or SkyAtmosphere actors already present

The project setting for Extend default luminance range in Auto Exposure settings is required for this SunSky Actor to display correctly without editing its properties.

docs

16

HDRI Backdrop lighting actor

17

Geared towards product visualization

This actor allows you to easily get

Background mesh (such as a sky dome or custom geometry)

Ambient lighting from a Dynamic Sky Light

Dynamic reflections

Ground projection with shadow catching

docs

17

Lighting Performance

18

With Movable(dynamic) lights the performance cost comes primarily from the number of meshes affected by the light, and the triangle count of those meshes. This means that a shadow-casting, movable light with a large radius will cost many times more than a movable light with a small radius.

Be careful when using multiple directional lights as they can quickly eat up performance due increased triangle count from dynamic shadows

Unreal already drastically increases lighting performance by caching. Meaning when a point or spot light is not moving, the shadow map for that light is stored to be reused it next frame. This makes shadow casting movable Point and Spotlights much more affordable in games where the environment is often not moving.

You can customize Unreal’s engine scalability by manually adding certain lighting features to be enabled and disabled on various quality settings

If your project uses fully dynamic lighting, unchecking "Allow Static Lighting" in project settings allows you use AO in Materials for surfaces lit by a Movable Skylight and it reduces pixel and texture overhead in most materials since they no longer need to sample static lighting textures.

18

19

Shadows

19

Shadows and their relation to mobility

20

Static Shadows - Shadows calculated for static geometry via LightMass and pre-baked. They have minimal cost at runtime, biggest one being memory, which is the _BuildData file for every level

Stationary Light Shadows - A baked/runtime hybrid model which blends shadow approaches. This enables you to use the benefits from both approaches by casting dynamic shadows only on Movable objects

Directional Light Cascading Shadow Maps - Whole scene shadows in conjunction with static ones. Faded over distance via Dynamic Shadow Distance StationaryLight

Dynamic Shadows - Cast by Movable lights, nothing is baked. And it works on Static Meshes, Skeletal Meshes, effects, etc… regardless of their mobility

Static vs Stationary Directional light

docs

20

Shadows and their relation to mobility

21

Each movable object creates two dynamic shadows from a stationary light:

a shadow to handle the static world casting onto the object, and one to handle the object casting onto the world. This means the cost can vary from very little to a large amount, depending on how many dynamic objects there are. With enough dynamic objects, it is more efficient to use a Movable light instead.

Dynamic shadows on use the ob

Unreal Engine 4 - Lighting
Info
Tags VFX, Unreal Engine, Lightning, Learning, Graphics, Games
Type Google Slide
Published 28/04/2024, 15:47:24

Resources

Animation/VFX/Game Industry Job Postings
VFX Salaries
Computer Graphics Resources
Cyberpunk 2077 Settings Optimization