Assertion when encoding lightmaps

I am using the Procedural Foliage system to place grass, trees, and rocks in my scene so I have a very large Instanced Foliage Actor that contains all of these meshes. I can’t use material-driven grass since it can’t be light-baked and I am working in VR so dynamic lighting isn’t an option. When I go to build lights it will complete a full build but then I get an assertion when encoding lightmaps. The assertion is on line 1945 of Lightmap.cpp:


This function says that if the element to be added doesn’t fit on the Texture it will return false, so I assume that the lightmap atlas for the Instanced Foliage Actor is too large to fit on one lightmap, is this correct?

I have reduced the lightmap resolution for my static meshes considerably and my max lightmap size is 4096 so it seems like I should be able to get quite a few objects on one lightmap. Is there a way for me to break up the Instanced Foliage Actor into smaller actors so it doesn’t all have to fit on one lightmap?

Will I have to resort to hand-placing static meshes instead of using an Instanced Mesh Actor?

Thanks in advance for the help

I have figured out a solution.

For anyone wondering about this in the future: it seems meshes are required to be on the same lightmap if they were placed with the same Procedural Foliage System. So if you want a lot of meshes you will need to break them up into many PFS actors. Even though they all end up in the same Instanced Foliage Actor they will end up on different lightmaps if they were generated with different PFS actors.

Hope this helps anyone struggling with the same issue.

If it helps, Landscape grass is gaining a feature in 4.12 where the grass can share the parent landscape’s light/shadow map. It’s not as good as full baked lighting, but it’s a big improvement.

It was a pull request too!

As for the crash… yeah that shouldn’t happen. That code is only hit when the lightmap couldn’t fit in any existing texture, so it creates a new texture especially for it. If it doesn’t fit into an empty texture, then something’s really wrong. Do you think you could upload a minimal repro project so I can investigate what’s going on?