Isles of Adalar

Isles of Adalar

Not enough ratings
Level Design 10 : Lighting Optimization
By PaperBagCrusher
This tutorial covers : Explain the impact of casting shadows and turning off shadows for lights in high density areas. Light objects and properties.
   
Award
Favorite
Favorited
Unfavorite
Light Settings
Lighting is one of the most important elements of a game scene in regards to the overall fidelity. It can also be one of the biggest performance drawbacks if it is not set up properly. First we will start by going over the technical information about lighting within ‘Isles of Adalar’, then we will cover the theory behind lighting in games and how to achieve the best results.

You can place down a light just like any other object in the game. They range from objects that mount on the ground, walls, and even floating chandeliers. There’s only two settings within the ‘Edit Object’ window that are unique to lights, and they are as follows.



Lit only at night - Whether this object should produce light all the time, or only during the night hours.

Cast shadows - Whether or not this light produces shadows that affect the environment around it.



Light Objects
Physical lights that exist in the world are not the only light sources we support. You can add invisible (while in play mode) light sources that we call ‘Light Objects’ to achieve maximum flexibility in scene lighting. You can place and select ‘Light Objects’ from either the ‘Objects’ tab or the ‘Builder’ tab. Keep in mind that ‘Light Objects’ made within the ‘Builder’ tab will move when the corresponding builder is moved. ‘Light Object’ settings are as follows.





Color - The color of the light produced. You can choose from pre made colors or manually enter color values.

Cast shadows - Whether or not shadows should project from the origin of the ‘Light Object’. This setting is off by default.

Range - The area the light produced will expand to.

Intensity - The overall brightness of the light produced.
Game Lighting Theory
Now that the technical information is out of the way, it’s time to dive into game lighting theory and best practices. An extremely important lighting concept for games is bounced lighting or global illumination. Games that allow light sources to bounce light off of multiple surfaces via global illumination can achieve a much more natural look than only relying on direct lighting.



Traditionally games have only used global illumination in scenes with static lighting because dynamic global illumination is extremely expensive. Some games allow for real time global illumination but it’s not truly dynamic because they still require the geometry in the scene affected by it to remain static at all times and rely on pre-calculated information to light the scene.

Isles of Adalar can only have truly dynamic lighting because of the built in level editor functionality and the ability to change the layout of any level. This prevents us from using the traditional global illumination systems of most recent games. Ray tracing will eventually allow us to have dynamic global illumination, but even once we implement it into Isles of Adalar, it will only be viable on high end hardware. As a result of this, we will still have support for the ‘Direct Lighting Only’ mode and will use techniques to achieve the best look and performance within that mode. Our invisible ‘Light Objects’ system is something we developed to allow us to simulate global illumination without the performance drawbacks, it just requires some extra work from the level designer. Imagine putting light objects near the white arrows from the previous image to achieve a similar result.

Lack of indirect lighting via global illumination is not the only issue designers need to consider when setting up lighting in their levels. Every light that casts shadows multiplies the amount of geometry the game needs to render in order to properly display the shadow projection. As a result of this, you only want to cast shadows on lights where it is extremely impactful to the look of the scene. On average we recommend only casting shadows on 1 out of every 4 lights within a building when working within a city or town. If the building is off on its own in the woods for example, you can cast shadows more often than that. But don’t be reckless with it because you can easily create performance issues if you aren’t careful.

Most of the lights in your levels should not cast shadows to keep high performance. It seems like a simple enough rule but it produces another design challenge you will need to account for called ‘light bleeding’. Light bleeding occurs when geometry shaded by a non shadow producing light connects together within the light’s range and can break the visual fidelity of your scene.



There are multiple ways to deal with light bleeding. In this example you could move the candles more towards the center of the room instead of in the corner, or add a wall torch to the other side of the wall which would make the light affecting the floor make sense.

The candles in the previous example are an example of a point light, or a light that emits in all directions. Point lights are very straightforward in terms of setup, but as you’ve already seen they are prone to light bleeding when they don’t cast shadows. If a wall torch was a point light, it would always bleed light on the other side of the wall if it wasn’t casting shadows. This would obviously be an issue since we want to avoid casting shadows too much to save performance. So as a result, all wall torches are cone lights that only project light forward. This gets rid of the light bleeding problem for wall torches but creates another small problem. Fortunately, this one is easy to solve.



As you can see only projecting light forward leaves the wall directly behind the light unlit which doesn’t make sense. We fix this by adding a ‘light object’ with an intensity of 1.5 and a range of 4 and move it directly in front of the torch. The low range and elevated height prevents light bleeding on the other side of the wall.

Proper Lighting Setup
Now that you know all the design challenges associated with lighting in your scene. Let’s breakdown proper lighting in a room.



The last image is the result you want to achieve. The most important light casts shadows for extra fidelity and the rest do not to keep up performance. Light objects of a low intensity are also used to fix some of the problem areas that are caused by only using direct lighting and create a fake sense of bounced lighting. We’ve already pointed out the wall torch as a problem area, but you need to be able to identify the others and see if you have similar problems in your environment.

The most obvious is the small candle on the left. The version of the candle with shadows barely affects the floor which doesn’t make sense. The version without shadows affects the floor but the light is too strong to disappear into darkness that quickly. We made the range of the small candles smaller to limit light bleeding on the other side in a situation like this, but you should add a lower intensity light object to make the light disappear more naturally.



The area by the tub has issues because the tub and bucket should not be receiving light or that intensity without the floor receiving some as well. This issue was likely caused from a light on the floor below not casting shadows. The answer again is to add a light object of a low intensity like 0.75 or lower to make it look more natural.



We chose to have the light by the desk cast shadows because the difference was too noticeable without them.



The table area got dark too quickly due to a lack of bounced lighting so we added a very small light object to make the transition more natural.