Foliage causing ligtmass crash when building

Alright, I’m making a horror game. And it takes place in the forest, so i downloaded kite demo and added it to my project. To place trees, I used foliage painting tool. The I saved it and started building. Soon after, it crashed. After about 20 (seriousely) attempts, I somehow managed to build a scene. Then, I added more trees, because a forest without trees is not a forest. Then, I started building again and it crashed. Nothing has worked and I don’t know how to fix it. I tried to clean and validate swarm cache, deleting swarm subfolders and logs, lowering all meshes lightmap resolution (on all meshes is now set to 64, which is so low). NOTHING HAS WORKED! It tells me to lower number of meshes, but I can’t do that bacause I need them (and I need to add much more). Currentely, I have 3.88k trees on my scene. But I need about 50k to fill my huge map. I saw many games with over 100k trees, how did they do that? Please help me, I don’t know what to do!

Hello Hobrux,

I have a bit of information I need in order to understand this issue better.

If you would post a screenshot of your viewport and of the foliage brush with your trees and grass.

You said you had around 3.88k trees in your scene. How many tris do your trees have?

What is your culling distances set to for trees and grass?

Many games do have many trees and foliage, however, their distances and lights have been optimized to handle that amount of foliage.

Also, if you would link your dxdiag I will continue to investigate this issue.

Logan

It is not reasonable to use static lighting for that amount of foliage. You should consider using dynamic lighting(movable light source) or disable static lighting for the foliage.

Going, Back to what I said. You may change your culling distance to optimize for the shear amount of foliage you have in your scene. While Jacky’s suggestion is valid, using dynamically lit lighting will increase your GPU load and create a more expensive scene. This will also be the case if you have dynamic foliage. Your grass, you will want to have lit but you won’t necessarily want shadows on your grass. If it’s horror and at night, you may even consider just turning shadows off completely. Baked lighting for your rendering pass will always be less expensive than dynamic.

Consider your options and what you would like to accomplish and try the troubleshoots I mentioned above and then please feel free to ask more questions.

The problem is i cant even imagine the amount of RAM they would need to build lights for 50k trees(+ the landscape and other objects) : \ Lightmass will keep crashing on them for that reason and dynamic lighting will be inevitable. But yeah, all of your suggestions should be considered and foliage itself should be well optimized before even getting into lighting(culling distance, billboards, etc.)

I’m not sure what you want to see. I’ll send you screenshot of viewport and foliage, but that is all I understand. I’m sorry, I’m very new to the engine and I don’t know much about these things.
Culling distances and tris? What are these?

Here are screenshots:

So, culling, refers to the distance from the camera at which something is called. When you go to the foliage brush, where you add mesh’s to paint, there is a details panel that brings up options for that mesh. Like in your screenshot, under Instance Settings, there is an option for cull distance. By default it is set to 0 which disables culling. This says, as long as your mesh is within your viewport it will be called. By changing the max distance you can change how far the camera can see this mesh at. So, if you set the max distance to 500, at 500 you will stop seeing trees. Also you can type in your command prompt, by hitting the " ~ " key, the command stat UnitGraph to see where most of your calculations are taking place. From there you can dive into optimization.

The other issue, that you mentioned, was tris. Tris refer to the number of triangles that make up your mesh or scene. Whenever you import an object, if you leave it default, the engine will try and triangulate your mesh’s. If you double click on a static mesh in your content browser you can bring up a window with all of that mesh’s properties. You can see in the top left corner how many tris make up your mesh. When dealing with tangent space, a 3d software calculates all of the points that are in your scene and then calculates if there is anything between these points. The same holds true for your mesh’s. So imagine the calculation on an object that has a couple thousand tris. This calculation is rather light for a computer with decent specs. Now, imagine you added that mesh to the engine under foliage, and you painted that 50k times. Your, computer now has to calculate all of those tries on each object, and where they are inside of your scene. You will have serious performance issues. With the above mentioned method of culling, you can eliminate the amount of calculations happening where your camera looks.

There are other methods like level streaming and optimizing to baked lighting instead of dynamic to optimize your scene. However, since you say your are a little new, I would start with culling.

If you have any further questions about optimizing, please open another thread with that specific question. Others may have the same question as you.