Create lightmap UVs in Blender?

(Rory Baxter) #1

Does anyone know how to create lightmap UVs in Blender, and import them into Unity?

I posted a scene (here) to get advice on how to export the Unity lighting and shadows to Sketchfab.

Waleguene said that it would be better to create lightmap UVs in Blender rather than in Unity (as Unity applies offset and scale that is not exported to Sketchfab), then bake the Unity lighting to them before export to Sketchfab.


(Shaderbytes) #2

you can create as many UV sets as you like in blender. Obviously when importing into Unity dont select to generate lightmaps. From there Im not sure how unity chooses which UV channel to use when importing your own. In previous Unity versions I think it just used to use the 2nd channel if it found one. Not sure about how this works these days. Also I would think in the enlighten settings you need to select the option to keep the UV set as is.

Im sure you know the rules for UV layouts of lightmaps?? all islands must be in the 0 -1 range , you need a good amount of padding and the uv distortion should be minimal ( this is why lightmaps have so many more splits and islands ) Blender does have an option to do Lightmapped unwrapping, so it does all the splits but it might not be as optimal as if you do it yourself. No overlapping either .. unless you are baking across different atlas's.

I have no idea how you are going to handle doing something like that..somehow you would need to custom set the atlas index's.. but only for specific islands. I'm not sure if enlighten exposes a means to do that manually. Anyway what you are attempting to do is no trivial task. It would be much easier to bake the lighting using dedicated 3D modeling and rendering software. All this is rather easy to do in Blender.

(Rory Baxter) #3

Thanks for your replay shaderbytes.

I think your description of light maps having so many splits and islands explains why I got a fractured panelled look in my geometry after the light bake in Unity - I could see lines that looked liked cracks on trees in my scene.

The reason I've done it this way is partly because of a reply by Glenatron on his Tiki Treasure where he confirms exporting a second set of UVs and doing the lighting in Unity because "the tools are better".

I've always wanted to build game assets and scenes, and Unity seemed a good entry level game engine. But yes, after my first results I am looking at options and considering how I would do this in Blender.

I've just seen a light-baking tutorial for Blender. My only concern here is maintaining a game look. I want it to look like something in a game, not a 3D render in Sketchfab.

(Rory Baxter) #4

I did a second light bake in Unity, this time using UVs I'd created in Blender that were not atlased. I used a second UV that was a copy of an unwrap, and the light baking was clean, smooth and without the fractures I saw in an earlier bake.


(Shaderbytes) #5

Glad you got something working , so did Unity still just auto select the second channel for lightmaps as I said it used to do?

(Rory Baxter) #6

Yeah it seems so. I got rid of the lightmap UV (in Blender), made the texture UV the first map, generated a new lightmap as the second and called it UV0. Then exported the model to Unity again.

(Rory Baxter) #7

Here's some screen shots...