Skip to content

kyl3r92/GrassShader

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is an interactive grass shader. It fakes some wind (strength and speed is adjustable) and also bends around multiple colliders.
When setting a collider to the layer "GrassCutLayer" you can "cut" the grass too.
Cutting grass works by shrinking it to 0.1f height and emitting grass blade particles at the cut position. 
Grass regrows over time. 
Collision and growing is calculated using a script but the grass is drawn using GPU instancing command using an optimized array with all the information like size, bending etc. 
The Wind bending is additionally to the other bending and is done using noise function in the vertex shader.
It's currently a normal HLSL shader and not yet a ShaderGraph. Shadow casting works in the demo but is sometimes offset by some value in my other scenes. 
Maybe due to the scaling of some object. ShaderGraph isn't possible yet because you cannot set custom properties per object in SG yet.

Scene:
https://imgur.com/UT06Rjg

Gif:
https://gfycat.com/spiffymagnificentamazondolphin

About

Public version of my grass shader

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 99.7%
  • Other 0.3%