This was a pretty small project that took about two days from start to finish. The main goal was to create a modern grass rendering system that made good use of instanced geometry to create grass that looks better than stock terrain grass.
As can be seen throughout the video, it’s not just a simple object instancer but it also includes a few other things made to make the effect more convincing and more performant.
Simply rendering the entire field at full quality wouldn’t be particularly wise or performant. Instead, when the grass gets far away from the camera I start skipping more and more blades of grass and scale up the remaining ones to mask the holes that come from a reduction in density.
Culling is done as a basic first-person frustum culling, but since we could render about 1 million blades of grass in this patch, that operation is moved off the main thread to avoid stuttering and performance issues.
Simply put, the swaying is done as a shader animation and the random input is generated with data fed during the culling process. Very little goes on in the Fragment shader, we just take the random data passed in Vert and use it to figure out how we should sway and modify our colour. No actual lighting pass is done in this shader, but it wouldn’t be hard to add a diffuse lighting pass.
Moreover, the grass itself can actually move around and get pushed by points of interest. Here it is used within Green Thing From Planet Jupiter, where we can see both players are able to push the grass around and interact with it in a semi-realistic way.
I built this project for Unity 2023.2 and the Built-in Render pipeline/Universal Render Pipeline.