Always think about where your lighting should come from. Is there sunlight? Is there a lamp nearby? Try to avoid just placing arbitrary lights around your level.
Lightening Techniques in U3:
- Light Point.
- Light Spot.
- Sky Light.
Light Maps and Shadow Maps
Calculating all Lighting and shadowing for your level constantly during gameplay would be crippling to performance. To handle that problem, Unreal generates light maps and shadow maps for all objects and lights that do not move during gameplay.
A light map is a texture generated from a calculation of all of the lights that are illuminating a particular surface or static mesh. The benefit of this is that multiple lights can strike a single surface, and because the actual calculation is done in advance and “baked” in the form of a light map, there is a minimal drop in performance.
A shadow map is very similar to a light map, but stores shadowing data instead of illumination data. Shadow maps also bear a distinct difference from light maps in that while a single light map can define lighting from many different lights, each light must have its own individual shadow map for a given surface. If many lights strike a single surface, the multiple shadow maps are combined to provide the final result
On the left, a level with only light maps. On the right, the same level with light and shadow maps
Static and Dynamic Lighting
Static lights to be lights which do not move during gameplay, meaning that their bMovable property is set to false. Dynamic lights will be considered as lights which can move, or that have their bMovable property set to true.
Per-Vertex Lighting and Lighting Subdivisions
This concept pertains only to the lighting of static meshes.
Per-vertex lighting is basically means that a triangle would only appear lit if one or more of its vertices was receiving any light.
As of Unreal Engine 3.0, lighting is calculated across static meshes using lighting subdivisions. This means that each polygon is internally subdivided into multiple parts, and the light striking each part is calculated. The final result is blended together, resulting in the final lighting for the polygon. Naturally, this calculation is more complex, though the performance hit affects level build times much more than gameplay.
The true benefit of lighting subdivisions comes from being able to change the number of subdivisions used to calculate the lighting across each polygon. The higher your subdivisions, the clearer your shadows will be, though the more calculation will be needed to create your shadows.
Where per-vertex lighting only looks to see if vertices are illuminated, lighting subdivisions allow for multiple sample points across each polygon for a more accurate result.
Types of Lights
There are four primary types of lights are point lights, spot lights, directional lights, and skylights.
The first three types of lights (point, spotlight, and directional) each have two subtypes available. These are toggleable
lights and moveable lights. This means that you can have a normal point light, a toggleable point light, or a moveable point light.
Toggleable are lights can be turned on and off during gameplay. This is done through the use of the Toggle sequence object within Kismet.
Moveable lights, as the name suggests, are dynamic lights that can move throughout your level. This could be anything from a point light that moves along a path to a spotlight that rotates to point at a target. This motion is handled with Matinee.
As with a toggleable light, the light from a moveable light cannot be used in a light map.
Point lights emit light from a single point in all directions, kind of like a light bulb. They are the most often used type of light, especially in indoor levels. The light has a Radius property that controls how far light travels from the location of the actor. Point lights are available in standard static form (PointLight), toggleable (PointLightToggleable), and moveable (PointLightMovable).
Icons for a PointLight, a PointLightToggleable, and a PointLightMovable.
Spot lights emit light from a single point in a confined cone, like a real-world spotlight or flashlight. This cone can be opened and closed to focus the light via the InnerConeAngle and OuterConeAngle properties.
Icons for a SpotLight, a SpotLightToggleable, and a SpotLightMovable
Directional lights are used when simulating an extremely distant light source, such as the Sun, and are usually only used in outdoor situations.
DirectionalLight actors only come is standard form (DirectonalLight) and toggleable form (DirectionalLight_Togglable)
On the left are shadows created with a point light, and on the right with a directional light. Notice the parallel nature of the directional light’s shadows.
A SkyLight actor emits light from two theoretical hemispheres, upper and lower. These hemispheres are calculated as if they were infinite in size, meaning that there is no way to move an actor “outside” the hemisphere. The purpose of the SkyLight is to provide ambient lighting to a level, thus preventing any shadows from falling into full blackness. Each of the two hemispheres has its own color and brightness values, meaning that you can have brighter light coming from above with dimmer coming from below, simulating the effect of diffused light coming from many surfaces at once. SkyLights do not have a toggleable or movable form.
Light Volumes are another method of determining what objects a light affects, aside from Lighting Channels.
In Unreal Engine 3.0, there are three different types of shadows available: Precomputed shadows, Shadow Volume Shadows, and Shadow Buffer Shadows.
Precomputed Shadows (Shadow Maps)
Precomputed shadows are used when static lights are illuminating static geometry.
Shadow Buffer Shadows
Shadow buffer shadows are used only when a static light illuminates dynamic geometry, such as characters, movers, etc.
Shadow volumes are used only when a dynamic light illuminates dynamic geometry or static geometry.
Shadow volumes do have a serious performance drain when illuminating objects with open edges (i.e. holes in the mesh). In such instances, a much slower double-sided shadow volume is used by the engine to calculate shadows at a marked performance loss. To prevent this, make sure that your meshes have no open edges, which is sometimes described as being “watertight”.
Light Environments are the method of choice for handling dynamic lighting from multiple sources with minimal overhead. In fact, all pawns in the game Gears of War were lit through the use of Light Environments!
The following are some simple performance-friendly guidelines to keep in mind when lighting your levels.
- Keep the amount of dynamic shadows, either cast by dynamic lights or by static lights on dynamic geometry, to an absolute minimum.
- Light Environments should be used whenever possible in place of dynamic lighting and shadowing.
- If any light has no potential to cast shadows, then disable shadow casting on the light by setting its CastShadows property to False.
- If any object has no potential cast shadows, disable shadow casting on the object by setting its CastShadows property to False.
- Use subtle ambient or bounce lighting (using SkyLights or multiple point lights) and/or modulated shadows to avoid super-black shadows.
- All lights, other than ambient or bounce lighting, should have a visual source, such as a static mesh, in the world. Always ask yourself, “Where is the light coming from?”
- When necessary, add lights for emissive surfaces, since they only give the appearance of emitting light, but do not actually emit light themselves.
- Remember that shadow maps require a separate map for every light affecting each individual object is stored. This means that too many lights casting shadows on many static objects can result in memory problems!
- When using shadow maps, make sure to only use a resolution high enough to give the necessary detail.
- Enable UseLightMap whenever possible, such as when static lights are affecting static objects, to force lighting to be baked into Lightmaps.
- Avoid Light Functions when possible as they cannot be stored in Lightmaps, even when they are static. However, at the time of this writing there is potential that the ability for static Light Function lights being calculated in the Lightmap will be added in a future release of the engine.
- Keep shadow buffer casting meshes out of immediate proximity of point lights.