New Avatar Lighting in Power & Prestige
| 06/22/2010 | Devlog | Discuss
One of the graphical changes we’ve made for Power & Prestige is a new avatar lighting system. The new lighting system makes our characters fit in better with the rest of the lighting in the environment. I’m going to talk about how the old system works, the goals for the new system, and how the new system works.
Ye Olde Lighting System
First, some background. The lighting of an object is determined by the light reaching the object from all different directions, then bouncing off the object and reaching the viewer. The light that reaches the object could be directly from a point light source (like the sun), from an area light (like the sky), or indirect light from the sun or sky that bounces off bright surfaces in the environment (the ocean, the ground, buildings, and so on) before reaching the object. Realtime lighting systems for games approximate these sources of light.
The avatars in our game are made up of a 3D model, which consists of a list of 3D triangles, and a texture map. The texture map represents the diffuse albedo (what the surface looks like under constant light) and is wrapped around the 3D model. By taking the value from the texture map and changing it in some way, we can approximate lighting effects. In particular, we can use the direction that the surface of the model points, called its surface normal, along with the direction that the light is coming from, to create a lighting approximation where the surface is brighter where it faces the light. We can use more than one lighting effect by adding the effects together and then multiplying them by the texture’s color.
The old lighting system used three light sources. The first light was a value that was constant no matter which direction the surface pointed and is an approximation of ambient light. In this case, it’s set to a bluish-gray color. On top of this, a directional light is added to approximate bounced light. In this case, the bounced light is coming from below and is a sort of greenish-yellow. The final light source is a directional light to approximate the sun, which in this case is coming from the left and is yellowish in color. Multiplying all of this by the texture map yields the final result.
![]() | ![]() | ![]() | ![]() | ![]() |
| Ambient | With Bounce | With Sun | Texture Map | Final Result |
The old lighting system resulted in some problems that prevented our characters from fitting into their environment. First, because the ambient color is constant and independent of surface direction, it causes a flat appearance when you look at an avatar from an angle where the other lights don’t have much effect. Second, the lighting values in the old system were the same for all avatars no matter where they were in the environment. This caused problems where characters would have blue or green colored lighting even though there was nothing blue or green around them. This also caused avatars that were standing in shadow be lit much too brightly.
![]() | ![]() | ![]() |
| Flat Lighting | Mystery Blue / Green Lighting | Brightly Lit Avatar In Shadow |
The New Lighting System
The new lighting system had to be designed within several constraints. First, the new lighting system couldn’t require much artist time, because ArtCo was busy with other expansion work. Second, the new system couldn’t be much more resource-intensive than the old lighting system. Third, the new system couldn’t add huge amounts of data to the game’s size.
The solution I settled on was to pre-compute the lighting environment in all of the places where an avatar could possibly be, and then have the game look up that information as the avatar moves through the environment. This is done automatically in our editor, which places the camera at a number of sample positions in the environment and takes screenshots in each direction.
![]() |
| Green Markers Show Light Sample Locations |
Those screenshots get processed to calculate the combined contribution of indirect light at that point from 10,000 directions. In addition, there’s a check to see if each point is in shadow or exposed to sun. To reduce storage space and the amount of data that has to be looked up at run-time, the lighting information gets stored using spherical harmonics, which are frequency-space representations analogous to fourier series but on a sphere. Because the lighting environment information is low-frequency, the spherical harmonic representation is particularly small and easy to access.
To put it another way, the incoming light changes gradually over the surface of an object, which means we only need to store the lighting contributions from a few important incoming light directions. We can then we can use equations to fill-in the missing data when the game is running.
As the avatar moves, the closest lighting environment samples are looked up and blended together, and the result is used to light the avatar’s surface based on the direction the surface is facing. The sun light is added in just like with the old lighting system, but only if the sample position isn’t in shadow.
![]() | ![]() | ![]() | ![]() |
| Precomputed Indirect Lighting | With Sunlight | Texture Map | Final Result |
The result is avatar lighting that reacts to what’s around in the environment. If an avatar is standing with their back to a bright yellow wall, you’ll actually see some of that light bouncing off the wall onto the character. If an avatar moves into a shaded area, you’ll see the sunlight fade out.
The lighting system doesn’t require much artist time because the lighting environment calculation is automatic (although they do have some coefficients they can tweak to get slightly different looks), it’s quite fast, and only adds a tiny amount of data to the game’s size (as an example, the lighting environment for Fort Caroline uses only 479Kb).
If for some reason you don’t like the look of the new lighting, you can turn it off in the preferences UI (the “High-Quality Avatar Lighting” option in the “Video” menu) and you’ll get the old lighting just as it was. You’ll also get the old lighting if you turn off “High-Quality Shaders.”
We’re very pleased with our new lighting, and we’re looking forward to you experiencing it when Power & Prestige goes live at the start of August!















