Lacuna Passage - Devlog #53 - Adjusting for Rendering Differences, Updating the Datapad, and Ludum Dare 33

Rendering Differences Between Color Modes

In our last few devlogs we have featured some updates to our art pipeline that have come with the transition to Unity 5's Standard Shader. In making this transition we have changed Unity's color mode from Gamma to Linear. This is a fairly technical aspect of rendering in a game engine, but I'll do my best to walk through our process (and problem solving). You can see the difference between the different color modes below.

Gamma Mode

Gamma Mode

Linear Mode

Linear Mode

You will notice that Linear color mode has much tighter highlights and generally makes metal materials look much more natural. The math behind it is all quite complex, but thankfully Unity takes care of it for us with a simple checkbox setting. We demonstrated how this new rendering mode looks a few weeks ago with our new Bridge environment assets.

Looks great, right? Well, unfortunately we were soon met with a few complications while trying to incorporate this new Linear color mode into our full project. Let's look at one specific example. Below you will see how this new color mode affected our fog blending with the skybox. (You can click to enlarge all images).

Our Mars time-of-day system was originally designed with Unity Gamma color mode. This is the exact start moment of "Dawn" in our old system where no color lerping (blending/gradation) is happening.

In this example we have switched to Linear color mode. You can see that the fog color is still blended properly with the background skybox, but that is to be expected since no lerping is happening at this moment.

Back in Gamma mode our time-of-day progresses from "Dawn" to "Midday" smoothing with a color lerp that is precise to match the blended skybox in the background. Looking good!

Now we can start to see the issue in Linear mode (you may need to click the image to enlarge it). The color lerp for the fog is no longer matched perfectly to the background skybox (notice the hard line at the horizon). Nothing else has changed from the previous screenshot other than the color mode. You can see problems with the sun shafts and lens flare as well; however, those are less of an issue because they can be tuned appropriately to compensate. The fog color lerp cannot be compensated. The start and end colors of the lerp are correct (see the Dawn example), but the colors in between are incorrect.

This simple problem caused us a huge headache. The beginning and ending points of our time-of-day transitions still matched the skybox perfectly, but every point in between was too dark and made our horizon line stick out like a sore thumb. So what was going on in Linear mode that was different from Gamma mode?

We had no idea. After scouring the web I came up empty handed. So I ended up resorting to posting for help on the /r/Unity3D subreddit. Lo and behold we were presented with a potential solution in less than an afternoon. And surprisingly, the solution came from real-world light physics and not from a Unity-specific error. As it turns out, Linear mode in Unity does not properly calculate the blending of two colors, but we can do that ourselves if we apply math! The video below led us to our final equation.

Mathf.Sqrt( Mathf.Pow(color1.r, 2) * (1.0f - t) + Mathf.Pow(color2.r, 2) * t )

This equation can be applied to our fog instead of using a Lerp. This transitions from color1 to color2 where t is the decimal percent of transition (just like t in a normal Lerp). We have to do this for each channel (r, g, b, and a) and use those values to build a new Color that reflects the proper values in Linear mode.

Now our fog blends perfectly with our skybox once again. There were a few other issues that we had to overcome in the transition to Linear mode, but we have finally gotten to a point where we are happy with the result. Due to the improvements with the Standard Shader in Linear mode, we think the game looks better than ever.

Updating the Datapad

We have also been working on updating the Datapad with the new Unity GUI features. Before we were using a plugin called NGUI, but this was becoming difficult to manage and we wanted to transition to using as many built-in Unity features as possible. One of the benefits of this new system is that it can automatically map the navigations between buttons.

You can see that we are making some general design changes to the Datapad as well, but we will have more details about that in a later devlog. Beyond that, we have made improvements to the shader for the Datapad screen so that colors appear more accurate to what you would see on an LCD screen. Before, the entire screen was illuminated equally, which led to blown out bright colors and washed out dark colors (shown below).

Old Datapad screen shader

Now we have a new shader for the screen that illuminates the brighter colors with more vibrancy while still preserving the dark colors.

New Datapad screen shader

Ludum Dare 33 - "The Monster Inside"

It was a pretty busy month, but our artist Spencer did manage to break away for a four day weekend vacation. So during that weekend I decided to participate in another Ludum Dare game jam without him. This time the theme was "You Are The Monster". The result was a collaboration with our composer, Clark Aboud, and a new contributing artist named Doug Auerbach.

We created a short audio-visual novella called "The Monster Inside". It is a text based game that explores a fantasy-infused film noir world. It covers some adult themes, so player-be-warned, but you can play it directly in your browser or download it from our Itch.io page below. Check it out and let us know what you think!

Thanks for following our devlog and we will be back soon with more art updates in a couple weeks!