08 - Emission Maps



Emission Maps

As soon as we decided to drop real-time lighting, we had to find alternatives to handle objects that are regionally lit, like torches or lava streams. Spot and point lights that we used to light those objects had now to be included in the baking process.

A special case of lighting were the lava streams. They were meant to emit light on their own which was handled with multiple spotlights at first. Unfortunately spotlights have a falloff and a circular area of effect which did not match the shape of the lava stream. We decided to take advantage of Unity’s lightmapping system, and applied an emission map that acts as a custom light source and influences the light baking process.




Emissive maps - like the diffuse/albedo texture - contain color information which can be mapped to the surface of 3D geometry. During the lightmapping process the emission map information is looked up, combined with an intensity value and considered as a custom light source that emits light from the geometry’s surface. Because the colors of the emission map are used to tint the light, multiple colors can be emitted from the same surface. This has a more believable effect than a single colored real-time light and requires less resources than multiple lights with different colors.

Creating emission maps for voxel-based meshes is super easy. Take the regular texture and simply paint everything that shouldn't emit light black:



In a similar way we made the boots of the Gravity Knight glow. As mentioned before animated objects can’t be baked to the lightmap and therefore the blue glow is calculated in real-time.

You can read more about the possibilities using emission maps here.


Lighting Hints

Letting multiple lights affect the same object is not a good practice on mobile platforms. Although the quality settings allow for a high number of lights, they quickly start to flicker and jitter. This seems to happen when Unity can’t decide whether to use realtime lights first and then the lightmaps or vice versa. To avoid this we tried to use lightmaps as much as possible.

Another odd problem occurred with real-time shadows. For some reason Unity lacked the possibility of correctly casting real-time shadows onto shadow baked objects. A strangely mirrored shadow that we called the crab shadow forced us to disable all real-time shadows. The problem is reported to Unity and might not be an issue in future versions; until then you might consider using the shadow projector from Unity’s standard assets to fake a shadow beneath your character.



Objects which are placed in the background can get much less space on the lightmap than objects close to the camera. E.g. distant towers in our game were scaled to a tenth of the lightmap space. This was possible because the speed of the game makes it hard to spot the differences while playing.

If you are using models without appropriate UVs, you can let Unity generate them for you. For more information on this read this article.

    Attachments
    There are no attachments for this article.