I am currently trying to implement grass with a wind shader on iOS. All of the grass examples I have found so far use opacity masked transparent materials and with a small number of grass meshes (hundreds) the fps tanks on iOS even though the total number of triangles is relatively low.
For example with about 150k tris of opacity masked grass on screen I get around 20 fps on an iPhone 6s.
Disabling the opacity mask gives us about 50 fps for exactly the same scene.
Because of this huge performance hit for transparent materials on the iPhone I wanted to do the grass with opaque materials, I tried modelling each blade of grass as a mesh but the results don’t look nearly as good as what I had before with the transparent materials.
Does anybody know of any games that have done really good looking grass with wind where each blade is individually modeled with opaque materials? Or maybe a market place asset I could buy and check out for inspiration or just to use as is?
Failing that what should I be doing to get the best opaque grass possible?
Use as few triangles as possible for the mesh
Use the opacity masking model and not translucency(you can fake in translucency with dithering though if you need it)
On the mesh, minimize space that is not opaque(get the mesh as close to the border of the texture as possible)
Too many tris will tank your fps
Too much non-opaque space, on the meshes, will tank your fps
Thanks for the tips! I will try to optimize the meshes to reduce the amount of transparent geometry to a minimum. And what do you mean by fake in translucency with dithering?
We use opaque geometry for grass in our upcoming game Oceanhorn 2. You can see the grass here. Oceanhorn 2 - GDC Demo Trailer - YouTube
Each static mesh has around dozen blades. Each blade has very few triangles. Around 2-4. Total of 49triangles and 85 vertices. This is quite heavily lodded. And draw distance is around 33meters.
This give us very good performance even on mobile and we are happy with the look.
For other foliage(trees) where we need to use Masked blend mode we cut the fully Opaque parts to different material section. This way only small percentage of mesh actully need to use Masked blend mode and bulk of the model use Opaque blend mode.
Do you have a wind shader applied to that grass? Or is it just static? I can’t fully tell from the video, it looks like you might be moving it a bit when the character interacts with it though?
Grass has custom wind effect. Waving from pivot of the blade, bending toward top. Also player feets will bend grass blades outwards. It’s also shrink down when each instance is near the hide distance to avoid popping. This is done also when camera is near to colliding to grass patch to avoid clipping.
“Use as few triangles as possible” isn’t entirely correct.
More specifically you want to set up good lods of grass (actually for all meshes in general). Close in you can use a lot of triangles, as long as they lod quickly out. The basic reasoning behind this is triangles only get really expensive when they start getting below the size of pixels. Up close your mesh is bigger, and takes up more screenspace, and so more triangles can be used without a lot of hit. The farther away it gets, the less pixels it takes up, the less triangles you want to use on it or it can quickly get very expensive.
Yes, LODing is important, but you still want to use as few tris as possible and as few LODs as possible… The general rule of thumb for ALL mesh creation is to use as few tris as possible, while still holding the correct shape/silhouette/etc. LOD0 blades of grass don’t need 80 tris in them and yes, sub pixel tris are a nightmare on performance.
Typically, you aren’t going to be looking at grass from an ant’s perspective where the blade would take up 45% of the screen up close. For your average game, a blade of grass might take 1% of your screen at an absolute max. That means in a 1080p game or ~2.1 megapixels, roughly 21k pixels or 144^2 will be covered by the blade of grass. Realistically, it won’t even take up a 16th of this area…
Here’s what 1% looks like if your screen resolution is 1080p:
Unless you have extremely tall and thick grass, there’s pretty much no reason to put more polygons in them.
Try using a world aligned panning cloud texture as the alpha input to a LERP and use that to have a moving color variation between your regular grass color and a slightly lighter color. It will give a low cost impression of wind.
ah man I would love to watch this but unfortunately I do not have access and 550 dollars for a single license is too steep for my indie level budget… I wonder if there is a way I can get access to just this video and nothing else?
Sometimes they feature some presentations and you can see them for free at limited time. You can also search from youtube or their website if they have made same presentation on somewhere else.
Cool that a “AAA” mobile dev gives back some insight. Thank you.
I’ll add this, try very hard on creating grass. It seems like a simple mesh to make, but sometimes you make several prototypes before you find an economical nice looking grass.