Project NO. 3 : Unity Lightmapping tools (using Vray etc.)
Basically the system is automating the bake process for Unity powered games using a powerful rendering software VRay.
The Unity team proposed a bit different workflow and not all the original ideas will be implemented as the part of the system. It was rather clear that it would happen since the ideas I described were indeed invented rather quick for a game which I’m working on with my team (no further details now😛 )
Nevertheless I’m very happy with the changes proposed by Unity team and those which came after the talk with my mentor Lucas Meijer. I think that it’ll all make the lightmapping process in Unity really simple and effective.
I didn’t setup my goals yet, since I want to be rather sure what exactly can be done in those 6 development weeks, but since many of you may be interested in the details I will often blog here information about the development progress and plans – starting from today. Feel free to submit here your ideas in a form of comment
Here’s the scratch of the workflow made by Joachim Ante:
From the end-users artwork we simply require:
* At import time per object unique uv’s are required (normalized to a range of 0 … 1)
[As a first step, we can just require the user to provide it, or we could automatically generate them later on]
The lightmapping process works in 4 steps:
- Go through the scene and pack rectangle UV coordinates into a texture sheet. They can be stored in the renderer using lightmap tiling and offset: http://unity3d.com/support/documentation/ScriptReference/Renderer-lightmapTilingOffset.html
- Create an FBX file from Unity scene. Export both the primary and secondary uv set with the packed UV coordinates. This means that we “offset-scale pack” the per object uv’s we have, into a new “baked uv sheet”. (FBX supports Ascii mode, so it’s quite easy to export)
- Launch Max from inside Unity through the commandline batchmode interface, automatically open the exported FBX file and start the lightmapping process
- Once the batchmode completes, Unity imports the textures and applies them to the renderers using the Lightmap Settings class and renderer.lightmapIndex.
Here’s a short summary from the discussion with Lucas:
- Our main goal is to “unchain” the baking process, so that one can modify the scene in Unity as much as he wants – and in every moment start the bake process (possibly several times during the work over the scene) before, the user were pretty much blocked to do changes in the imported model inside Unity
- We’ll test the system with max and vray, but it should work with any fbx reading, lightmap creating program with some additional work
- The user would have a choice (by selecting objects from list) which objects are meant to take part in the bake process. On the selection list will be placed combo boxes beside each object, to make user choose a lightmap-enabled shader.
- The scene is being exported into ascii-fbx file and then imported into 3dsmax. During the exporting process we set the 3rd channel uv using the existing (second?) channel uv which will be scalled and offseted. (We will demand an unwrap uv on second channel from the user for the beginning – later on it may be created automatically for him) [credits: Joachim Ante]
- All the UV’s will be packed to a single or a few big texture sheets – a benefit in performance
- We’ve got an idea to make vray materials assigning automatically according to the material name from unity – that would help the designer in preparing the scene to the baking process (when one doesn’t use any keywords in the material name in Unity then the default vrayMtl with a diffuse map (eventually in bump map – if it makes sense) will be assigned.
- The light setup in 3dsmax is not yet outvoted – although we’ve got two conceptions:
- The vray-lights are being created dynamically on the image of the lights created in Unity
- We leave the light setup to the 3d artist so he can import a light rig to the scene and then bake
- After the baking process is done the materials in Unity stay unchanged, but using the LightmapSettings class the appropriate parts of the lightmap texture are assigned to them (there are a few issues waiting to be resolved)
We’ve also considered some nice icings as for example forwarding 3dsmax communicates and render progress to Unity or a possibility to choose a custom renderer – Mental Ray for instance.
Here is a simple diagram of how the things will work inside
Filed under: Unity, Vray-Unity tools | 5 Comments