So I’ve been looking into this issue for a the past few days now and have come to the conclusion that either foliage with baked static lighting is currently fundamentally broken due to what seems like some design oversights, or that I’m missing something with how it works altogether.
.
My scenario is this:
- I have a large landscape with
approximately 31k trees, currently
consisting of 1 tree model. - The tree model has lightmap Uvs
carefully laid out for a minimum of a
32 x 32 px lightmap, which the model
is set to by default in the static
mesh editor. - Tested and baked individually with
the default lightmap size of 32px,
the tree lights correctly as
expected.
.
Upon painting and baking lighting of the tree on the landscape, I am receiving the following warning:
InstancedFoliageActor_0 The total lightmap size for this InstancedStaticMeshComponent was too big and it was automatically reduced. Consider reducing the component's lightmap resolution or number of mesh instances in this component
InstancedFoliageActor_0 The total lightmap size for this InstancedStaticMeshComponent is large, consider reducing the component's lightmap resolution or number of mesh instances in this component
.
The result of this is that the lighting for the trees looks very bad, seemingly due to the lightmaps now being reduced below 32px. Looking at the warning, it tells me to * “consider reducing the component’s lightmap resolution or number of mesh instances in this component” *
.
Now, to me this is unexpected - my landscape is made up of 64 components, each with approximately 484 trees, my Packed Light and Shadow Map Texture Size is set to 1024in World Settings, so it seems like there should be plenty of room for 484 32x32 lightmap atlases. (if my calculations are correct, you can fit 1024 32x32 lightmaps into a 1024x1024 texture).
Regardless, I gave it the benefit of the doubt and increased Packed Light and Shadow Map Texture Size to 2048, and then 4096. No matter what I set Packed Light and Shadow Map Texture Size to, the result was always the same; same warning + bad lighting on my trees.
.
I did some further investigation, looking at the baked lightmaps themselves with Packed Light and Shadow Map Texture Size maxed out at 4096, and concluded that it currently tries to bake all foliage into the same atlas, regardless of any landscape component. With this and the fact that the editor references all foliage as InstancedFoliageActor_0, It seems that all foliage is treated by the lightmapper as one giant model which seems highly inefficient, especially when it comes to texture/lightmap streaming.
.
Here are the following things I have tried to break up the foliage into smaller components/lightmap atlases:
- Duplicating the model and painting
the copies as different foliage
types. - Creating multiple Foliage Type
assets with the same model and
painting them as above. - Separating the landscape into 4
different sub-levels and re-baking
(highly inefficient workflow)
None of the above worked for me, I still receive the same warnings and the same issues for all scenarios.
.
In Epics own documentation on [Folaige Instance Meshes][2] I found this under Lighting:
- Lightmap Resolution - This must be a
small enough number so that all the
shadow maps for instances in a single
cluster (by default 100) can be tiled
together without exceeding the
maximum texture resolution
(4094x4096).
.
Has the cluster size been changed? Can it be changed manually? I cannot reduce the lightmap size of my trees any lower than what they are right now and it seems crazy to me that it’s struggling with this. I’ve seen dozens of threads posted about this issue with zero solutions.
Can someone out there offer me some information or advice about this?
I’d be happy to upload an example project if necessary.
Thanks.