What is a good approach to update and replace large numbers of instances in game?

What is a good approach to update and replace large numbers of instances in game?

As for example in a farm simulator, how could you animate the scale as the plants grows, then replace the mesh when the plants are harvested, or remove a plant when it dies? Say it should be on a field of 200 x 200 rows, so 40k instances.

I’m not planing to do a farm simulator, but I’m looking for suggestion for how to handle updates on large amounts of instances. The foliage system seems to be designed for static plants and trees. The same goes for packed level instances, which seems designed for identical copies. I’ve also looked into Instanced Static Meshes, but it seems that updating their transforms or custom data quickly leads to performance hits.

So looking for technical ideas on how to approach this problem?

You could do normal plants, hierarchical instanced static meshes or instanced static meshes and do the animation on a material level (using the time and sine node / Simple grass wind based on vertex color)

You can also feed in per instance parameters to a plant with “PerInstanceCustomData”, Color and other parameters you would use to change it on a shader level.

You could also look into the new procedural tools (“PCG” Procedural Content Generation plugin). Though I’m not sure how they are performance wise, with runtime updates.

Maybe, rather than update all 40k at once, stagger it out over multiple frames - I built a stagger system for something else (Distributed Transactions) and it works really well, there’s a video at the bottom of this page:

Async batches of sub 500 units will work OK if they are off the game thread.

You need to specificlally look at creating your own thread, your own async function, and how to have it interact with foliage.

However if you needed to build a real system for a game, you probably wouldnt bother and just use the shader material.
As the first post mentions.

The part thats missing is the fact that you can manipulate the shader and mesh to do crazy things, like a proper growth cycle, mesh replacements, mesh additions, and a bunch more just by playing with the material and different UV channels.

The plants collision will not be updated this way.

So for instance, planting trees and going from seed to sapling to tree will require an actual mesh update to deal with the collision as well…