Real Time GI vs Baked for Mobile Games

Diary of an Indie Game Developer: Chapter 42

Jason Tuttle
4 min readFeb 14, 2019

As you probably know by now, I’m working on a mobile game which means, compared to PC or console, I’m on a really tight budget when it comes to… well… EVERYTHING. Texture sizes. Mesh sizes. Particle system complexity. You name it. Everything is expensive.

That said, from day one I knew I was going to want my game to have global illumination, and unless I just couldn’t make it work at all on mobile, I was willing to spend some of my precious resource budget to get it. So, I’ve spent a LOT of time trying various approaches to GI to see what works and what doesn’t on mobile.

Unity has two builtin systems for GI. The first is a “real time” GI solution provided by Enlighten, which Unity licensed, and it’s super cool:

As you can see in the video above, the lighting is awesome, and because it’s a real time GI solution, the lighting can be changed on the fly at run time without breaking the GI.

Unity’s second builtin system for GI is a traditional baked solution provided by their Progressive Lightmapper. I talked about the Progressive Lightmapper in a previous post, and like Enlighten, it too produces beautiful lighting. What’s more, Unity is working on a version of their Progressive Lightmapper that runs on the GPU allowing you to to bake lighting ~10x faster:

So, which GI solution should I use for my game? Real time or baked? Fortunately, in my testing, both options can work well on mobile. That said, there are pros and cons to each approach.

First, let’s take a look at the cons.

Real time GI is, by definition, a “real time” solution, so it costs you some precious CPU cycles at run time. Depending on whether your game tends to be CPU or GPU bound, giving up CPU cycles to real time GI, could be a problem. Another con for real time GI is that Enlighten tends to produce less detailed occlusion than traditional baked solutions. Last but not least, setting up your levels to work well with Enlighten can be tricky which is definitely a con. Explaining why it’s tricky and how best to approach that problem would be an entire post in and of itself. Fortunately, I don’t need to write that post, because Unity already did. If you’re interested in learning more about setting up levels to work well with Enlighten in Unity, check this out.

Baked GI, on the other hand, has no run time CPU cost, but all of those baked lightmaps can add up quickly. On one of my early test levels, baking GI produced 120 MB worth of lightmaps. That’s no big deal on a PC or console game, but on mobile, 120 MB worth of lightmap textures is a LOT. Another con is that it can take a loooooooooong time to bake lightmaps. Unity’s GPU lightmapper will solve this problem eventually, but it’s only in beta now, so using it in production isn’t really an option at the moment.

So what about the pros?

Real time GI doesn’t rely on lightmaps, so you don’t have to worry about many mega bytes worth of lightmaps eating into your game’s texture budget. Also, if you set up your levels properly, computing real time GI can be fast. No long bake times.

Baked GI, on the other hand, has no run time CPU cost. It also produces beautiful detailed occlusion.

Given all of those pros and cons, I chose to go with real time GI… at first. Why? My game tends to be GPU bound rather than CPU bound, so I figured I could afford to spend some CPU cycles on real time GI. Also, my texture budget is really tight, and I didn’t relish spending any of it on many mega bytes worth of lightmaps.

But I ran into a problem:

The screenshot above shows a simple test scene with real time GI enabled. As you can see, it looks exactly the same on both the iPhone XS and on the Mac, but there’s a weird greenish tint on the iPhone 6s. I contacted Unity about it and filed a bug report. They seem to think it’s a driver related bug.

If the bug gets fixed in time, I may switch back to real time GI before I ship my game, but since my game needs to run well on the iPhone 6s, I’ve decided to go with baked GI, for now.

Also, I’m not waiting for the GPU version of Unity’s Progressive Lightmapper. I’m using Bakery which I also mentioned previously back when it was still in beta. Bakery is Windows only and requires an Nvidia GPU, so I’ve had to switch my Hackintosh over to Windows 10 full time, but it’s worth it. Bakery is out of beta now. It’s production ready and produces beautiful lightmaps. What’s more, I’m not sure what sort of magic Bakery is using, but in my experience, it consistently produces fewer and smaller lightmaps per level than Unity’s Progressive Lightmapper. Bonus!

See you next week…

--

--

Jason Tuttle

Indie Game Developer. Formerly, Associate Environment Artist at Santa Monica Studio working on God of War. In a previous life, I was the IT guy at TED.