Foliage + Lightmaps is broken/bugged/dysfunctional - Detailed explanation

Ok so I learned some interesting things today:

**Firstly draw calls **- I did tests with a scene that has around 1500 trees, comparing a fully baked scene and a fully dynamic one:

My conclusion is close to what I expected; foliage with lightmaps is still instanced and therefore has low draw calls. The dynamic scene has more draw calls due to the dynamic shadow pass (although not hugely different). So It’s safe to say using lightmaps will not increase draw calls.

Secondly, component sizes and lightmaps - I learned that foliage is not packed in the lightmap atlas according to the landscape component it’s painted on, but via the Instance Static Mesh component. So how it works is basically this:

It will try to fit ALL instanced meshes of a certain foliage type in a single level into one atlas, regardless of their location or proximity to one another in the level. This is obviously not a particularly efficient nor streamlined way for the engine to be handling this but I have discovered that by having multiple Foliage Types (Create new asset>Miscellaneous>Foliage Type) with the same mesh component, I can effectively push one foliage mesh counts beyond the limits of a single Packed Lightmap Atlas.

Also it seems that moving objects or landscape components which have foliage painted on them to different sub levels helps!

So I think for now, the solution is to carefully keep track of how many Instance Static Mesh Components are in the level vs the Packed Lightmap size and break them up carefully as desribed above.

Oh and one other interesting thing I discovered is that Half of your Packed Lightmap Atlas size is used for directional lightmaps - so you will need to half the amount of foliage instances you can fit into one atlas!

Hope this is useful info!