Dynamic Grass FX

Bring your low-poly and simplistic scenes to life with Dynamic Grass FX! This powerful Unity asset allows you to easily apply GPU-generated dynamic grass to any mesh.

Setup

Setting up the asset is really intuitive, just follow this steps:

  1. Create an empty GameObject.
  2. Add a MeshFilter and a MeshRenderer to the newly created GameObject.
  3. Configure the MeshFilter to use the mesh you want the grass surface to have.
  4. Create a new material and assign the Bytesized/Grass shader.
  5. Select the material and configure the shader parameters.
  6. Apply the material to the previously created GameObject.
  7. Enjoy your GPU generated grass!

How it works

The main shader is divided in 2 main stages, the tesselation shader and the geometry shader:

  • The tesselation shader is in charge of subdividing the mesh into smaller triangles the closer it is from the camera, allowing the geometry shader to output less grass blades the farther the distance from the camera is, making it more performant; This shader is located GrassTessellation.cginc and included via a directive.

  • The geometry shader is in charge of processing each vertex and outputing a grass blade with the specified parameters in that position. When generating it all the uniforms described below are applied, the wind factor, the width, the height, the stiffness and many others are all calculated foreach vertex on each generated segment.

Bytesized/Grass Shader Reference

Property Type Description Default Value
Top Color Color Top color of the grass blade (0.57, 0.84, 0.32, 1.0)
Bottom Color Color Bottom color of the grass blade (0.0625, 0.375, 0.07, 1.0)
Translucent Gain Range(0.0001, 1) Strength of the glow effect 0.3
Wind Strength Range(0, 1) Strength of the wind effect 0.3
View Radius Float Distance from the camera of when to start reducing the amount of grass to improve performance 48
Max Stages Range(2, 64) Maximium amount of tessellation steps that can be done. (The hardware limit is 64) 7
Base Stages Range(-64, 64) Stages to add by default to the calculation. Useful for tweaking the out-of-radius grass rendering. -0.5
Blade Width Range(0, 0.4) Target width of the grass blade 0.05
Blade Width Random Range(0, 0.4) Max amount of width that can deviate from the target width 0.02
Blade Height Float Target height of the grass blade 0.5
Blade Height Random Float Max amount of height that can deviate from the target height 0.5
Blade Stiffness Amount Range(0, 1) Stiffness of the grass blades 0.38
Blade Curvature Amount Range(1, 4) Amount of curvature to apply to the grass blades 2
Bend Rotation Random Range(0, 1) Strength of the glow effect 0.2


About us

We are a small company focused on building tools for game developers. Send us an email to careers@leastsquares.io if interested in working with us. For any other inquiries, feel free to contact us at hello@leastsquares.io or contact us on the discord





Sign up to our newsletter.

Want to receive news about discounts, new products and updates?