Actor Foliage Optimization

Hey guys, I was wondering if anybody has any ideas on how i can optimize my trees. Currently one tree is only 2.5k triangles with two materials. Each tree is a foliage ACTOR so i have reason to believe it is not as optimized as if they were all just instanced static meshes. I would like most of them to be instanced except for the ones that get interacted with. Currently the way my tree system works is that you click a tree and it takes a little bit of health away from it and once its healt


h equals zero it turns into a pile of logs ready to collect. Feel free to ask questions if i wasnt clear on something. Thanks in advance! :slight_smile:

Well, what isnt clear is if you are using the foliage system to populate and manage them or not.

As far as oprimizing goes, listen, IF your rts view is locked in like shown, then you should really forget about the tris and just use Octhedral Impostors.
It makes lighting possibly a bit tricky, you may need to fake things at the material level etc, but you wont beat the performance you gain with essentially having maybe 10 tris per tree and a single drawcall (instead of 2) overall.

The other alternative to the tris count is billboards, but with rts/top down they don’t really look all that great.

With that. If i understand correctly you are placing Actors with the foliage.
For performance that’s a death sentence.

You need a system to replace instances similar to what I built DynoFoliage: UE4 Interactive Foliage

The challange you’ll have is having to save/reload the state of the edits you make to the foliage collection. Though you can build the engine from source and lift the engine save/load methods that are editor only to achieve something good with the guiadance of what you know for a fact already works.

Going this route, instead of having say 5000 actors blueprints with their own functions, you’ll have 4999 foliage instances, and 1 actor that’s being interacted with (or several, depending on how many you click?)

The other option is… do you even need to replace the instance?
Unless the tree you interact with needs to animate or act in specific ways, you really don’t.

You can just keep the click count of the instance you interacted with and remove the instance once its been clicked enough (Note that removing instances still means you need to save the new foliage state).

Try these things.

Also, since its an RTS, you need to look into tick managers or group managers.
Basic concept is, one actor keeps track of many and issues functions based on a single on tick.

Because if you click 100 trees and they convert to instances, when all 100 have tick running your CPU will overload.

1 Like

you might look on youtube for a tutorial from prismaticadev about per instance custom data. I was able to use this to store data per foliage instance which means that you don’t have to turn them into actors at all. You can have 50k triangle trees in the hundreds of thousands like this and on my 1060 gpu it was still around 50fps.

there are other solutions that copy the instance transform and then spawn an actor, but I think the per instance custom data is probably overall simpler to implement.

1 Like

ref: https://www.youtube.com/watch?v=6sjc4dqoCF0

I’ve worked this kind of thing into my systems, it’s very handy! Makes per-instance data available to materials beyond Random/Fade, so it’s very extensible.

Thankyou all for your help :slight_smile: