PrefabLightmapping
PrefabLightmapping copied to clipboard
Bake lighmap with consistent UV Layout
Is there a way to generate lighmaps with the same UV layout? Right now when I bake lightmap again, without any changes, it looks slightly different. I'm trying to swap lightmaps on runtime and I need to generate few lighmaps with the same UV layout.
Hi, so this script allows you to set lightmaps regardless of the UVs so the code inside takes care of assigning lightmaps with the right uvs and all, so you technically can record different lightmaps in different lightmap scripts and load them independently. It is not something working out of the box but you can do it. Let me know if that makes sense. The script takes the lightmap it has reference to and loads it. So you could make different prefabs with different lighting and just use the serialized data for each to load each different lighting
Hi, thanks for the reply! I think I solved my problem, but I'm not sure why it works that way. So my idea was to:
- Bake first lightmap, it generates Lightmap-0_comp_dir.png and Lightmap-0_comp_light.exr file.
- Duplicate and rename this files, change lights and generate new lightmap. That way I have 2 different lightmaps.
- Write simple code that is able to change m_Lightmaps and m_LightmapsDir and cal Init() again. I don't see any perfomance issues doing it that way.
I did it before opening this thread, because everything worked fine except 1 thing. Even if I didn't change anything Lightmap-0_comp_light.exr file was different than previously baked copy. Just now I found a way to solve this problem, but it's a little annoying. To resolve this issue I have to bake lighmaps before I create prefab of an object. So basically I have to unpack my prefab, perform steps 1 and 2, then create new prefab. Somehow this way generated files have exactly same layout and everything works fine. It would be nice to find out how to do this without unpacking prefab.