Lacuna Passage - Devlog #52.5 - Lightmapping with Emission in Unity 5

Light mapping is a technique where you can bake the light from a scene into objects so that they self-illuminate based on a generated lightmap texture that usually is mapped to a second UV channel. This is a great solution to reduce the number of light calculations needed on static objects. But what if you have an object in the scene that needs to appear as if it is projecting light and casting shadows on other objects - and you also want to control the color and intensity of the light ingame? Well that’s where emissive lighting comes in handy.

Emissive lighting is typically used to self-illuminate objects in a scene and make them appear as the light source. A texture specifies the areas of the object that you want to emit light and global Illumination bounces this light onto other objects in the scene. Below is an example of a typical emissive object with global illumination affecting the scene around it.

But when you want precise shadows and lighting that matches the emission produced you need to get a little more complex. Baking the light casted from the emission source in your modeling software can achieve this effect with only a little extra effort. So, in effect, we want to produce our own lightmapping outside of Unity and apply it to the emissive channel in our Unity material.

First things first, we need to get a demo scene started in our modeling software. I’m going to be using 3ds Max along with the Mental Ray renderer. Below is the basic scene in 3ds max (top) and our desired look using a spotlight in Unity (bottom).

The hemisphere in the corner is the lamp of our scene and its bulb will illuminate our objects. To emulate this lighting in 3ds Max we need to place a light source in the center of the bulb. I used a Photometric Free Light and set the shadows to “Ray Traced” and the emit shape to “Sphere.”

Because I am using Photometric lights, I made sure my scene units match that of real-world objects. In this case I used 4 cm for the lamp bulb and made the radius of the emit shape also 4 cm.

After tweaking some of the light and shadow settings, I made a new Arch & Design material to place on our objects. In the diffuse color map slot I placed my diffuse map.  In the glossiness map slot under the reflection rollout I placed my gloss map. I made sure the diffuse and reflection colors are set to pure white, and the reflectivity is set to 1.0. I also checked the “Highlights+FG only” option because bounced light will be taken care of by global illumination in Unity.

Finally, I added a Normal Bump under the Special Maps rollout with the normal map of our projected high poly (Make sure you flip the green channel). After a couple quick render tests I decided to increase the gloss output to 2.0 to make the highlights tighter.

Now that we have our light and materials setup, we just need to render the light to a texture map. To do this, we open the Render to Texture dialog (Rendering > Render to Texture…). With our all our objects attached into one mesh we can easily render the entire texture at once. With our single object selected we can set our render to texture properties accordingly.

Scroll down to the Output rollout and add a “CompleteMap.” Complete maps incorporate all light information including normal, gloss, and diffuse maps into our bake. Set the texture size and save location accordingly and make sure “Shadows” is checked. Then hit “Render.”

Once the render is complete, decide if you need to increase the quality of the shadows before going to Photoshop to tweak any errors. You can do that by going to Rendering > Render Setup and opening the “Renderer” tab. Here you can tweak things like light sampling and noise thresholds. You could also go back to your light source and tweak its settings.

The end result is a custom emission map that reflects the lighting in your 3ds Max scene:

Then you just bring all your assets and textures into Unity and plug them into the Standard shader (I used the specular version). Here’s a quick video of how the emission lighting method compares to a spotlight within Unity:

In the example at the end of the video you can see some of the benefits of this method. Instead of lightmapping the entire hallway we can simulate lightmapping on a single asset that looks reasonably good even when duplicated in several places around the scene. This works particularly well when the light source is attached to the object that you want to have simulated direct lighting. The lighting never needs to be rebuilt and the resolution of the emission map can be scaled smaller than your other texture maps if needed. The emissive properties can also be easily changed at runtime to create effects like flickering or colored lights. The emission coming from our transmissive plastic also contributes to the scene's lighting via Unity's precomputed realtime Global Illumination.

Lacuna Passage - Devlog #52 - The Bridge Art Progress 3

The Bridge is complete and fully integrated with Unity 5. We have been working hard to update our assets to the new Unity standard shader, and we really think it has paid off. Our workflow is more streamlined than ever with the use of physically based rendering (PBR) and real-world material properties. We have always utilized the Quixel Suite to tweak our normal maps and create base textures, but only recently were we able to make use of Quixel’s built in PBR map generation thanks to this new shader in Unity 5.

We start by creating a base model and high poly for normal mapping. Then we transition to Quixel’s nDo for normal map tweaking. This allows us to make normal map changes within Photoshop using custom shapes and selections.

Once we have our normal map complete, we create a color map, or ID map, that separates the different material sections for our final textures. Quixel has a color swatch dedicated to each of their base materials, so we simply find the material we want using our own custom material previewer in Unity and apply the proper swatch to that area of the color map.

Next is where the magic happens. Quixel's dDo then takes all the information from our normal map and color map to generate base diffuse, specular, and gloss maps accurate to their real-world counterparts.

From there we simply tweak the maps to suit our needs and place the assets into Unity. The end result is a scene with physically accurate materials made to react with light as they would in the real world. Here is a comparison of the importance texturing and lighting brings to a scene:

But, just showing off screenshots doesn't fully capture the look and feel of walking through the Bridge, so this time we decided a video walkthrough would be appropriate. Here’s a quick look at the Bridge of Foundation Base:

If you're wondering what the Bridge will look like from the exterior, check out the last art devlog post here.