Baking Glowmaps in Blender

From FreeSpace Wiki
Jump to: navigation, search

Disclaimer: The objective of this guide is to give the community a simple step-by-step introduction on baking glowmaps. It is a reflection of my own workflow, which is probably not the most optimized one in the blender universe but I can assure you that they do work. This is not a modeling guide, so you'll need a correctly UVmapped model. If you have any doubts or problems, please feel free to point them out.

Introduction: Why baking glows? The physics of lighting are pretty complicate. Once emitted, a light beam will travel in straight lines, bouncing from one object to another while been partially absorbed. All objects receiving light become lightsources in turn. No game engine or hardware is able to duplicate this behaviour in real time currently. And you'll subconsciently notice that there's something funny going on on your image...

However, the problem can be tackled pretty effectively if all objects are static. In this case, we can use a rendering program and compute the effect of light on the scene (a process that can take a long time), store the information in an image and just use the image in our engine. That's basically what glow baking is all about. If the geometry of your ship is static (no rotating bits, sorry!) and if lights are static (sorry, no blinking lights!) then you should bake some glows.

Also, baked glows look good. It gives your model a more accomplished look. They work best in low light situations and specially good with shadows enabled. Enough words and let's go to an image:


Can you see how that white light in the front lights things around it? Can you see how the blue light bleed out? Isn't that awesome?!

The works

Blender has two rendering engines that we can use for this: Blender Internal (BI) and Cycles. BI has two ways of calculating lights, an approximate method and raytracing. This gives us three baking methods, each with a particular setup, that we will be exploring next:

- BI: approximate method: the cheap and dirty way - BI: raytracing method: earning your bake - Cycles: getting into the experimental stuff

What I do in general is to bake lights grouped by color and maybe intensity. If you bake different lights groups into different files, you can integrate them into a single image and control their relative intensity later. We'll be exploring that too at the end of this guide.

- Integration and final touches

What method to choose?

I will be using the GVB Hathor as an example throughout this guide. You can see the model here. We will be baking only the green lights into a 2048x2048 map in white (we will address color in the last step). Here's a comparison of the results we will obtain with each method, though the general light intensity is a bit heterogeneous:


What stands out: 1- The approximate method is unable to do any shadowcasting. this means that areas that should be completely black are lighted because they are facing some light. You can see that the green things in the pods are actually lighting the inside of the cockpit! In this case, the comparison is a bit harsh, but with a less complex model, the result might just be enough. It is really easy to set up. Also, baking this took me less than 1 min (using the GPU, Blender can use CUDA (sorry AMD users!)). If your machine is getting old, you might want to avoid the other methods since they are quite heavy and your pretty much stuck with this.

2- The raytracing method works fine but it is cumbersome to use. You have to use lights in order to cast shadows, and you have to put them in place manually. That takes a lot of time, but I have a bit of a workaround. The problem with this method is that only lights affect lighting. That means that light won't bounce from one surface to another, and it'll give relatively sharp shadows. Rendering this took me about 30 min.

3- Cycles is the new rendering engine in Blender and it has been in development roughly for two years. Cycles baking is a new feature, and you'll need to grab a Blender nightly. Being a new thing, it has some issues. For example I wasn't able to get it to run on the GPU, and my final render took about 3 hours. The problem of bouncing light from one place to another is that calculations cost time and might give grainy results, but there are some ways to work around the problems. On the plus side, you get shadows and indirect lighting from every face. It's just so beautiful.