I have an old unity project (done in Unity4) where all assets are linked to specific lightmaps which were baked in Maya.
If I open the old project with the new Unity version, will all the lightmaps be utilized and linked to the right assets?
Why not backup and try it out?
If The lightmaps where integrated with the old light-mapping then they will probably brake and not work in unity 5.
I really hope not, since this will require a huge amount of work to remap all the already baked lightmaps to all objects.
Is there a free trial for Unity5 pro?
All the Pro features you have in 4.x pro you get in 5.x Personal.
Just download Unity5 make a coppy of your game and try it out.
I did try it, sadly the lightmap array is gone.
I guess that means that’s its impossible to open old unity projects in the new one.
It doesn’t make any sense, why not keep the array, are studios supposed to re-shade and light all their games?
Unity is using a whole new light mapping system with a whole new way to store and manage the lightmaps.
The old format does not fit in the current shaders / storrage anymore.
is it at least possible to create a new array with the new system then replug the old lightmaps?
It is POSSIBLE to port the old lightmaps, but it is far from trivial!
We are doing it here at Betadwarf, but we have also had a programmer spend quite a bit of time creating stuff for it.
Personally I think there are some “simpler” solutions out there now that we can set per-renderer data, but even that would need pairing with custom shaders.
1-Ok, I managed to have an a array of lightmaps after doing a random bake in a scene which is good news (its still wieird though that you have 0 options in this tab, but I can live with that).
https://drive.google.com/open?id=0BwsPPskcQl7BdXJMbVp3bG96UVE&authuser=0
2- legacy shaders seem to be working, good news.
3-The problem is if I select an object, I can’t manage to change it’s lightmap index:
https://drive.google.com/file/d/0BwsPPskcQl7BVmtkWktjaWZBdG8/view?usp=sharing
any ideas? been struggling for a while for a solution.
The lightmap index/tiling I think is calculated differently now. So unless you manually kept the lightmap UV’s in the models, then you have a problem. (Same as we have).
We are currently exporting everything in each scene to maya, then back into unity 5.
- having to verify stuff.
So no easy solution.
Yes, I have manually unwrapped my second set of UVs. But even with this, it doesn’t seem possible. Could you describe your workflow for changing the index for objects?
So what Zicandar describes can be done with the following steps. I will say though this is a pain in the ass, so if you can avoid it you should. This has taken us a few weeks to get working properly, but we’re nearly there with this technique. (Note all the code is just quick sketch of the concepts, I have no tested any of this for compilation, naming, etc.)
- In Unity 4 find a way to save your scale offsets, we used protobuf but I’m sure you could use almost any other serialization technique. You can find this data by fetching the serialized properties for your lightbaked renderers.
List<SerializableLightbakedObject> objects = new List<SerializableLightbakedObject>();
for(int i = 0; i < renderers.Length; i++)
{
SerializedObject so = new SerializedObject(renderers[i]);
Vector4 tilingOffset = new Vector4(so.FindProperty("m_LightmapTilingOffset.x").floatValue,
so.FindProperty("m_LightmapTilingOffset.y").floatValue,
so.FindProperty("m_LightmapTilingOffset.z").floatValue,
so.FindProperty("m_LightmapTilingOffset.w").floatValue));
objects.Add(new SerializableLightbakedObject(renderer[i], tilingOffset);
}
SerializeLightbakedObjects(objects);
- Make sure the models you have in Unity 4 have the same UV2 mappings as in Unity 5.
We noticed early on that the UV2 sets autogenerated by Unity in 4 vs 5 are completely different and don’t match up at all. To fix this we had to use a maya exporter to export our fbx files (with autogenerated UV2 sets) from Unity 4 to Maya. From there we could replace our models in Unity 5 with these fbx files exported again from Maya to Unity 5. Note that we used an importer script to handle naming issues (renaming and storing the names in an xml file for when we import). We spent a good bit of time working with the export scripts to get them doing what we wanted and to handle the poor naming conventions used in the project.
- Scrub bake a lightmap for the scene you wish to apply Unity4 lightmapping to in Unity 5.
This seems to be the step that allows you to actually see lightmaps in the scene, without this applying the serialized values does nothing.
- Write a script that can apply the serialized values either at runtime (easiest solution) or at editor time.
for(int i = 0; i < renderers.Length; i++)
{
for(int j = 0; j < lightbakedObjects.Length; j++)
{
if(CheckEquals(renderers[i], lightbakedObjects[j]))
{
renderers[i].lightmapScaleOffset = new Vector4(lightmapScaleOffset.X, lightmapScaleOffset.Y, lightmapScaleOffset.Z, lightmapScaleOffset.W);
renderers[i].lightmapIndex = datas[j].LightmapIndex;
}
}
}
We implemented a CheckEquals method that is capable of determining if a serialized object is indeed the renderer we are looking for, we used a combination of name, position, rotation and parenting info to determine equality.
If you do it at editor time, you should know that all lightmapping data is lost when hitting play in the editor. However, you can build the project with the scene light baked from the editor and it will work in build. We are currently experimenting with this to see if it is totally viable, but it is nice as the runtime lightmap replacement is semi costly (~1s extra load time for medium sized scenes.)
- Fix lightprobes
Lightprobes gave us a little trouble but it seems if you just set them up as described in the docs it all works. That is you go through each probe, and use AddDirectionalLight for all directional ights and SHAddPointLight for all point lights and then set LightmapSettings.lightProbes.bakedProbes.
Hopefully this can point you in a direction that allows you to adapt your light maps from Unity 4. As I said this has been hellish to do and really is a last resort. I’ll try to keep an eye on the thread if you have any questions about a specific step.
Panbake, thanks alot for sharing all your workflow and scripts.
You are right indeed this is way to complicated for such a simple task.
I am discouraged to be honest as I have to many scenes to upgrade.
I will hopefully wait for more simple solutions in the future.
We’ve written export scripts for Unity and Maya that have made it a lot easier to handle, though there is a good bit of work involved in making those scripts. Unfortunately I doubt that there’s a way around this if you are in the same position we were in with autogenerated UV2’s being incompatible. We did experiment and try many different options and this was the only one that worked. We had to handle about 35 scenes and we’ve been able to process them all for the new lightbaking in about 2 weeks of one person converting each scene with our tools.