Get Lightmap Resolution on Static Mesh in BP

In a static mesh there are multiple values for the Lightmap Resultion: One for each LOD and one default under General Settings (the one that is applied by default in any Static Mesh Component).

I need this last value, and I need to read it through Blueprint.

Does anyone know where to find it? Is it not exposed?

(p.s. accessing the value in Static Mesh Component is easy, but that won’t do because I dont have a component yet at this stage)

It probably isn’t.
You’d have to build a c++ class to expose it to blueprint.

I think it’s an editor only property though. So you would really have to look over the header of the static mesh to determine if it is legible and initialized when the game is running.

I think that’s mostly the same for the LOD one. These values don’t strike me as something that should be avaliable at runtime since all baking happens well before that…

Why don’t you create and manually set a value in blueprint to match?
Harder to remember to set, but probably a lot easier than accessing c++ and researching for 15m to find out if it’s possible…

1 Like

In fact, what I’m trying to do is in-editor only for the moment.

The goal is to import meshes with Datasmith (DataPrep with a BP), matching the lightmap resolution of Lod0 with the calculated optimal value (in DataPrep this is done through a function called “Setup Static Lighting”)

The reason that I want to match the resolutions is to have optimal lightmaps: a value that’s lower than the one set on the component just wastes valuable texture space. A value that’s higher creates overlap/leaks in the baked results.

Unfortunately, the calculated value is only set on the default value (under General Settings, as mentioned above…) and on every Static Mesh Component after the actors are placed. Both of which I can’t read through BP in the DataPrep stage.

Are you sure the FBX import doesn’t have that option?
It’s not something I use often - as like almost everyone else here we do dynamic more than cooked.

You can potentially lift that code from the FBX import and pass it onto whatever other import method you are looking to use.

BTW, probably pointless for you but maybe someone reading along finds some value in this.
The light-map resolution should be fixed to whatever texture value the UV was unwrapped to for the light-map - instead of relying on the engine to generate the light-map.
When unwrapping the model for light map, you should take care to make sure that vertex are properly mapped to the edge of the pixel instead of the center or any other value, so as to prevent leaks or half colored pixel bakes.

1 Like

FBX Import only unwraps for 64x64 lightmaps. If you want something different you have to go in to each mesh individually and set a different value

With Datasmith/Dataprep you have more control (ie. you can set any value you want), which is a great improvement.

Then Datasmith/Dataprep also introduced this extremely useful function to calculate optimal size… but failed to make the resulting value available for the unwrapping step of the process :frowning:

So when you say “The light-map resolution should be fixed to whatever texture value the UV was unwrapped to for the light-map” that’s exactly what I’m trying to achieve, but I want to use the resolution that is determined to be optimal by the Dataprep calculation…

1 Like

No other idea other than lifting the importer code and repurposing it in a custom importer…

1 Like

Alright… thanks anyway for your support. Haven’t found a solution yet, but I’ll let you know if I do.


Also looking for BP solutions in this area, it it surprising that just a few key values left un exposed.

Very frustrating

If you can do Python, you can read this:

Do some thing like this:

assets = unreal.EditorUtilityLibrary.get_selected_assets()
for asset in assets:
asset.set_editor_property(“light_map_resolution”, 12)