A downloadable project for Windows

What is this?

This project is just a little experiment of mine. I want to learn more about GPU instancing and optimized terrain generation/rendering.


Progress

  1. Initially, I developed a chunk script for terrain generation, creating a plane mesh with adjustable vertex count.
    1. I use a compute shader to determine vertex heights by combining three layers of differently scaled noises on the GPU.
    2. To fix the incorrectly calculated normals at chunk edges, I recalculated the normals based on the gradient.
  2. Once I got one chunk working fine I made a chunk manager that can spawn a grid of chunks. This manager makes it easy to adjust parameters such as vertex count per chunk and vertex spacing.
  3. I also began work on a "chunk decorations" script attached to each chunk
    1. When a chunk is first loaded, a compute shader calculates heights for random positions within the chunk area.
    2. I also calculate slightly random scales and rotations and store them all in a Matrix4x4 array
    3. This "Transform" array is then stored in a Dictionary with the chunks id as the key so that when you return to a chunk the tree, house and boat positions are still the same
    4. Each frame, I check chunk visibility and use the RenderMeshInstanced function to efficiently render tree, boat, and house meshes. This method optimizes performance by sending mesh and material data only once per 1023 objects.
    5. I've implemented a lower-poly tree model for distant chunks to further enhance performance.
    Red = not in view, yellow = low poly trees, green = normal trees

Future

There are still a lot of things that I want to like to optimize or add to the project going forward:

  • I want to start using the RenderMeshIndirect function to further optimize the performance
  • I am working on giving the ships simple boid-like behaviour I have done so with a compute shader and keeping the positional data mostly on the GPU (with RenderMeshIndirect) will allow me to keep the performance good while doing so
  • I would like to work on a better water shader, the one that is currently in the project is a placeholder I made in a couple of minutes
  • Post processing
  • I also want to add more gameplay, currently the player has the "objective" to hunt the green cube around the map but I have been thinking about other possibilities for more fun and unique gameplay

Download

Download
Terrain Generation 57 MB

Comments

Log in with itch.io to leave a comment.

cool stuff!