Its been well over 3 weeks, more like 4 since I started looking at implementing a grass system into my Unity terrain generator and multiplayer RPG game. I will say, its been hell. I think I cried more than a couple of times.
When I first started looking at grass systems I took a few notes on the different techniques. Basically it came down to a few…
Grass Shader System
This one is probably one of the best. It allows you to bypass the CPU and use the GPU to create some really nice looking grass without sacrificing performance to do it. The GPU is tasked with creating and drawing the grass system all on its own.
There are more than a few ways of doing it, between having a script create the grass with a mesh and texture along with position, rotation and scale. Then it would write these values to the shader and have the shader process it and draw it to the screen.
This system was by far the best looking and best performing technique. Especially if you use DrawInstancedIndirect. This function allows you to draw millions of meshes without touching the CPU and maintains a very good frame rate.
Grass Billboard System
This system uses a quad or plane with a texture and keeps the quad or plane facing the camera at all times. This was the most common way of drawing things like grass to the screen. Shader systems have now pretty much become the standard. One downside of using the billboard system in Unity is that there are issues when it comes to instancing. On top of that the grass just didn’t look very good.
Grass Particle System
This was actually the one system I didn’t get into. It just didn’t feel right, lol.
Grass Mesh System
With this kind of system, you use a mesh, slap a grass texture on it than place it as you see fit. You can create an empty game object, add multiple meshes, position them, rotate them and scale them to look the way you want, then drop this game object into your assets to make a prefab. You can use script to procedurally place these grass prefabs throughout your scene and it actaully looks pretty good. The down side for me was getting full ground coverage. In order to make it look right, it took an ass ton of grass prefabs and my frame rate started dropping.
In the end, I combined the mesh system with the shader system and got a really good system that I am very happy with.
Third Party Grass Systems
I spent way too much money on different grass systems from the Asset store and tried a bunch of free ones too. Here is a break down of what I tried…
YAPP, Yet another prefab painter, Free
Great tool for painting prefabs on any terrain
but grass prefabs really hammer the FPS
Grass Flow DX11 Grass Shader Asset, Asset Store
Looks very good, FPS was hitting almost 300 in areas
The bad thing is the shaders are very confusing, need to restrict the grass to certain heights of the terrain
Also need to see how to only draw grass where the player camera is, switching to scene view draws the grass on the entire terrain
After restricing the heights, the grass cut off hard at each triangle where the height changed
Didn’t want to spend anymore time tweaking it
Heres a video I did of the Grass Flow System!
Brute Force Grass Grass Shader, Asset Store
Looked decent, after playing with it decided it actually looked way too much like fur
Took some tweaking to get right, but it was still not what I wanted
Grass was actually very blurry in certain areas when wind moved, or pixelated if zoomed in
FPS was very good on a scaled plane of 10, hitting 390
The trial didn’t react right, even after tweaking it for over an hour
FPS was 150 on my terrain.
Heres a video I did of the Brute Force Grass System!
Dynamic Grass FX, Asset Store
Look good but you really had to turn up base stages to get good coverage, had to turn down max stages to stop the horrible rapid wind effect on the view edges
FPS was 55 on my terrain, this really sucked, no room for any other stuff like water, trees, stones, structures, etc
Used blades, not a very realistic look, but good for Fantasy, cartoony style.
Heres a video I did of the Dynamic Grass FX!
RoyStan Grass Shader, Free
Looked really good for blade style grass, have to really crank up the Tessellation to get good coverage which ends up tanking the FPS
Halisavakis Grass Shader, Free
Didnt look very good, the blades were single tris with no bends and I couldn’t get very good coverage, max 15 per mesh triangle
FPS was over 400 though, lol
Interactive Grass, Asset Store
Looked identical to RoyStan, Horrid FPS and really had to crank up the tesselation to get good coverage
FPS was 8 at 34 Tessellation
Turning Tess down, showed squares like tiling in the grass
Minion Art Grass
Look good for a stylized blade, somewhat cartoony
Couldn’t get good coverage, couldnt see where to increase blade count, actually I did alter the shader, changed blades to 100 but its restricted to max of 51 vertex count else it throws errors
Not sure how they were getting full coverage as shown in the video
Hitting 290 FPS, but very low coverage
Figured out in order to get high density grass, you need a high detail mesh, the more tris on your mesh, the more grass you can put in
Best Way Of Making Grass Guide, using Unity Tree and Leaf, From a tutorial
Doesnt look very good and horrible FPS 80, with 6000 Cross Grass Meshes
Very outdated
Vegetation Studio Pro, Asset Store
Was a bit tricky to setup, docs confused me at first
Tons of settings, hard to find your way around
Ultimately, gave a very nice looking grass system with a smoking frame rate
Loved the look and actually how easy it was to implement
Don’t know how I can use it in my own standalone terrain generator, I would have to use script to tweak settings
I was going to use this system, but decided to go with my own for more and better control over it
Moving On!
The whole idea here is to be able to create grass on my terrain as painless as possible. I am almost done creating my system that will add objects to my terrain using buttons and input boxes for settings.
I will be able to click a button to add a new object to my terrain, I will choose grass and it will add a grass block to my scroll view window. In this block I will be able to choose what mesh to use, what texture and color along with settings for density, scales, rotations and terrain heights to grow grass on.
Now that I am done with my grass system, I will be looking forward to moving onto other objects like rocks, boulders, bushes, plants and trees!
Thanks for reading and if you have any questions, please feel free to leave a comment below!