Lightmap creation workflow

Hi there,
I’m trying to create lightmaps for an interior room.
I’m now using the Lightmapper addon for Blender for it.
But I’m curious to know the proper workflow for creating lightmaps with Unreal Engine.
Anyone have information on how to create the lightmaps AND export them when exporting to glTF?
In the UE exporter options there is a tick for lightmaps, but nothing is exported, surely because I’m not doing it right, I’m completely new to Unreal.
Any information is welcome.

Hi, gltf looks like not exporting lightmap, I load lightmap singlely after gltf is loaded. Usually, lightMap use the second uvs coordinate (uvs2), you should prepare uvs2 before you export gltf. Sorry I have not used UE ever before. In Unity ,there has an field named lightmapScaleOffset(vector4 type) in MeshRender, uvs2.xy = uvs.xy*
For meshes which are not instance,you can do something like this to create uvs2:
var uvs = mesh.uvs;
var uvs2 = new float[uvs.length];
for(var i = 0;i<uvs.length/2;i++){
uvs2[i*2] = uvs[i*2]*lightmapScaleOffset.x+lightmapScaleOffset.z;
uvs2[i*2+1] = uvs[i*2+1]*lightmapScaleOffset.y+lightmapScaleOffset.w;
mesh.uvs2 = uvs2;
For meshes which are instance, it needs lots of work to support lightmap.
PS: if you have more than one lightMap, you should separate meshes by lightMapIndex firstly when you want to combine them to decrease drawcall

1 Like

I am working to achieve instance lightMap now, I plane to add child node for each mesh in prefab like this:
Monitor have 2 mesh, I create 2 nodes for each of them,I use position and scaling to save instanceData
position.x: lightMapIndex
I need to write a customPBRMaterial to sampler lightMap customly next.

Also you can combine lightMap to albedo:

Thank you.
I had to state that I’m aware of the UVs channel and already created those, no poblem.
I was seeking for Unreal help because I read it has the glTF exporter, but the lack of documentation is annoying to say the least.

1 Like

If you manage to export the lightmap from Unity, I would very interested I knowing how to do it :slight_smile: because Unity editor is great for level design

Could always use the Unity BJS toolkit and all its light baking subtractive lightmap glory.

Do you have any information or workflows for complete dummies for that?

@MackeyK24 Do you have any resources to help guide this gentleman into the wonder world of BJS toolkit?