Any suggestions on optimizing this grass shader

Here’s the shader I’m currently using to render the grass on my terrain. It’s quite basic and just renders the base color and normal and displaces it using a sine wave to make it look like it’s swaying. I would like to get some more performance out of it. My fps is around 250 with the grass off and around 190 with the grass on.

The grass are terrain details that render my billboard mesh using GPU instancing, and this shader. Grass on/off by toggling the Draw bool in the Terrain components Tree+Detail section.

CPU [ms] GPU [ms]
Grass being rendered 7.0 2.6
Grass not being rendered 5.3 2.5


Since shaders are executed on the GPU - look at the difference there. It’s ±0.1 ms. So if you optimize this shader like a legendary pro shader wizard, this is absolute limit of what you can gain (not much). Framerate counter won’t change because fps is dictated by the slower device.


CPU slows down in this scenario by ±1.7 ms and this causes the said frame drop, not the shader. Unfortunately Terrain component is not open-source so we can’t optimize it but replace.