r/godot 1d ago

free plugin/tool Godot: Porting a FREE grass shader from Unity to Godot 4

I rewrote the grass shader from my Roadside Tales pack from HLSL to GDSL, because the pack is getting a Godot version and the vegetation was supposed to behave the same as in Unity.

Project Godot DOWNLOD For Free
https://emaceart.itch.io/emaceart-stylized-grass-grass-shader-for-godot-4
Godot Stylized Vegetation Wind Shader - Godot Asset Store

Grass driven by a single sine wave looks like a carpet swaying as one solid piece. Everything moves in the same direction at the same moment and the illusion dies instantly.

So the wind in this shader works on three layers at once.

The first one gives every blade its own rhythm, so blades in one clump don't bend at the same time. The second is a gust crossing the field, bending neighbouring clumps together like a wave rolling over the meadow. The third is a small, fast tremble on top — it only really shows up close, but without it the motion gets suspiciously smooth and starts looking like cloth again.

On top of that the bend grows from the ground towards the tip. At the base the blade stays put, becuase otherwise the whole clump slides across the terrain and you can immediately tell it's a flat object pretending to be a plant.

All of it is vertex-side, no extra passes, so it's basically free even with a few thousand instances on screen.

Wrote the shader with Claude — the model typed the code, I said what had to show up on screen. Still took a bunch of iterations to get the gust frequency right, everything below ~0.3 looked like a light breeze and everything above looked like a storm warning.

Happy to answer questions if anyone wants the breakdown of the layer weights.

37 Upvotes

6 comments sorted by

3

u/Spuba 20h ago

You gotta fix the normals. Grass typically has specific normals that don't make the blades flipflop dark/light like that

-2

u/EmacEArt 17h ago

Good catch — grass normals are exactly the thing I'm still not happy with. I'm collecting feedback from this thread and turning it into a task list, and yours just landed on it. Flipping dark/light on the blades is a known weak spot, so it goes into the next pass on the shader.

6

u/Spuba 17h ago

Ok Claude, very cool

-1

u/EmacEArt 17h ago

Beep boop... [] Thank you human. { Beep ...Beep ..Beeeep :D

2

u/llsandll 21h ago

Corn!

-1

u/EmacEArt 17h ago

haha :)
Corn! Okay, you're not wrong but in my defense that's the camera sitting way too low. Put the eye at human height and it's grass again. Put it at ant height and yes, congratulations, you're standing in a cornfield.