Grass Shader

25 October 2023

Premise
At the Beginning

I wanted to recreate the changing seasons and I thought of making a floor of fallen leaves that start out green then transition to orange/reds to brown and then covered in snow before it melts and the leaves are green again.

Problems with That

I started piI underestimated the amount of work that it would take just to start out. First I couldn't really figure out how to make a proper leaf shape with the sharp tapering on the top and bottom as well as the details within the leaf. Then I had issues coming up with ways to simulate/create a pile of leaves nicely, I was struggling to layer them on top of each other.ece by piece by breaking the effect into parts and combining them together at the end.

Cutting my Losses

After struggling for a few hours, I decided to cut my loses and just go for a simpler concept. Basically having blades of grass that grow up from the ground that turn from green to brown and 'wither away' at the end.

Grass Blade Shape

  • I start off by creating the shape of the grass. I used the Twirl node to have the Rectangle shape warp a little to the side, creating a droopy blade of grass then adding them together to create 3 blades of droopy grass.

Grass Blade Color

  • I colored the grass by getting the G value of the UV to mask out the top half of the grass from the bottom half so it creates a gradient of ground color to a bright green leaf color. I also made the second version (Brown) using the same nodes. The nodes are then lerp together with a Fade transition node that swaps both colors in and out following a time - sine wave.

Grow / Wither Animation

  • The growing/wither animation I did was pretty much the same concept, but I used the UV's Green channel and two Power nodes to make the gradient move up and down on Cosine Time. I added the Posterize Step node just to make it look more blocky / stylistic.

Wind Animation

  • I looked up a tutorial on how it was done and just emulated it.
GRASS SWAY in Unity - SHADER GRAPH

Shadergraph Overview

  • An overall look at the entire shadergraph

Final Result + Thoughts

  • It ended up looking more like seaweed instead of normal grass, but I think I still managed to achieve what I set out to do :D