Download

1016064 trees

Wanted to see if I could spawn more than a million trees. Assets are from the Kite demo package.

Some screenshots once down on the ground. I could probably roam for hours.

eab4ab116a248f30ca26ed308b128027f2b216ac.jpeg

They had an overall of +15 million foliage instanced in that demo map. (With optimization, not loading all at once).

How many fps do you get + what are you specs? :smiley:

Dynamic loading is the key :slight_smile:
I have only about 40000 foliage instances in this test. Plus the 1.000.000 trees of course.

I found that collision is the most expensive part about this. Dynamically having collision only on the nearby/needed trees increases the performance drastically.

Have you employed culling at all? Looks like it runs well enough from the short video. Pretty cool!

780 GTX and I7-4790K @ 4.6GHZ.
50 fps while falling. 23 fps on the ground at 1080p. But if decrease the amount so they don’t stand so close I get much better results. It was just the spread I needed for 1 million trees in a single landscape.

Here is a slightly less packed test (but still way too much to fit other stuff in between)

b998ec7d59fbcb88cd23a8b93eb68087124ed92f.jpeg

No culling. Just the default lod that the assets come with.

NO, no Stop, you can’t do that!

You’re making my brain melt. so envious, sheesh I need to get off this forum and read some more documentation.

Just tested my trees on my PC (gtx 660 ti, intel i5-3570 3.4GHz) and I also get a pretty good performance → with 2 million trees I get around 40 fps…that’s insane :smiley:

Could you please share how you are spawning those trees? I’m trying to procedurally do something with trees and I can’t even get 30,000 trees to render without killing my frame rate. I’d love to see how you are getting so many on screen at once. Cheers,

J^2

I added some more trees and ended up with 2178900 this time.

Once on the ground the performance issue is mostly when a tree casts shadow on another tree, this affects the performance quite a bit. So if you want great performance, don’t let tree’s shadow other trees. :slight_smile:

I’ve been using the week to learn unreal and some c++. So I made a forest generator and a foliage tool. https://forums.unrealengine.com/showthread.php?65268-WIP-Procedural-mesh-generation
In this demo I use the foliage code to spawn the trees and have turned off collisions for them. I’m thinking about combining some of logic in both tools to create a forest generator that takes a set amount of trees (lets say 1 million) and reuses it in such a way that you can never run out of trees. :slight_smile:

PS: The trees in the kite asset pack have a 2d-sprite as their lowest lod. I can see your having problems if you use trees that are still pretty detailed at their smallest lod.

BTW: In the video below the foliage is about 20000 instances, but as you can see I can run around forever :slight_smile:

Hmm. The beginning of your first video, where you start way up high and move down, how many trees would you say where in view at the beginning? And where they all using the lowest LOD/billboard tree? I’m looking at a more Civ V type scenario, less Far Cry, so I need to get a bunch of trees pretty closely packed that still look like trees when viewed from 1 kilometer above them. I haven’t been able to use the foliage system since it really isn’t compatible with a procedurally generated level. I’ll take a look at that tree model and see what’s different from the one I’m using. Maybe they have some secret sauce in there. Cheers,

J^2

I’m guessing I can see between 200.000 - 400.000 trees at the beginning.

If you want to be able to zoom far out and still see trees, but at the same time zoom way in: You have to do some magic, you can’t have 1 million meshes with a lot of polys each. You need a good lod so that the tree is mostly just a 2d-sprite at the very distance, hd close up and some levels of lod in between.

Btw: How do you spawn your trees? C++ or blueprint?
I take a static mesh and create a HierarchicalInstancedStaticMeshComponent out of it. Then I add instances to that.

Here is some example/psudo code:
UHierarchicalInstancedStaticMeshComponent* HierarchicalInstancedStaticMeshComponent = CreateDefaultSubobject<UHierarchicalInstancedStaticMeshComponent>(TEXT(“MeshComponent”));
HierarchicalInstancedStaticMeshComponent->SetStaticMesh(StaticMesh);
HierarchicalInstancedStaticMeshComponent->SetCollisionEnabled(ECollisionEnabled::NoCollision);

// For each tree
FTransform transform = FTransform(…);
HierarchicalInstancedStaticMeshComponent->AddInstance(transform);

I looked at your other post and was wondering, you are implementing the bp node in C++, but are you building off the existing foliage system, or making your own? And are you extending the instanced static mesh class or the hierarchical instanced static mesh node? I’m asking since I’m working with Zeustiak on his random map generator and we’ve kind of gotten stuck in the trees. They are killing our frame rate. We are using the HISM node to make our forests, but the impact on frame rate is not what we had hoped. Are we just going too far by trying to use individual trees to build the forest? Do I need to make a more simplified universal “forest” mesh? Any advice would be appreciated. Cheers,

J^2

Map Generator 3.0 - Please Critique! - Blueprint Visual Scripting - Unreal Engine Forums!

We are basically doing what you describe, using blueprints. I do have LODs set up, and you can definitely see the 2D one in use, but they still kill frame rate. Even with the 2d billboard trees, we are getting slammed. I’ll have to do some more research and see what I can do that might be more apropos to our situation. Cheers,

J^2

Liked, and subscribed! Cool stuff!

Disclaimer: I’ve never coded C++ or in Unreal before, and I picked it up 5 days ago. So I might not be doing it correctly all the time. :slight_smile:

The blueprint is based on AActor.
I have a StaticMesh property where i set the tree mesh.
Then I create a UHierarchicalInstancedStaticMeshComponent and set the static mesh that was given in the property. I don’t think there is a difference if I use UInstancedStaticMeshComponent or the other, but UHierarchicalInstancedStaticMeshComponent is newer and supposed to be used with foliage (Someone said somewhere). But I’m not sure I get any advantages from it because I don’t know exactly what is different between the two.
Then I generate my FVector’s where I want to spawn trees, and for each I do HierarchicalInstancedStaticMeshComponent->AddInstance(transform);

Btw: I’ve made two blueprints so far. One for trees which is a lot like the one coming in 4.8. And one for foliage that has 9x9 tiles where the tiles “follow” the player around. I’m planning on using a tiling system for the trees also, so that I can spawn trees regardless if the world is 10km2 or 100.000km2

Here is a demo of how the tiling works.
The foliagegenerator has a minimum of 81 meshes (1 pr 81 tiles since it’s 9x9). Lets say tile row index 0 is at the top, and 8 at the bottom. If I move 1 tile-length up, the code moves the 8 row up, then the 7, etc. So the area is always center to the character.
Since all instances are added at start, all I do is move them around. I never delete or add new instances.

Then I make it 7000 large in radius and make it spawn 100 meshes pr tile.

Then I copy&paste it and make the new one 15000 large.

Here is the exact same scene with a grass texture on the landscape.

Just tested UHierarchicalInstancedStaticMeshComponent vs. UInstancedStaticMeshComponent and the result is quite drastic!
If you look at the images you see that UInstancedStaticMeshComponent doesn’t seem to LOD correctly for objects. Notice both the trees and the grass.

27 fps vs. 4 fps
f5d0488cc10e2a0f206a2ac6aa2f94d124de0317.gif

Yes, I think that was supposed to be one of the biggest differences between the ISM and HISM nodes, the fact that LODs will work more appropriately. As I’ve been told, the ISM node would shift the LODs of every instance when even a single instance needed to shift whereas the HISM node only shifts the LODs of those instances that need it. Alas, it seems like all these system are still geared towards the usage of a first person perspective where you are view the trees from the ground looking up at them, not from the air looking down. The more I look into this the more I think we need to move away from using the Foliage paradigm entirely and just make a single mesh “forest” that will work when instanced 30-50k times. I’m sure it’s doable. They did it Civ V, so it’s possible. It’s just a matter of wether its something a complete non-coder can achieve using blueprints or not. I’ll keep digging. Cheers,

J^2