Search code examples
unity-game-engineshadermeshterraingeometry-shader

Unity Geometry Shader: Dynamic Grass


So, I have a functioning voxel engine that creates smoothed terrain in chunks of 1x1x1 meter in a 1024 radius around my player.

I wanted to create a geometry shader that not only continues to texture the ground appropriately, but also creates grass (preferably waving with the wind).

I have found some basic billboard geometry shaders to get me started, but they seem to cause the mesh to stop texturing. Is there anyway to do both from one shader?

Do I pass the mesh triangles and the new grass triangles on to the fragment shader with a flag? Thanks in advance!


Solution

  • You can do this by implementing two passes to the shader as it turns out. My first pass is a simple surface shader, but my second pass is the geometry shader. The multi-pass still results in 130 FPS, so it seems to be adequate.