Download

Creating an optimized forest

Hi all,
I’m having some trouble creating a forest for a large scale environment.
Basically I have made a terrain about the size of 10 x 10 kilometers that needs a lot of trees and other foliage. For some reason, as soon as I paint an area with some foliage, be it grass or trees (taken from the Nature mega pack) the FPS dramatically decreases, and I mean a lot. Without foliage the scene runs at 70+ FPS. With foliage it runs max 30 FPS, and with a decent amount of foliage that actually makes the scene look like a forrest I may be lucky if I get 2 FPS.

First I thought this was an LoD issue, but these assets have all been pre-made, and if I turn down the culling distance to 1 so that all foliage disappears, there’s no improvement in performance whatshowever, even though not a single plant is rendered.
The weird thing is, the Nature Mega pack comes with an example scene that contains loads of grass and trees. Almost the entire scene is covered with it. Yet it runs marvelous with a solid framerate. I can’t for the life of me figure out what this scene does differently opposed to mine. My scene contains way less foliage and it’s a slideshow. Even if I bombard the example scene with thousands of plants using the foliage painter the performance barely decreases only until I reach a ridiculous amount of plants.

I also tried using smaller terrain meshes that overlap but performance wise it’s no difference.

Can anyone give me some insight on why my performance is so bad? 30 FPS is unacceptable for me considering 98% of the game’s mechanics still need to be put in. I’m running on an GTX 970, 8 Gig of RAM and an i7 processor of 2.8 Ghz. Engine version 4.9.2.

There’s one other thing I cannot figure out that I might as well mention right now;
In the example scene of the Nature Mega Pack, all trees are individual objects and aren’t placed using the foliage tool. Performance wise it seems to run a bit better, but the trees also have collisions which they don’t have when added as foliage.
Is there a way to paint objects on the terrain without using the foliage tool? I can hardly imagine they placed all of those trees by hand. The advantage of this method besides performance and collisions is that the position and rotation of each individual tree can be manually adjusted.
I did read about SpeedTree, but it’s too expensive for me to have another montly subscription.

In the editor, use the devtools with different options (quick for example), it points you in the right direction.
:slight_smile:
PS: From my personal limited knowledge these big maps 10x10 are cool to create, but hard to optimize.
When your map has a valley, where you have great panoramic view, then it is so much work.
Start smaller, seperate levels, use teleporters to get to new zones(enter doors).
Better to optimize. You can always go bigger and snap the next tile to another, if enough performance is left.
Use buildings/poi or high stuff like hills to block views.
Setup basic cube objects and scale them to limit view from some perspective and then rebuild that blocked area with something you like.
:slight_smile:

you can manually adjust trees after you have painted them, one of the tools in the painting area lets you select them.
placing trees down one at a time is really bad for performance, each tree will need a draw call, 5000 trees will be 5000 calls to draw it and will kill your CPU. with the foliage tools you can have 100k+ (any number really) and it will only cost one call.
there is a setting to enable collisions for foliage in the tool somewhere, or it would be kinda pointless.
in the kite demo they use These

i’m currently running around 130k trees from the kite demo on an 8k x 8k map, fully dynamic lighting with day/night cycle, seasons and weather effects, and everywhere there isn’t water its covered in grass meshes. I get min 45 fps.
make sure your 970 isn’t hitting the 3.5GB wall, that will kill your performance
this is a pic of my current foliage

But then a high sys spec is rquired to run that, with a 970 min. ?
PS: Nice waterforest.

Try baking the lighting.

First of all happy new year guys!

Thanks a lot for your replies. It looks like baking did the trick! My scene ran at 8 FPS before I built the lighting. After it was done it ran around 80 FPS. Now I feel like an idiot. :rolleyes:
I tried baking another test scene before but there it didn’t seem to improve the performance, which I now expect was caused by the huge terrain consisting out of one mesh.

I now also noticed the detailed options for the foliage and managed to individually move or rotate trees. Thanks!

Btw, every time the baking is done, I get a huge list of errors mostly saying “Instanced meshes don’t yet support unique static lighting for each LOD, lighting on LOD 1+ may be incorrect” Any idea how to prevent these errors from showing up?

Pretty sure it’s for all meshes with LoDs. Shouldn’t bee too much of an issue though, the LoD meshes will use the same lightmaps as the baseLoD meshes which could cause some artifacts but is usually no issue aslong as your lightmap UVs do not differ per LoD.

Alright that’s good to know.
Something odd I found out btw, if I uncheck “cast static shadows” and enable “dynamic shadows” on the sun light, all lightmaps get ignored and all shadows become dynamic as expected, but the framerate runs around 50 FPS. You would expect that the editor would go into a crawl since not a single shadow is static anymore, but it does the opposite.

I accidentally noticed this due to some other problem that hopefully you know something about;
I added some more foliage to the terrain and decided to bake the lightmaps again, waited about 45 minutes for it to complete, but after it was done some of the foliage turned full bright (not the foliage I added later, just random bits), completely ignoring the shadows. There also appeared a weird edge shade suddenly on one of the landscape’s tiles. Something that didn’t happen before. Also the error that lighting of 51 objects needed to rebuild didn’t disappear.
Have you ever encountered something like this?