Hi,
Just wanted to start a development log for the new grass system to show where the current work is and whats been done.
So, the new grass system is using an instanced grass patch which means that you only pay for a single tile of grass that might be 8mx8m. This same mesh is then used to populate the rest of the grass on the terrain which eliminates stuttering like we had on Gen1 where you would move across the ground at speed or in a vehicle and it would pop as the grass is generated.
This happens no more.
However, because it is instanced, that means the tile has to be created as a flat tile:(see image)
![unknown.png](./download/file.php?id=405&sid=c1336056908ce09c429ee8959bbc8beb)
- unknown.png (891.62 KiB) Viewed 91772 times
which we then use the vertex shader with the terrain heightmap data to move the Y positions of the grass to sit on the terrain. The heightmap data will have to be recreated every time you press play, regenerate the grass tiles or if we are lucky, then recreate the map after the editing through the mouse release. This recreated data is stored into a FLOAT32_RGB format for accurate information over large areas.
Picture of the saved out heightdata:
![unknown (1).png](./download/file.php?id=406&sid=c1336056908ce09c429ee8959bbc8beb)
- unknown (1).png (412 KiB) Viewed 91772 times
It was not as simple as sampling a single point of height data though as it ended up looking very steppy or stairs.
![unknown (2).png](./download/file.php?id=407&sid=c1336056908ce09c429ee8959bbc8beb)
- unknown (2).png (941.53 KiB) Viewed 91772 times
After doing some vector mathematics in the shader and working out which triangle the vertex belonged to on the terrain, we now have it working quite nicely.
![unknown (3).png](./download/file.php?id=408&sid=c1336056908ce09c429ee8959bbc8beb)
- unknown (3).png (890.01 KiB) Viewed 91772 times
The only downside now is the buonding information since the bounds are set with the flat tile still and the new data is edited on the GPU, so this is affecting culling at the moment which is my current job.
I will keep this thread up to date with the development