A long time ago, I had blasted in Facebook saying that we will share our findings of Light-map workflow in Unity 5. Along with learning that it is always better to not promise anything before it is done, here is a tutorial… Finally !
Unity 5 came out and they completely overhauled the Light-map system. Although an amazing update, it is kind of difficult at the moment to get the hang of it. The tutorials are difficult to find and the workflow seems as if it is kind of messy.
After working and testing on it for about 6-7 months we have kind of figured how to get a good result with the new Light-map system and that is why this tutorial has been forged!
What is Light-map!?
Light-map is nothing but a texture with lighting information baked directly from the scene to help reduce draw calls and increase performance of one’s game. It usually has shadow, Global Illumination and Ambient occlusion baked onto it to give an amazing depth to the environment without hindering the FPS. Real-time lightning is only set to moving or intractable objects which reflects dynamic shadows. This is a rather standard procedure in games pipeline and has been in use since a long time.
What you need?
In-order to follow this tutorial, we will get down to basics and use primitive objects to bake light-map as an example. Later, you can use the same technique to bake your awesome models in Unity. For now these are the stuff you will need
- A 3D scene exported from any 3D software with a plane and a box.
- The box should have two UV channels. Channel 1 for Diffuse and Channel 2 for Light-mapping. (UV 2 is not mandatory but it is always better to manual unwrap for better quality light-maps)
- Unity 5
Once you have all the above stuff, lets move on to setting up a proper scene in Unity. We will export this in FBX. or Obj. or whatever format your 3D package supports and lets move on to Unity!
Setting up the scene!
- Import the FBX or your exported 3D Obj into your Unity 5 scene. Use the following import setting to make sure that you get good quality Light-maps.
Note: If you don’t have UV2 channel in your 3D object then you can turn on the GENERATE LIGHTMAP UVs in the import settings. This will automatically unwrap a UV2 channel for your 3D object.
- Duplicate the boxes and intersect them together so that the contact shadows or Ambient occlusion will be visible
- Mark your 3D objects as static . The object which are static will only be Light-mapped.
- Select the directional light, mark it static as this will be the source which will produce the required lighting information which we need for our Light-map.
- Change the Directional Light setting as shown below. Basically, you need to change the Baking from Real-time to Baked.
- Go to your quality settings under Project setting and change it as shown in the image below. We do this because the default shadow setting are not that great and are blurry.
Once the scene is set and loaded, we can now move on to settings of the Light-map.
Tweaking the Light-map Settings!
To open up the Lighmap setting tab, you need to go to Windows > Lighting > Scenes
To get more info about each property of the setting tab, please refer to this link. It is highly recommended that you sit down and read it thoroughly before moving on. Please dont skip the documentation or else you will pay for it. It is always better to have atleast a basic understanding of all the parameters before actually working with them!
Please refer the image below and change the settings as shown.
It is highly important that you select all objects you want to bake. Once all objects are selected, press BUILD to start the baking process !
When the Build button is pressed a progress bar will appear on the bottom right corner of your Unity 5 window indicating that the Baking process has started!
Once it is done processing, you will be done with your light-map baking and should have an amazing looking scene with the shadows all baked into the assets beautifully as shown below.
As you can see in the below image the difference between a scene which is baked with light-map looks way more cooler then the dull scene which is without any maps! The use of Light-mapping in your game can play a big part in bringing in that added polish and a very nice grounded feel to your environments.
Things to remember while baking!
- The light-map resolution size is displayed in the light-map settings. Make sure to use proper size and not go overboard as it will hamper your performance of the game
- If you want to clear the light-map, you can by do it by going into the Light-map settings, clicking the arrow besides the Build button > Clear Baked Data. It should delete your Light-maps and you will have to bake it again
- If you want to change the Light-map resolution manually, you can do that by going into the Light-maps tab, clicking on the individual Light-map which will take you to the Light-map texture where you can change the texture compression or resolution manually.
That is pretty much it on how you can bake Light-maps in Unity 5. We hope you enjoyed the read and use this light-mapping technique in your pipeline. if you already haven’t been using it, go ahead and test it now! The procedure can really enhance the look and feel of your game and you should not ignore it if possible. If you dint understand anything which was explained here then don’t hesitate to let us know. The whole point of blabbering about this is to make sure you get it right!
Thanks for dropping by and for your support. We will be blogging about our visit to EGX, Birmingham where we showcased Asura! It was an amazing experience and we will share about it pretty soon.
Until then….. Take care, Be Epic and Forge beautiful stuff