Summer of Code: Progress on External Lightmapping
This blog post is written by Michał Mandrysz who is working on support for External Lightmapping in Unity. The project is one of four selected projects that were selected for the Unity Summer of Code.
If you’re not familiar with the terms “baking” and “lightmapping” then let me introduce them to you a little. Baking is an operation of prerendering expensive details (in calculational sense) like illuminated lightning, highlights and shadows into a texture so that it doesn’t have to be renderered at realtime. It requires some additional effort from the game designers, but it benefits hugely in performance. This solution is pretty old, but according to words of John Carmack it’s still up-to-date and will be – even in high end games.
What is the Lightmapping Tool?
It’s a tool for lightmapping scenes in external applications (yeah, I know most of you would wish to see an integrated system, but it’s not that easy to write this kind of system; however there are several huge benefits from using an external one, especially as powerful one as VRay).
As you may have heard before, my job is to wire lightmapping process tightly with 3dsmax and VRay. The system automates the process of both external baking, and setting up the lightmaps in Unity.
Lightmapping tool manages up to 99 lightmap atlases (could be even more but the interface would have to be modded for such extreme jobs) which hold object information with resolution proportional to their size on the stage. It can start external applications (currently only 3dsmax), assign appropriate renderer or load a preset max scene which holds information about lightning and so on. I’m planning to make a short screencast video when the work is done, so you can be sure you understand everything clearly ;-)
This picture presents about 1/6 of a whole scene lightmapped with only one 2kx2k lightmap rendered with VRay on medium settings
What makes this solution different?
Many people have asked me how my tool will change the way the lightmapping is done. The answer is quite simple – it gives you the power to decide whatever in scene will be static (and lightmapped) or not – at anytime without much pain.
Let me introduce how the workflow is looking:
- Open a the lightmapping tool (all the previously lightmapped objects from the scene will be already present at Lightmapping tools lists),
- Setup export options,
- Export to 3dsmax and make anything that’s needed to make the scene look good,
- Max will be opened (if not opened before),
- Setup lightning in 3dsmax and store presets with light and renderer settings using the the additional tool Lightmapping. You’ll be able to switch between them later to render the scene,
- Bake them with a single click.
- Come back to Unity to see the effects of your work. No texture drag and dropping – everything is automated ;)
How is the work going?
Most of the options you’ve seen are implemented and working, today the system hits it’s first beta day and will be given to first beta testers (by the way: if you’re interested in beta testing, please write a message to masteranza at gmail dot com).
It’s over four weeks of developing right now, and I must say that the original idea really evolved. I’ve read some feedback coming from the community and I decided to generalize my system. Of course I stick to the guide lines (Main Goals) send to Unity team, but I try to generalize whenever is possible. Let’s look at the “Advanced” window – it was not designed to fit 3dsmax or VRay options only, but with a little effort every external tool.
What’s more, after exporting, the FBX file system waits for lightmaps to appear so, automatic setting up them is also tool independent. I will do my best to help everyone willing to extend the system in future for such tools like Blender, Maya and so on.
What’s left to do for this week:
- correct the material setting subsystem
- correct some issues with lightmap edges
- eliminate bugs
- optimize the code
- try making GUI more intuitive
- gather feedback from beta testers and make improvements
- make icons and additional graphics for both (Unity and Max) interfaces
Developing the system gave and still gives me a lot of satisfaction. I’ve learned a lot of things and had a chance to use things I’ve learned in school in practice. Starting from Immediate-GUI, going through the ‘normals space’, up to some deeper MaxScript insights. Although it took me almost half of my vacations [and a small eye strain ;-D] I’ve already planned a game development in Unity as soon as I get my Unity Pro license.
What I noticed during development is that Unity makes some things really easy to do and it’s not only about the Unity Engine internals, but the way things are organized here – I’m thinking about the huge community, enormous library of already written scripts and almost instant help on any problem.