How does Unity apply a lightmap?


I’m trying to bake my own lightmaps in Maya, partly because I want more control and partly because I can’t afford Unity Pro. So I baked a lightmap with just “Illumination” as a render pass:

So I wrote a simple surface shader which blends two textures together and applies the result to the Emission property of the material. The problem is, I can’t figure out how to properly blend the lightmap with the object’s color:

  • I tried using multiply - the shadows are correct, but the highlights are washed out
  • Using screen - Way too much light and no shadows

So how does Unity do it? Or is there an easier way to tell Unity “apply this texture to this object as a lightmap”?


Read my comment from the accepted answer for more details. Here is a screenshot from Unity with the lightmap correctly applied. The advantages of using this method is that I can completely customize the look of my scene with area lights/shadows, advanced GI and AO settings and more.

I think that you need to write your own Lighting function as explained here.
There is a built-in legacy shader that authorize manual lightmaps. Maybe you could look at the source of this shader.

You can also replace the lightmaps in the lightmap panel by your own like explained here.

Here are other good resources:
A Truly Lightmap Shader
Vray lightmapping workflow in 3dsmax
Using externally baked lightmaps in Unity 3.5