26. August 2015

Simulating Area Lights in UE4

Von Alan Noon

In the real world, light sources come in all shapes and sizes: fluorescent tubes, light bulbs both traditional and curly, car headlights, campfires, the sky, and so on.

In professional photography, light is controlled by a number of different methods. Gels are used to tint and color light. Gobos, or “cookies” change the shape or pattern of a projection. Diffusers are of particular interest to us, such as the soft box and the photographic umbrella, which are used to redirect, spread, and soften light.

A powerful feature typical in modern offline rendering solutions is that of the area light. The area light works much like the photographer’s soft box diffuser functions in the real world: It allows for a volume of illumination to be emitted from a large surface, filling a space with diffuse lighting. This decreases the harshness of shadows and highlights in a scene, which generally renders surfaces in a more pleasing manner.

As of this writing, UE4 does not currently support area lights. However, with some basic geometry, a simple material, and a standard UE spotlight, we can emulate area lighting in a convincing and easily controllable manner by creating our own realtime diffuser. For the sake of this discussion, we’ll call this assembly our Bounce Card.

Step 1: The Scene

Initially in our simple scene, we have a house-like structure with several windows and doors, as well as a skylight. There is also a Directional Light acting as the sun. There are also a few specialized actors in place: Three Sphere Reflection Capture Actors to assist with accurately rendering reflective surfaces, a Lightmass Importance Volume directs Lightmass where to spend its light baking efforts,* and a Post Process Volume is used to tune the final render with various visual effects.**

Playing In Editor yields:

SimLight_0

Obviously, the interior of the structure is extremely dark. What we are looking to do is simulate light pouring in from the outside through the windows and doors, allowing photons to enter the building. These photons will bounce around the environment, illuminating surfaces they come in contact with and ultimately yield a more believable and pleasing result.

Step 2: Adding Lights

Our first step is to add light sources, just outside of and roughly centered in each portal. The Inner Cone Angle and Outer Cone Angles have been opened up in order to maximize the spread of illumination of each spotlight.

  • Inner Cone Angle    80.0
  • Outer Cone Angle    85.0

Results of Building Lighting and Playing In Editor:

SimLight_1

Better, in that we can at least see the interior, but note the harsh lighting and shadowing. By assembling the remaining pieces of the Bounce Cards, we can get that higher quality Area Lighting associated with architectural visualization rendering.

Step 3: Diffusing the Lights

Our Bounce Cards are composed of simple planes scaled to fit and placed outside of each portal, just beyond each spotlight. The planes each have a white material applied***, and are oriented so that they face towards the interior of the building.

The light sources themselves have had their Attenuation Radius brought down in order to provide the Bounce Card just enough coverage. Different scenes may require different values. The lights are rotated to point outwards, away from the interior of the building and directly into the planes that were just placed.

  • Attenuation Radius = 200.0

Bounce Card configuration:

SimLight_3

Scene Setup:

SimLight_4

Results of Building Lighting and Playing In Editor:

SimLight_6

PROTIP: If the glowing exterior world effect of the Bounce Card is undesired, select all Bounce Cards, and from the Details Panel, enable the checkbox for Actor Hidden In Game.

SimLight_5

Footnotes:

*Lightmass Settings

Lightmass is the tool that performs the light baking process and encodes the result into lightmaps for each object. By increasing key parameters, the final quality of the scene’s static lighting is improved. The adjustments for this project include:

  • Static Mesh Lightmap resolution = 512
  • Num Indirect Lighting Bounces = 25
  • Indirect Lighting Quality = 8.0
  • Use Ambient Occlusion = True
  • Compress Lightmaps = False

Increasing these values will raise the quality of the final light bake at the expense of time, dependent on available processing power. It is recommended to “rough in” the general and tone of your scene lighting by iterating with lower values, eventually stepping them up to final quality once the desired look has been achieved.

**Post Processing

Post Processing Effects are extremely powerful features that can dramatically affect the final output from the renderer. A little bit of post processing goes a long way. A hint of bloom, some color correcting and a touch of contrast can add a lot to a scene. The Post Processing Volume provides access to the various parameters. For this project, the following settings were used:

  • Scene Color
    • Fringe Intensity = 0.575221
    • Grain Intensity = 0.150442
  • AutoExposure
    • Min Brightness = 1.0
    • Max Brightness = 1.0
  • Lens Flares
    • Intensity = 0.0
  • Unbound = True

Fringe and Grain settings add hints of photographic artifacts.

Here, the Auto Exposure and Lens Flare settings effectively disable those effects.

Unbound makes the Post Process Volume act globally across the scene.

*** Bounce Card Material

The master Bounce Card Material is straightforward: a Vector3 for Base Color, and a Scalar that multiplies that color into the Emissive Channel. The Material Instance version has its Brightness increased.

  • Brightness = 13.0

SimLight_7
Master Material                |                Material Instance

Note that the emissive quality of the material is NOT set to actually emit light into the scene and figure into the Lightmass calculation; it is purely an aesthetic choice in this case.