As per my findings in the forum thread: Changing the grass mesh and using a lower density didn’t do anything (My density is 250, grass mesh has ~40 triangles). This is definitely some sort of engine bug because while not playing inside the editor the grass loads just fine. I could literally be at the start point with the camera, with the grass all there, and when I hit play, the grass would clear and very slowly load back in. As soon as I stop play it’ll load up instantly.
Sorry for the delayed response, been at home with a fever today unfortunately. Interesting development though! I did manage to reproduce the issue very simply on multiple PCs, even my i74-4770k with a GTX780 takes ~10 seconds to load it all. I can also confirm that it DOES happen on 4.8.3. These are the reproduction steps:
The only notable thing about the material are the grass types. It doesn’t have to be 4, but I’m trying to match my real project environment. Now, most of the settings in the landscape grass assets remains at their default settings. The only changes are these:
The mesh is set to anything. It doesn’t matter what.
The density is dropped down to ~20 on each.
The fourth one (or any one really) has at least 5 variations, each of which uses a different mesh and a density of ~20 each.
With these in place play at various positions on the landscape. Note that it all loads instantly.
And now for the big bang: Reduce the landscape scale to 25x25x100. Play somewhere at the midpoint. Observe how the grass tiles slowly creep towards you.
Incidentally, dropping all but the first variation of the 4th grass asset will make it load up instantly (or at least much faster) again.
I hope this is enough to replicate it. Thank you for your time!
Your process is different than that of the suggested workflow. The Landscape material using the procedurally placed foliage, needs to Sample one of the layers of my landscape material in order to apply it correctly.
In the screenshot below, you can see I have created a simple Layer Blend for my landscapes material, and then added the Grass type node with the four unique inputs.
Each sample then can contain its own ‘GrassType’ (collection of foliage meshes) to be applied to a specific landscape layer. It seems you are compiling all of your meshes on the same layer, and could be experiencing all of the cull distances and Level Of detail changes of each mesh. You will want to edit these values to get your meshes to render correctly at the appropriate distance to the camera. Also scaling your Landscape non uniformly is going to cause all sorts of problems and is not recommended.
My production material does sample layers, the above setup is just for testing purposes, it makes no difference. The big culprint is the landscape scale, as I have noted in my reproduction step. You can take your landscape, assuming it’s set to the same settings as I noted in the repro steps, and set its scale to 25x25x100 and you will see the problem.
Sorry but with all due respect this is not the solution. I’ve tried this a dozen times on half a dozen PCs - it’s a bug, the draw calls go up tenfold with the SAME material on the SAME terrain with just the terrain scale being changed. If what you suggest is the culprit I’d see the fps drop right off the bat, without changing the terrain scale.
I feel like you haven’t honestly even read the reproduction steps.
I did read your repro steps, and tried to respond by letting you know that your workflow is incorrect, therefore you are going to experience some issues. Scaling your landscape, especially one the size of 32x32 and with all of your foliage placed on the same material layer, with those densities is definitely going to cause an issue.
Scaling your landscape is not suggested, as it will cause all types of errors. It is best to create the correct scale at the beginning and stick with that. Here is a post that will shed some more light on this.
Changing Landscape Scale
As for the load times of your foliage, this is also mentioned in our documetation and is expected. Especially with the test set up you have provided as all of your meshes are being spawned on the same material layer.
As I said, my “real” terrain doesn’t put all the meshes everywhere, it samples layers. The behavior is absolutely identical. The loading I am seeing is definitely not the expected behavior as it loads up instantly unless the landscape is scaled down. (It also happens on a packaged build, not in the editor during painting).
However, I see that landscape scaling causes glitches so I’ll see to it to rescale the height map to get the right scale right away.
This is for anyone who is still having trouble with this issue :
Short Answer : You need to call ‘UpdateGrass’ on the landscape proxy actor with bForceSync = true to make all the grass get created at once. This is not available from blueprints, you’re going to need to import that Landscape module and do it in C++.
Long Answer :
The grass is created on a per-landscape actor basis and each frame the grass actor queues up a certain number of subcomponents to have their meshes generated at runtime. The number of tasks it can queue each frame is 4, but regardless is only pops one async tasks off its finished queue each frame. Basically the larger your landscape in terms of components, the more frames it’ll take to render regardless of how dense the foliage is on the landscape.
To understand this go check out ‘LandscapeGrass.cpp’ in the ‘UpdateGrass’ method. You’ll find that if bForceSync is set to true that it’ll make sure to queue up all tasks and wait for them to drain. Otherwise in the queuing logic it checks the ‘AsyncFoliageTasks’ array against the async task counter to queue logic, and at the very bottom of the function it pulls tasks off (and has nice little comment about how ‘one per frame is fine’).
I’m on version 4.16 and before I finish playing on the first frame I make sure that I call this method and all my grass instantly spawns in.
This solution worked! Thank you so much.
Since I’m using UE5 I had to add the array @Kaspi mentioned.
When I have this actor enabled it causes all the foliage on the map to be visible and ignores the cull distances. This is obviously very bad for FPS. Is anyone else also experiencing this? Is there something that I would need to add to the code to enable the distant foliage to be culled again?
Distance culling works fine when I don’t run this code, but then the foliage takes forever to load again.