Foliage + Lightmaps is broken/bugged/dysfunctional - Detailed explanation
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:
Upon painting and baking lighting of the tree on the landscape, I am receiving the following warning:
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 **1024**in 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:
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 I found this under Lighting:
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.
Hey again brisck1,
So I did some extensive testing and my assumptions about your issue were correct. What you are encountering is expected, as the density per component relative to the lightmap resolution of each instance within that component, are what comprise the overall limitation. As proof of this concept, I took your test example and changed the density of painted instances per component and rebuilt using different Lightmap Resolution Overrides.
There is a reason we have exposed the Lightmap Resolution when painting foliage instances, and why 8 is the default resolution. There is an understanding that users will want to paint these foliage instances fairly densely, and having it fit within the required lightmap resolution limitation with the default lightmap resolution (usually 64) wouldn't be manageable.
Above you can see my landscape size 8x8 components and the overall resolution. This helps give you an idea of the density per component.
16 Lightmap Resolution - 1024 Packed Lightmap Resolution
Now you can see how I am getting the same message you are reporting, using the settings outlined and mentioned.
16 Lightmap Resolution - 2048 Packed Lightmap Resolution
Here you can see the message has been cleared after increasing the packed lightmap resolution.
All in all, I do understand what you are reporting, but you are simply overloading the allowed resolution per component. This is why we have techniques like Cascaded Shadow Maps and Distance Field Shadowing to help blend to crisper shadows while keeping the low lightmap resolutions at far distances so they are less noticeable.
Cascaded Shadow Map Transition Example
As you can see in the above gif, I have set up some the cascaded shadow maps to essentially transition cleaner and hide the low quality lightmap/shadowmaps up to a certain distance.
Your issue is all going to come down to the platform you are developing for, and the techniques allowed per platform. If you want to use fully static lighting for an outdoor scene like this, you will have to work within the limitations of that lighting mobility type, which includes the lightmap limitations for landscapes.
answered Feb 15 '17 at 10:30 PM
So I went into the test project you provided and immediately had some things for you to improve your situation. This might not be the case in your actual scene, but with levels this large be sure to use a Lightmass Importance Volume.
Secondly, the density in which the foliage has been painted is very extreme and even on my powerhouse of a machine, I was having some performance issues. Be sure you are establishing an End Cull Distance by setting up the Per Instance Fade amount within the static meshes material.
Third, the only way I see to workaround this is to reduce the density of your trees a little bit, per landscape component. What you can do is give them a bit larger scale so you can have less that occupy the same amount of space. You then need to go into the foliage setting and set the lightmap resolution there to override the static mesh settings.
Next, you need to establish LODs, this makes it so you don't have one single LOD which quickly fills your packed lightmap size for your landscape components. Also using the cascaded shadow maps to help conceal what might be poor lightmap resolution. This way as you get closer, the nice high resolution shadow will stream in, and the far shadows with low lightmap resolutions will not be as noticeable.
If none of this seems to be working, you can resample your landscape to have a larger amount of components and divide them into 2x2 subsections to have greater control over the packed lightmap resolution per component.
Let me know if you have additional questions.
answered Feb 10 '17 at 10:05 PM
So upon further testing I have discovered that it is the foliage component and not the landscape component that Andrew was referring to, that's interesting! I think i can now use this information to better manage my meshes.
So in summary, here's what I learned:
So I think for now, I think my 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 described above.
Follow this question
Once you sign in you will be able to subscribe for any updates here