Feedback On My Part Terrain System

Since the start of July I have been turning my Marching Cubes terrain generator into a fully-fledged terrain system.

How It Works
This terrain samples points every 5 studs inside of a 16x25x16 rectangle. Each point is sampled from a fractal noise function. Then if that sampled value is below the threshold then the point is off, if the sampled value is above or equal to the threshold then the point is on.

the points are then put into a marching cubes algorithm and it makes quite convincing terrain.

Here’s what my terrain looked like before I started:

Here’s what my terrain looked like when the terrain system was done:


It took a lot of optimisations to get from a small 16x25x16 chunk to a 5 by 5 grid of 25x25x25 chunks.

What optimisations did I make?

  • I changed it so that when the player joins the game a table of parts is created, these parts are put into a part pool. Then when a chunk is created it takes the parts it needs from the part pool. This causes significantly less lag as new parts are only created when the player joins.

  • I declared variables such as v3 = Vector3.New and SetMetatable = setmetatable at the top of my script, this is micro-optimisation that helps with speed.

  • I implemented my own wait function that helps with making sure that things are loaded fast with the least lag as possible.

  • I added a function that only performs the marching cubes algorithm on the points that would actually help form part of the terrain.

Overall my optimisations reduced the lag significantly and reduced the average load time from 17s to 5s.


Other stuff I Did

  • I made the tops of hills a darker green the better distinguish them and separate them from the low valleys.

  • I added trees, currently they just choose random positions on the terrain but eventually I want to create my own implementation of a poisson disc sampling algorithm to place them on the terrain.


A Video Of The Terrain

12 Likes