For anyone else coming across this issue, for me, this seems to work fine in 5.1 so long as I remember to check “preserve area” for the foliage nanite meshes, otherwise, they don’t load in. Also, I use the path tracer and need to use the following commands for landscape grass meshes to work using nanite with path tracer:
r.RayTracing.Nanite.Mode=1
r.RayTracing.Geometry.LandscapeGrass=1
Also, I find that the max density count of 1000 for foliage in the landscape grass object is too low. Use grass.densityScaling (put a multiplier here, 1 is default, I use at least 2 for denser grass)
As you increase density/use larger terrains, you might run into the issue of not all the grass streaming in properly, and unreal will recommend you increase the max nanite nodes. Set r.Nanite.MaxNodes to something like 2000000-3000000 if you really want to push it, though I definitely wouldn’t recommend that for anything real-time, it tanks performance even with nanite, though it’s certainly much better than without nanite.
Note that changing the r.Nanite.MaxNodes doesn’t work in editor, as the log will tell you that it’s read only. I change all of my settings in the ConsoleVariables.ini folder, located in (Drive Letter):\Epic Games\UE_5.1\Engine\Config directly under the [Startup] header. Adding all of these console commands here will ensure that they are always enabled each time you launch the editor so you don’t have to retype them every time, though they’ll be overwritten if you ever redownload/change Unreal from the Epic Launcher. Changing r.Nanite.MaxNodes will actually work if typed here, just remember to put an “=” instead of a space between the main body of text and the number for ini files.
I don’t know if the amount of instances are what tanks the performance, or if it’s just the density and draw distance of the grass. If it’s the instances, you could try assembling your foliage into as large clumps as you’re willing to tolerate. Larger clumps mean less precision and control around the borders of your grassy areas, but traditionally more performance. Though with nanite, I’m not sure if that’s true anymore, someone would have to test that. If it does help, making a mask with a gradient from the center, where the large clumps are distributed along the central areas while the smaller clumps are distributed along the edges would give you the best of both worlds, assuming that this form of optimization even works at all.
If using path tracing, I set r.RayTracing.Geometry.InstancedStaticMeshes.Culling 0. Seemed like a good setting to change from reading the FAQ of Path Tracer in Unreal Engine | Unreal Engine 5.1 Documentation.
In short, all the commands that I use for path-traced nanite landscape grass:
r.RayTracing.Nanite.Mode=1
r.RayTracing.Geometry.LandscapeGrass=1
grass.densityScaling=2
r.Nanite.MaxNodes=3621440
r.RayTracing.Geometry.InstancedStaticMeshes.Culling=0
(Edit, see below): r.RayTracing.Geometry.InstancedStaticMeshes.EvaluateWPO=1
Hope this helps!
Edit: I’m trying to get wpo to work using the landscape grass system, and right now I’m getting two issues:
-
If I make any changes to the wpo, I get buggy/invisible grass along the landscape shader, though the source object works as intended. This is only for nanite enabled meshes, non-nanite works as intended.
-
Any modifications I make to wpo whatsoever are completely ignored by the path tracer. I’ve just fixed this issue by setting r.RayTracing.Geometry.InstancedStaticMeshes.EvaluateWPO=1
If anyone has any solution to my first issue, please let me know! As of now, I’m considering this to be a bug that needs to be fixed by Epic.