Interesting problem: how to create a large grass environment that can be cut and re-grow?

Hi. As it says it the title, I’m looking for a clever way to implement a large environment completely covered in objects that are somewhat dynamic. Think of it like grass that can be cut and then regrow over time, or a giant canvas that can be drawn on with fading ink. I want it to be fine enough that it doesn’t look like a tilemap. I’m worried about performance: how can I do this without creating millions of objects that all need to be updated occasionally? The best I can come up with is:

  • Save some performance by only updating an area’s growth state when the main camera looks at it, or when the CPU isn’t very busy.
  • Create a hierarchy of zones which can notify a controlling script to not spend time updating them when all the sub-zones are in a static state. (In other words: ignore the grass areas that are fully grown.)
  • Do a sort tilemap of larger grass-splotches, but hide it by making several shapes of grass and randomly rotating them?

I think these are some decent ideas, but they probably won’t be enough when there’s a worst-case scenario of most of the map in the process of regrowing. And even if the growing-updating issue could be solved, I’m still worried about the space required for a large map. Even if I used a byte number to record the state of a unit of grass, and stored the whole thing as a single array, which I’m not sure is even possible, a ten-thousand grass-unit-square map would still be 100Mb. Not ideal. Anybody got any clever solutions?

If you’re talking about grass and foliage then you are likely talking about a huge area with a huge number of objects. Keeping track of all this and individualizing settings per object is likely going to quickly get CPU restrictive. You might consider a better method to calculate visibility in the vertex shader instead. Particularly in the grass you could subset the vertices lower under the terrain when the grass is “cut”, and then raise them back up to position over time. Different methods can be considered how to best demarcate cut areas, either with an array of scene objects or Vector3 positions, or perhaps a top-down texturemap.

1 Like

@chingwa Interesting idea, but could that vertex manipulation be made to work in 2d? I’m using 2d.

Ah I didn’t realize you were in 2d. That’s probably less of an issue for the CPU then. I don’t think my idea about vertex manipulation is as applicable.