Grass rendering experiment in Unity. Uses an HLSL compute shader and graphics shader to draw procedurally
generated blades on the GPU.
Documentation: https://drive.google.com/file/d/1yU3R3r8M-x1r2aaZG5QTPN35xTdAMPPg/view?usp=sharing
Essentially an implementation of the approach used in Ghost of Tsushima, detailed in this incredible talk:
https://www.youtube.com/watch?v=Ibe1JBF5i5Y
The grass is quite performant (although there are crucial optimisations that should be added, like LODing).
The look and movement of the grass is highly customisable and can be changed using various parameters.
Features:
- Shape of blades determined by cubic Bezier curves
- Wind animation driven by scrolling 2D perlin noise inputted to a sin-based function that modulates
various parameters of the grass
- Clumping: Grass can be grouped into Voronoi clumps that share the same parameters, for a less
uniform look
- Lighting: Phong shading, with gloss map, and fake ambient occlusion based on length of blade
- Grass color: combination of color gradient along length, clump color, and albedo texture
- Heightmap terrain: blades placed on the surface of a heightmap terrain
- Indirect, instanced rendering: allowing for fast rendering of millions of blades
- Frustum culling, Blades outside of the viewing frustum are not rendered
- Distance culling, Fewer blades are rendered at distance, with a smooth transition between near and far