Procedural island generation

Hey everyone!

I’m working on a tiny side project as a prototype for a future project I’d like to work on. It’s a game where you build skyships and explore different sky islands with friends, complete quests, etc.

I am wondering how to procedurally generate the sky islands. I want to have different monuments across each one and they should all be different shapes and size and in different positions in the world. Heres an example of one I built by hand:

They should have overhangs, holes, etc. No clue where to start with this, a bit of help and some code snippets would be much appreciated!

4 Likes

This isn’t really the place to request entire scripts.

On a side note, I actually made something that does basically this:

The difficulty comes in making them all not look the same.
This isn’t really something that has an easy solution.
I would recommend instead creating a bunch of island models by hand and cframing a clone of them into their respective positions.

I don’t really think this is requesting a script. I think they’re looking for methods to generate something like this. You can’t CFrame terrain and that wasn’t really helpful to their question.

As for the OP, I would personally recommend looking at Roblox’s terrain plugin as it might contain some useful code for biome selection. Googling for terrain generation also isn’t too bad of an idea. There are some very detailed topics online.

Usually math.noise would be used for flat terrain but since you’re going for islands you’d probably only use it for the surface of the island. You can apply some smoothing around the edges, give bottoms to the islands, and generate small caves in the islands. Again, Roblox’s terrain plugin might be good to look into.

Starting basic doesn’t hurt either. Once you’ve got some island shapes you can move on to generating more complex features in the islands.

@dispeller your game is cool but it’s not really much like what I’m looking for. I’m not asking for an entire script, either. Just some pseudo code.

I want smooth terrain island generation that can spawn little monuments on islands, trees, rocks, overhangs, hills, holes like in the example in the OP, etc

@Hexcede I’ve already tried to Google but so far can’t find much that will help me. How would I even generate a basic island shape?

For object spawning RayCasting would most likely do what you want. Roblox’s Random object can also help.

Determining islands’ center points would probably done the same way. Then you can determine a basic shape for the island using math.noise (probably using some kind of threshold), give it some heights again with math.noise, and give it some rotation.

Then you can use some smoothing to smooth the edges of the terrain and give it some curves (or maybe spikes) on the bottom of the terrain. Again you can smooth this out so it matches up better with the island.

1 Like

I’m still confused about how I can get a circular shape without it being a perfect circle?

Well math.noise gives you smooth values between x, y, and z changes so your island can use a threshold value from math.noise to determine the island shape. That’ll give you a relatively roundish shape.

1 Like

Could you give some pseudo code - I still don’t really understand it.

Basics of using Perlin Noise (2D Based) This thread is perfect for learning about perlin noise. it also contains psuedo code

1 Like

I was just looking at that post, but I still don’t understand this:

I’m still confused about how I should make the island with that and where I get Z from.

The X, Y, and Z of the island position can be your noise inputs according to the docs math.noise returns a value between -0.5 and 0.5. You can have a threshold to determine the shape of your island. For example, if the value is above 0.4, you could generate terrain there.

Most terrain generation uses perlin or simplex noise. These noise generators produce smooth values very much like hills or mountains.

But how do I get a circular shape? Wouldn’t this make a cube? Plus I don’t want perfect circles:

(The hand-made islands I did, not the best)

No it would not give a cube. Try visualizing the values returned by math.noise. make some parts for a 2d range in a map and then set their height to the output of the noise function.

Noise is random, but it is basically smooth randomness.

When generating your heightmap, you can use this function at each coordinate to apply a circular gradient:

function applyGradient(heightMapSize, x, y, z)
    local distance_x = math.abs(x - heightMapSize * 0.5)
    local distance_y = math.abs(z - heightMapSize * 0.5)
    local distance = math.sqrt(distance_x*distance_x + distance_y*distance_y)

    local max_width = heightMapSize * 0.5 - 10.0
    local delta = distance / max_width
    local gradient = delta * delta

    return y * math.max(0.0, 1.0 - gradient)
end
6 Likes

So, math.noise gives one value back, I could use that to make a perfect circle. How could I make it more of an oval?

You can use a threshold. If the value returned is high enough you could generate terrain there. You can adjust the threshold and the higher the number the smaller area will be generated. Too low, terrain will connect. Too high, terrain will be too small.

1 Like

How can I translate this into smooth terrain? I’m trying now but it’s not going well :joy:

The value returned would be used for terrain height. For 2d terrain, like the topbof your island, the z value isn’t usually used.

When I get a chance I’ll show you what my game’s terrain code looks like right now

How would I even generate the cylinder/oval shape and then round it off? I have literally never done this type of thing before sorry :joy:

You would use a threshold value. The noise function when graphed looks like hills. That’s why it’s used in terrain generation. If you cut the top off of a hill it’ll look kind of circular.