GPU Instanced Grass in Unity
For the original post, please go to https://www.yuque.com/qwerasdwww/dfy5xd
Part 1: Use DrawMeshInstancedIndirect and compute shader to draw static grass mesh
First, create a C# script and declare parameters we need to draw static grass.
Define the struct of grass, and create an array to store the grass.
Declare the parameters of compute shader.
We do the initialize work in Start(), and dispatch the compute shader and draw mesh in Update().
Finally we need to destroy the buffer.
Now let's create the compute shader first, write the grass struct and databuffer into it and leave it.
No comments:
Post a Comment