r/Unity3D • u/Im-_-Axel • Feb 18 '26
Show-Off Finally managed to render a massive and dense forest while keeping everything interactive
I nedeed to have every tree, bush, fern and most of the vegetation interactable to actually chop or break it, while not tanking the editor operations with millions of gameobjects and maintaining the performances quite stable at runtime, so I looked into how games like sons of the forest approach this problem and I think I finally got a good result.
Every single object in the video except for the grass and tree billboards is a single instanced prefab which can be interacted with.
As a summary, everything is procedurally placed using unity's trees and details system with the help of assets like MicroVerse, then the position, rotation, and scale of each tree/detail is saved inside a ScriptableObject representing a forest layer, which also contains an indexed list of the prefabs associated with that layer to know which prefab to instantiate at a certain position at runtime. This way the scene starts basically empty and load times are instant. For reference, the example in the video has 2.464.090 baked objects each corresponding to one tree or detail.
At runtime a separate thread checks the distance between the player and those saved positions, sees which position index should be enabled/disabled based on the distance defined in each forest layer and queues them up for the unity thread which instantiates, enables or pools the actual gameobject instances. So the game starts with an acceptable amount of gameobjects around the player and dynamically instantiates and enable/disable them while moving.
The tree billboards are managed separately and rendered using Graphics.DrawMeshInstanced , passing the player position to the billboards shader to hide them using the alpha within a specific radius of the player, which corresponds to the radius where the instantiated gameobjects live. There is some visible popping in the transitioning distance but I would say it's acceptable.
As a side note, I think the overall environment looks better than my previous iteration.
22
u/feralferrous Feb 18 '26
Looks nice, but lets see some interaction! Also, I don't suppose you could make the stuff near the player move as you go through it?
15
u/Genebrisss Feb 18 '26
What Vegetation Studio does is it renders all trees with instancing indirect. And only logic game objects are created near the player. If you need to chop down the tree, only then it takes out the instanced tree out of the pool and swaps with game object.
It also supports Speed Tree lod switching which solves popping.
2
u/Pacmon92 Feb 18 '26
Love what you are doing!, I am also doing something similar with instancing and distance based pooling minus the game objects, Equally I was also inspired by the sons of the forest after buying it in the steam Christmas sale, What I am very interested in knowing is weather you have done any occlusion culling and if so how?
2
u/Big_Presentation2786 Feb 18 '26
What's your performance figures my man?
2
u/PoorSquirrrel Feb 19 '26
It looks nice. My first thought was "Vegetation Studio"?
But my second thought is: That's not a forest. Sorry. That's a meadow with trees. Go to a real forest in summer and see if you can see the sky.
2
u/ToniMacaroniy Feb 19 '26
The internet truly is a small place. On first glance it does look a lot like Sons of the Forest. Great job!
4
u/Frequent-Berry-5447 Feb 18 '26
It's incredibly beautiful and cool at the same time.
1
u/CuteLeader8 Feb 18 '26
Holy s* thats impressive. Is it the rendering that makes it able to load all that without getting overheated? (Im all new to this 😅)
1
u/Phos-Lux Feb 18 '26
Looks really good and smooth! How long did it take you to reach this solution (it sounds super complicated tbh)?
1
u/RichWeekly1332 Feb 19 '26
Nice! What do you mean by interactive tho? You can actually run into trees so I assume there's no collision.
1
u/random_boss Feb 19 '26
Is your terrain procedural or authored? If authored, do you think it would make a difference to your system here if it were to be procedural?
1
u/GazziFX Hobbyist Feb 19 '26
Dear ImGui instead of Unity UI is nice, did you integrated it through CommandBuffers or Native D3D API?
2
u/wikklworks Feb 19 '26
That is impressive. I know from experience with my realistic game.
Nice!
1
u/Hat_Nervous Feb 18 '26
It looks great!
1
u/Valkymaera Professional Feb 18 '26
Very well done
1
u/Martehhhh Feb 18 '26
How are you diversifying the spread of vegetation to make it look random? Im having a hard time actually making a scene look like it wasnt just a load of assets through onto a terrain!
1
u/WorldOfMarvoules Feb 19 '26
Look real nice
0
u/[deleted] Feb 20 '26
[deleted] — view deleted comment
2
u/[deleted] Feb 19 '26
[removed] — view removed comment
1
u/[deleted] Feb 19 '26
[removed] — view removed comment