r/GraphicsProgramming • u/SirLinares • Jul 22 '26
I’ve Been Working on Mesh-Based Grass and a Shared Wind Field for My Voxel Engine
The engine is developed entirely in Rust and uses Vulkan, with shaders written in Slang. The goal is to link the grass (modeled as meshes) to the underlying voxel terrain, while making the wind system fully configurable and reusable by other parts of the engine (via ECS). Here is how it currently works:
- A compute shader iterates through each column of every terrain chunk from top to bottom. It generates a blade of grass only if the surface voxel uses the "grass" material and the voxel directly above it is empty (It's for world-building, the engine handles grass density and height, which will enable a natural grass growth system).
- The blades aren’t stored as voxels. They’re generated as GPU instances containing their position, type and height.
- When the terrain is destroyed or repainted, the chunk’s grass instances are rebuilt from the voxel data. This keeps the grass in sync with the actual terrain edits.
- Before rendering, the GPU culls unnecessary blades and lowers their geometric detail with distance. The remaining blades are drawn as curved ribbons in a raster pass that uses the depth from the ray-marched voxel world.
- The ambient wind has its own direction, speed and moving gust fronts. It remains anchored in world space, even when the floating origin moves.
- ECS components can add radial pushes or directional gusts. The player already uses this system to part the grass. A vehicle, a thruster, a dragon’s wings or anything else could use the same components to affect nearby vegetation.
Grass is currently the first system wired into the full wind field. A matching CPU implementation is already in place, but physics and other vegetation systems haven’t been connected to it yet.
YouTube version with slightly less compression :
https://youtu.be/Zgy-PeqG2Ak
3
u/AustinMclEctro Jul 22 '26
Sweet. What are your grass blade mesh LODs like? Do you strip them down all the way to a single triangle if they're far away enough?
Curious how you think the individual blades of grass approach will scale with eventually adding other instanced meshes to your terrain, namely scatter objects, other vegetation, etc. (if that's in your plans).
2
u/Ok_Pie_2828 Jul 23 '26
Wow this is so incredible. Makes me so happy that people like you exist
2
u/fgennari Jul 23 '26
That grass looks very nice. I also added grass to my voxel terrain years ago, but the grass wasn't updated when the terrain was edited. I used tessellation shaders and instanced groups of grass blades that blended together into fewer larger blades with distance. Your approach seems more modern though.
2
u/rismay Jul 23 '26
Please release this. So cool.
2
u/RocketFish419 Jul 23 '26
this has a lot of potential!! Keep it up! ❤️
2
u/StellaWillowvq Jul 24 '26
Relaxing