Foliage causing gpu lightmass to crash

Whilst working on a project in 4.27.2 a new issue has occurred which is causing foliage to crash gpu lightmass when it starts encoding textures with this error:

Assertion failed: SizeX != -1 && SizeY != -1 [File:D:/Build/++UE4/Sync/Engine/Source/Runtime/Engine/Private/ShadowMap.cpp] [Line: 619]

Last week I was able to build lighting without issue and I cannot pinpoint what has changed within the project to cause this issue.

Furthermore I have found this issue to persist in a completely different project I setup to investigate this issue. If I create a new scene with just a landscape, sunsky, and a couple of static meshes lighting builds fine but as soon as I add a single foliage actor the lighting crashes the engine as soon as it starts to encode textures.

I have removed/ reinstalled, and verified the engine version I am using. I have also updated drivers for the RTX 3090 I am using. I also have asked a colleague working on a different pc to test this and they have had the same results with the same error message.

Any help would be much appreciated.

I am facing the same issue exactly right now.

Everything was baking great but after I disabled Virtual Texture Lightmap Support I got the error and crash!

Turning it back on fixed the issue.

The problem is that using the virtual texture support for the lightmap introduces other flickering shadow bug so I rather turn it off. Now I’m not sure what to do.

I just want to say that I have the same issue and it was the foliage that was causing the problem. I am using 4.27.2 as well.

It was definitely foliage causing UE4 to crash when encoding textures, if I removed all foliage it seemed to bake fine.

I did find a working solution by selecting all foliage actors in the scene and setting their ‘Lightmap type’ to ‘Force Volumetric(in the foliage actor settings drop down section under ‘Lighting’), this seemed to fix the issue, but I’m not sure if that is an optimal solution to the problem.