|Topic was automatically imported from the old Question2Answer platform.
In the 3d game that I am working on I followed a tutorial about how to create grass, but the worlds that I am making are fairly big, and I can’t imagine that rendering every single grass blade across a big landmass in a game is good for performance. There is also a limit of how many grass blades that can be rendered with one multimesh so it looks kind of ugly with the grass so spread out. In other games that I have played I have seen grass only being rendered when it is in close proximity to the player. What would be the best way to go about doing this?
Would you have multimeshes around the world and only show them based off of where the player is, or is there a better system to do this?
Would you somehow get a multimesh to populate the surface but only in proximity to the player?
I know this is a big topic but I couldn’t find any tutorial or anything about this anywhere. Thank you in advance!
The way I do it is by maintaining a grid of grass chunks around the camera, within a limited area. When a chunk gets too far, I remove it. When the area has empty spots for a chunk, I add them. This can be in a circle or a square. Chunks allow to do a bit of frustrum culling and manage “infinite” presence of grass.
Then each chunk contains a multimesh, and here there are a few options: either generate each instance position using raycasts and procedural formulas with a script, or precalculate one with full density, share it on all multimeshes and rather decimate instances from a vertex shader according to a density map or splatmap (commonly seen with heightmap terrain). If the world is too big to fit in a single heightmap, they could be easily chunked themselves on a larger scale.
Finally, to smooth out the “popping” effect when chunks load/unload, I fade grass using a fragment shader based on distance. The distance is choosen in such a way chunks that get loaded or unload should be almost invisible as all grass inside has faded away.
Properly choosing colors for ground and grass also helps to make it blend in.
Here is how my version looks like with some debug drawing: https://www.youtube.com/watch?v=nrkvvzZ51Js
Dang this is exactly what I was thinking Brilliant answer
Wakatta | 2022-04-06 13:31
Thank you so much! I’ll definitely be trying this!
Nathcra | 2022-04-06 14:47