Procedural Foliage in Unreal Engine 4 | UE4 Tutorial (2020)
Вставка
- Опубліковано 22 лип 2024
- In this UE4 tutorial we will take a look over procedural foliage in the newer versions of UE4 (4.22 and above). To be more specific, we will discuss when and why you should use procedural foliage and then we will see how we can create procedural foliage in UE4 ourselves.
It may sound hard as procedural stuff isn't the easiest thing out there, but 90% of what you need already comes with engine, so don't worry if you're not very experienced with procedural generation in UE4.
♥ Patreon: / nitrogendev
One thing to keep in mind is that, in our case, procedural foliage does not mean foliage spawned at run-time. And while that might be a bit disappointing, procedural foliage in Unreal Engine is still a great tool for organic looks.
Sources:
Foliage pack used in this video: www.unrealengine.com/marketpl...
Music used in this video:
- Like Saturn - I Don't Mind ( • Like Saturn - I Don't ... )
All content on Nitrogen is available for free. We, as a community, support completely free education available to everyone. Any support is appreciated for me to keep making content for free and improving it.
We recently hit 10k!!! A milestone that was once so far was finally achieved and I'm so proud of our growing community! More and cooler tutorials are going to come, so if you haven't joined this community yet, make sure to do so!
On a side note, I made some pronunciation mistakes throughout the video such as saying fifty instead of fifteen, but hopefully that wasn't confusing.
As well, this is a remake of an older video and, while I don't usually do remakes, it was request by a lot of you and the old one is a bit obsolete.
You know!
You can also spesify the the material layer you want the foliage to spawn on...
That mean you don't need the blocking volume, except to block areas you want to be cleared.
Like if you have different foliage types, you can give them each a material layer to spawn on. (Or several layers)
Then if you leave out the roads and other layers. The foliage will not spawn on those material layers!
You may have to enable view advanced in the view option (The eye drop down )
The landscape videos were the main reason why I subscribed.
Congratulations! Your video format is awesome and I love how short and to the point these tutorials are.
yes please make tutorials for this topic as deep as you can
Will do!
And as C.L.E.A.R as you can
Is it out yet? The in depth video on this
Hey I know this video is almost 2 years by now, but it is still amazing! Doing my exam project in Unreal and I am the level designer in the group. I thought the procedural generated forest I had to make was going to be a pain, but instead I ended having a blast using procedural foliage tool. I was worries when I first heard about the tool that it was very specific meshes you could use, but Works great with the polygon assets I bought for the project! Again, thanks for the quick and easy starter guide :D
Very nice tutorial, I really like the way you explain stuff, not too fast and not too slow :)
Happy to hear that! :D
is it possible to add some "smoothing" onto the flat polygons for the leaves, to make them more bendy..something like sub-d....branches too....I feel the thing that breaks photorealism is jagged polygony branches and leaves that are clearly mapped onto a square polygon
If you know your way around Blender or any other 3D modelling program, you could certainly do that. But in terms of procedural foliage inside Unreal Engine, there's not much you can about it.
Thanks buddy , really helpful one
There's really great UE stuff on your channel. I'm learning alot thanks to you. No wonder you will reach 20k subs soon. #UnrealEngine #Realtime
I appreciate that!
VERY, very useful video!!! Thank you very much
the wind blowing in the grass is so satisfying lol
So true haha. Perhaps I should just upload half an hour of that grass waving.
Great tutorial do you have a tutorial like this but for grass placement?
YES advanced tutorials please!
Hello! Thank you for the tutorial!
How did you do your grass in the example? Was it with procedural spawn too? or just draw in foliage mode?
Hi great tutorial Having a slight problem, when I click on the Tree.PFS volume I just get a blank screen load up.
Hello, Thanks for the great tut, I have a question in minde now in UE5 I am using open world, and when using the foliage tool in large scale or far away the trees dont show up untill you come to a distance, Is there a way to increase this distance of a way to bake the whole thing?
Thank you for the awesome explanation!
Glad it was helpful!
awesome ! Thanks for the Tutorial :)
No problem! :)
How would one resimulate on beginplay with a different seed of rthe BFS?
Nice and clear video, thank you.
Glad you enjoyed it!
Hi, How do you create a custom brush type ?
hi,every time I put Procedural Foliage Spawner in level,it crash in UE4
Thank you! Your style of teaching is perfect. Do you have a 4.26 tutorial on how to efficiently set up the paint terrain tool? Say for items coming from Megascans? All the best...
Unfortunately, I don't have a tutorial on that.
Very nice and useful ..........Thanks
I want use foliage for stone river in garden. can you help me ? please !!
A bit late, but what about FPS's? When I paint my trees with the folliage tool my FPS drop to 6-8 even having a Nvidia RTX 2070 Super and a 3070 on my personal pc. Do FPS increase using procedural folliage?
Thank you so much, very informative.
Glad you liked it!
Can anyone pls tell me how he created that muddy road in the forest pls?
You save my lifetime, thx so much !
No need to thank me!
It's giving me an error (Unable to spawn instances. Ensure a large enough surface exists within the volume) I tried to to make the cube bigger, but still giving the same error.
please help.
How do I enable collision on the Foliage? I tried checking if it has the "BlockAll" options but no luck.
Hi there, were you ever able to figure this out? I am also having that issue.
It's not working, error: Unable to spawn instances. Ensure a large enough surface exists within the volume. What is mean?
I have ran into an issue with Procedural foliage spawning. I have set up the foliage types to spawn on only certain landscape layers however it refuses to spawn anything at all. It appears to be because we have the map split up into streaming proxy’s? I tested the same set up on a simple landscape and it works fine. Am I missing somthing?
had the same issue as you but thinking it just doesnt like rough terrain
Hey Nitrogen! Great tutorial. Do you know how to fix the issue of shadows turning off on procedural foliage that is far away from camera? I've tried everything I can think of and it's still doing it. Thanks for any help!
Actually, that is not an issue, but an optimization. Because those trees are supposedly far away, the engine doesn't bother shading them anymore. But you can get around that using distance field shadows. For this, you will need to turn it on in the project settings, enable it in your directional light after the distance fields have been generated and, finally and VERY importantly, in each foliage type, for each mesh, you need to enable "Affect distance field lighting" or something along those lines.
For a clearer explanation on the process, check these links:
docs.unrealengine.com/en-US/BuildingWorlds/LightingAndShadows/RayTracedDistanceFieldShadowing/index.html
forums.unrealengine.com/development-discussion/rendering/1428407-distance-field-for-foliage
Very helpful, thanks!
Glad to hear it was helpful to you!
Amazing tutorial. Thank you! Question. My map has a hill, the trees spawn on the normals but sideways. how can you make the spawn straight up even on the hill?
In the foliage type, there is a setting called "align to normal". Uncheck that and the tree should point upwards.
@@NitrogenDev Thank you !
how to grow auto tree ony in box and in spesific texture/color automatickly, eg. in mountain with mix material blending with more than tree unic tree seperate mix all type plant and grass specific different type of one mountain to other hill etc..
one question: how do you solve the problem with everything either running through all those trees or get blocked moving at all?
You could do it two ways, which yield the best result if used together:
1. Create custom and precise collisions for those trees. You can either do this in-engine (check the collision documentation page, in case you don't know how) or manually create the collision (this shouldn't be necessary unless Unreal really can't give you the result you're looking for).
2. Decrease the density of the forest. If there are too many trees, it will be physically impossible to move between them.
These should fix both your problems, so let me know if that helped!
Hi, where do you have the pine tree collection from?
Thanks.
Those come from a marketplace pack called "Procedural Landscape Ecosystem": www.unrealengine.com/marketplace/en-US/product/procedural-landscape-ecosystem
Dope, amazing video. How did you make the short shrubs and bushes?
The shrubs come from the asset pack mentioned in the description of the video.
Loved It!
Thank you!
How does the collision radius differ from the shade radius? Thanks
The description in the engine is pretty vague, but here's what I understand from it. The shade radius is used to completely stop other instances from growing close to an already-spawned instance. On the other hand, if another instance tries to spawn in the collision radius, the engine decides which instance to keep (between, say, a spawned tree and a to-be-spawned one).
Where did you get the procedural ecosystem content? I did not get any of that when enabling the procedural foliage.
That is a marketplace asset pack (www.unrealengine.com/marketplace/en-US/product/procedural-landscape-ecosystem) that you will have to buy to gain access to, but you don't need it to create procedural foliage. You can use any foliage pack that you have.
Hi. Why cant i use procedural spawner on rotated landscape?, i have me z rotation at 45
Not sure, but I don't think it's relate to the landscape. Are you sure you set up everything correctly?
my player walk through trees and the tree meshes has collision
is there a way to add wind movement to this ?
thanks for the amazing tutorial !
One simple way to do that is create a wind effect inside the material of each tree and control the world position offset. You could most likely create a material function so you don't have to deal with rewriting the code again and again.
Useful, Thank you!
Glad it was helpful!
THANK YOU YOU ARE MY SAVIOUR
what about world composition? how can this be used with a large map with f.ex 53 levels?
Shouldn't be any different. At the end of the day, it's just like manually placing the foliage, but it's done by the engine.
very informative, thank you for sharing. quick question, performance wise, is this more efficient than using the regular foliage paint tools? how about the impact on memory?
As far as I know, there shouldn't be any performance hit as the trees aren't generated at run-time.
@@NitrogenDev Thank you !
thanks it's verry cool tuto
Glad you think so!
Hi nice tutorial
When u r zoomout (in the video 06:22) the viewport that time shadows and lightning details not showing why and how to get ride that issue.give me solution for that.
In order for shadows to appear at larger distance, you have to enable distance field shadows. I am by no means an expert in this area, so I'm sure this page will help you out: docs.unrealengine.com/4.26/en-US/BuildingWorlds/LightingAndShadows/RayTracedDistanceFieldShadowing/
@@NitrogenDev thank you 👍
How about the impact in the memory ram? To many trees /rocks & grass.
Obviously you have to pay attention to that, just as you would do with the traditional foliage tool.
Hello, thanks for the tutorial :)
One question: I have set the size of the spawner to cover the whole terrain and added some trees, grasses and rocks. Is there any way I can spawn specific foliage with a specified slope?
e.g. I do not want trees to be spawning on the cliffs (just on plateau), and I do not want rocks to be spawning on the plateau (just on cliffs)
That is possible and I have an idea of how it's done, but it's a pretty lengthy process and I'm not sure it would work. Instead, I recommend using multiple spawners instead of a big one for now, and I might do a tutorial on that once I find out a good solution.
@@NitrogenDev Got it, thanks :)
How do you make the grass and flowers? Are they procedural. It would make a good tutorial.
Yes, they are procedural! A video on that is coming out this Wednesday.
I realise this is an old video, but consider me subscribed, liked and probably patreoned once i've looked through a few more, there's not may tutorials of this quality for landscape.
Definitely make more tutotials like this.
Are the tree's you used from an asset pack? Or did you make them ?
I am happy that you liked this tutorial. I need to mention that recently I have changed the kind of videos and content I make, to be more exact, from Unreal tutorials to game design videos, for a number of reason, which I could tell you about if you're interested. That said, please don't expect many more Unreal tutorials from now.
As for the trees, they're from this pack: www.unrealengine.com/marketplace/en-US/product/procedural-landscape-ecosystem
Why the change? i mean its okey that you like to take another direction but your ue4 tutorials are one of the best, straight to the point.
is there a way to clear foliage with splines?
There probably isn't a method the engine gives you out of the box. You could, however, edit the source code to allow you to use special splines and then rebuild the engine with that new class. Tedious, I know, but it's probably the best way to get precisely your desired behaviour.
Hi, does anyone know how to get rid of those empty corridors that appear in grid pattern across entire foliage spawn area? One clear line can be sean in the video at 5:00. It makes the tool unusable for forest creation.
A quick fix would be to place some trees manually along those corridors which should be very easy if the foliage tool takes the procedural trees into consideration when spawning other foliage.
@@NitrogenDev Yes, thanks for reply, I have thought about it but.. It just sucks out the very first purpose of the systems procedularity. Any bigger forests, like the ones i would like to make XD, just have to much of those corridors to manually fix them. Defeats the tools purpose it this case HOWEVER when making smaller patches of foliage, that arent continous across the entire map the tool works fine since you cant see the corridors so aparently... But they are still there. They should fix that.
This was so gooood
Thank you!
Can Procedural Foliage trees interactive? Like chopping them?
You should be able to. If I am not mistaken, you can now spawn blueprints as well using procedural foliage volumes.
Can you make a lumberjack in UE4? That forest is so alone...:)) Another job well done!
I'll just make the player be the lumberjack. :)
Unable to spawn instances. Ensure a large enough surface exists within the volume. Can anybody help me to solve this problem?
I had that in the past as well, not sure if I even figured out a fix, but I'm sure I sometimes managed to get over this by getting a new volume. Perhaps you could try exporting the height data and creating a new landscape using that height data.
That means that it's unable to spawn foliage there for any reason. For me the reason was that I was trying to spawn my foliage higher than I put the limit. Therefore it wouldnt let me spawn it and it would give me that message.
can you do one with grass to please :D
Love you
This is why UE4 is superior over unity. Much more available tools! Great video as always friend!
While right now Unity might be better than UE4 in some aspects (like having C#), I wonder how well that is going to continue with UE5.
@@NitrogenDev well, ue4 having the blueprints
Nav mesh dosent work in procedural foliage any idea how to fix this
If you mean that nav mesh isn't detecting the foliage, make sure collision is enabled. If that's not the issue, take a look inside the procedural foliage classes as there might be a setting inside them for nav mesh.
Ai enemies are not working when we put nav mesh in procedural foliage volume.
After the generation, can you move each tree manually? or all they all stacked as one unit?
Also good video!
They are all stacked, unfortunately.
@@NitrogenDev :cc
nice tutorials
Thank you!
sir thsi was very easy but sir when i touch i tree and rock i was enter on it my mean its visible
Make sure collision is enabled for both of them.
@@NitrogenDev Sir enableed but its not work Plase sir Make a video on It plaseeee🙏🙏🙏
a thing... with these procedural things, the collision does not work. i get through every trees i placed. have you any solution?
Make sure you have enabled the collision settings in the actual static mesh of your foliage. I had the same problem with collision, and I'm pretty sure that was why it wasn't working.
I found a solution. In "FT_Tree" goto "Instance Setting" and change Collison Presets from "No Collision" to "Block All"
@@MrSqurk it's already done. i found the problem just right before Nitrogen and you tell me the answer.
@@81N4R11 ok, I was more leaving the answer for others. The OP rarely actually reads the responses.
Awesome
love your videos man. talking fast, showing what happens in the beginning... i'd love to have a less thicc accent so i could speed it up 2x ;D
I'm glad to hear that! I know the struggle of having a thick accent myself, surely something I wish to get rid of as quick as possible haha.
I have a problem... whenever I press resimulate, it shows "Unable to spawn instances. Ensure a large enough surface exists within the volume." I tried scaling both the landscape and the spawner but nothing happens. Also when I make the landscape huge, it shows a dialog box that says "Placing Foliage" or something along those lines, but afterwards nothing happens. Nice tutorial though. Thanks!
I have had that problem before, and - I must admit - I never got a proper fix for it other than recreating the landscape, which might not be possible in your case. Although I haven't checked the Unreal forum in a while, perhaps someone managed to get a fix for it in the meantime - should be worth checking.
@@NitrogenDev Thanks will check them out!
@@NitrogenDev And I had tried recreating the landscape but it didn't work.
What about procedural cities?
This method isn't suited for that, for a city you would usually have a grid and this creates anything but a grid.
can u plz show ur fps when doing tutorials like this? :) would be nice to see how well it performs.. since this is just a forest i guess it will be a different story when u start adding alot of other stuff as buildings with inventory, characters/Ai, cars ect ect
That's not a bad idea, I should definitely keep that in mind next time. If it matters, I was consistently over 60 if I remember correctly.
And yes, but also no. If you create a forest and then place your other assets such as the ones you mentioned the performance will be worse, but that's virtually impossible because you need to make place for those assets. So, for example, when adding a building , you will most likely have to delete quite a bit of trees here and there. So the different story you're talking about depends heavily on the scene you're making.
@@NitrogenDev Thank you for your reply.. and also for making really nice tutorials!
@@MrZyprez thanks for your support as well!
It doesnt like rough terrain it refuses to populate on it :( awe
I can see myself making a foliage layer for trees, another layer for grass, and another for tiny rocks scattered
Awesome video Nitrogen. I have been running into a challenge taking this concept one step further unfortunately though. Is there any way to turn one of the trees into an actor for the use of destructibility. I found a post (answers.unrealengine.com/questions/927586/actor-foliage-performance.html) kind of discussing the concept but the discussion seems largely incomplete in that I am not able to figure out how to replicate it. What I would like to do, if possible, is to procedurally spawn a forest - then go up and hit a tree, upon doing so, the tree is turned into an actor that I can then chop down and gather wood from.
Is there any way to do this, or something you'd be able to help us get a better understanding of? I have seen a lot of people struggling over this shortcoming of procedural foliage since it cannot be interacted with as part of gathering within a game situation. Any help or information on this would be huge, and I thank you for all the work you put into making these videos :)
As far as I know, you cannot do something like that with the built-in procedural foliage actor.
What you could do pretty easily is take a look at the engine's procedural foliage actor source code and learn how the foliage is spawned. Then you could entirely recreate the same principle, but instead of supplying it with a foliage type you can use classes.
In theory this should be pretty easy (or not too hard, at least), but I'm worried about the actually spawning process. I imagine that the foliage type classes my have access to more data about the landscape which helps with setting the spawn location, so you might want to check that class as well. If that's not the case, then what I said might work pretty nicely.
If you end up doing that, please let me know how it all ended up!
no collision with this method
Hey Nitrogen, good stuff! Do you know if there's a shader / tool to help make giant forests in the background? Say for example I want to create a vista of many layers of ever increasingly distant trees:
i.etsystatic.com/18144822/r/il/203307/2050257224/il_1140xN.2050257224_b9xa.jpg
I assume it has to do with LoD's. But I'm not UE4 Literate enough to do this very well. Would love a tutorial to make a Bob Ross-eque type scene with a sense of scale. Think you can do this? Thanks in advance if you look into it at all.
As much as I know right now, I'm pretty sure the best way is using planes with images. What I mean by that is, you make a 2D projection of a tree, remove the background (should probably use the targa format and the alpha channel) and in UE4 make a material that masks everything but the tree (should probably be double-sided).
Now, for the model, a single plane would work, but usually people use 2 perpendicular planes to cover more viewing angles. That would mean 8 vertices to draw per mesh. With that in mind, you could probably use thousands of those and still have a performant scene.
What I'm not quite sure of is how these will look in the background. I've only once done a scene with a technique like this and it looked decen, but I wasn't scaling them up much, so maybe if I had done that, it would've ended up looking better. Here's how it looks (it's a pretty old scene from when I began doing scene designs): prnt.sc/t092kr (circled trees in the background)
Lastly, I imagine that combined with blur, fog and other post process effects I would end up looking quite good if you do the following: in the foreground use high-poly trees, in the middleground use LODs and in the background use what I talked about above.
Hopefully this helps! I will further look into it and if I find anything of value I will make sure to make a video on it!
@@NitrogenDev That image isn't bad at all! It could definitely work. As a follow up, do you think it's possible to somehow make that 2D/2.5D image from the existing Foliage, or was that what you were already explaining with taking the Alpha?
Just to point but, if you make a dirt path beforehand and make proper settings, the procedural foliage will respect and avoid that.
This may just have become a topic for another tutorial :)
You live, nice
I guess that's nice.
proc folliage volume
1. performance-heavy - a lot of different volumes cost a lot more for performance than standard painting or trough materials
2. don't work with world composition, you cant use landscape layers in that setup
Can you explain or link a source for why procedural foliage is more performance-intensive than the foliage painting tool?
Sloooww Doowwwnn lol too much too fast for a newbie.
Also, how do you give the foliage collision? My character walks through everything.
Open the mesh you want to add collision to and search for a menu called "Collision" in the top side of the window, select the type of collision you want (simple or complex) and apply it. That's an oversimplified overview, so here's the official documentation that talks about both simple and complex collision: docs.unrealengine.com/en-US/Engine/Physics/Collision/HowTo/index.html
I made the mistake of making the PFS scale to 8000 x 8000 x 8000 haha
Unless your PC is a literal rocket, it definitely did not have a fun time with that haha.
i made a game , Project files are available for free now !
Nice! Mind sharing a link with us?
hedi-dev-studio.itch.io/lampy-project-files-and-source-code
В тебе совковий акцент)