[SOLVED] foliage.DensityScale not working because of nanite

Hello, I am making a multiplayer game in a very small world with a small landscape and I have some foliage on the edge. However, I am trying to make this game work on lower end hardware as well and I feel that the amount of foliage I have is heavily impacting the FPS. So I want to add setting that allows you to control how much foliage there is on a level but it seems that I can’t swap out Procedural Foliage Volumes or Instanced Foliage Actors. Is there a way to increase or decrease the density of the foliage in game or pre-simulate them and swap them out with their respective density settings?

The first port of call would probably be to optimize the foliage, so it didn’t matter.

But, in any event, you can use the console command

foliage.DensityScale

There are many others, also for foliage.

3 Likes

Thank you for your reply. Unfortunately it does not seem to be working for me. I am using 5.1.1 and after a little bit of searching online, it seems I found one other person who is using 5.1 and is having the same issue where this console command is not working.

I have tried typing the command manually, in blueprints with my settings widget, I have even tried using a DefaultScalability.ini file to automatically change it with the engine’s foliage setting. I have also tried playing the game in PIE, standalone, and simulate. I have also tried this with the manual foliage painting tool since right now I am using procedural foliage but neither works. Also yes I enabled density scaling on each static mesh foliage asset.

If the foliage is being placed by the grass-layers in the landscape material, could be not control the mask therein to reduce the density?

@OP, can you use billboards/imposters for the foliage at the edge? I believe that is likely what ClockworkOcean is suggesting?

I’ve always found Ryan to be a fascinating read. Would these work? Post Page

ref - https://www.reddit.com/r/unrealengine/comments/brv3ub/how_to_create_fortnites_octahedral_impostors_in/

1 Like

It’s a very small scene so I think that would not look very good. Plus, I’d still like to know why foliage.DensityScale isn’t working.

It works just fine :slight_smile:

You have to opt in to density scaling via the tool

Density scaling will work.

If that is an actual landscape, and you don’t need collision or whatnot, can you place them via a grass layer?

Use a noise-texture you can add/subtract/multiply the grass-layer with and you can control how much 0 → 1 you will get across the landscape, influencing how many actual meshes get placed.

My understanding is that the grass-types are a ‘lighter’ mesh vs the foliage painter (someone confirm?) in that they don’t come with collision and some other things. If you don’t need to interact with anything, if the foliage is simply window-dressing, would that work?

And to be honest, if that is ALL your game is going to be, that one square, you wouldn’t have much to worry about unless your models are really high-poly/expensive-material (IMHO).

Is it a fighting-game with that stuff as backdrop?

I am sorry, I already have that enabled. Also, I am using procedural foliage for this project.

The way I have my level set up is I have the procedural foliage actor covering most of the landscape. Then I painted the area immediately around the house with a No Weight-Blend layer and set it as an exclusion layer so that foliage would not be generated there. I also just tried making a new project with procedural foliage enabled, I made a brand new procedural foliage spawner and a brand new foliage asset with density scaling turned on and it still does not allow me to change the density with the command. I am typing it like this “foliage.DensityScale 0.1”.

Also to answer your last question, I switched my foliage assets from the Megascans European Hornbeam pack to some free stylized assets that I found online so these should have far less detail. And yeah, the foliage is just a nice backdrop so the game looks nice

Take a mega-high-poly mesh and let the Unreal calculate several LODs, sometimes you get a decent reduction. Materials can do a LOT with a low-poly mesh, especially if you are never going to see it close up. Some of the meshes you get have many material-slots you likely won’t really need.

I also like TreeIt: TreeIt | Tree Generator

Since they are just deco, turn off anything you don’t need like collision or whatnot, you just want them for the look and shadows. If spawned via the grass-layer they should also already be instanced as well. Not sure you can make gains there…

Make them move via materials with a wind-function in WPO; you can do a lot here to make them look really nice even with low-poly models. Try spending the expense on a triplanar texure for the bark.

Ok I figured out why foliage.DensityScale was not working. It is because the meshes I was using had nanite enabled. When I disabled nanite for my foliage static meshes the console command worked. I guess this is a bug that Epic needs to fix

2 Likes