Terrain generation unrealistic

I am trying to make a minecraft-like terrain generation. I am on the first phase right now - generating a terrain with cool stuff like overhangs etc.

It somewhat works but the generation is unrealistic.

I have some questions.

  • How can I make this realistic?
  • How do I go about texturing all the blocks? For e.g texturing the first 2 layers as grass etc.
  • How can I add different biomes?
  • How can I add oceans?
  • How can I add lakes and isolated bodies of water?

CURRENT CODE:

local RunService = game:GetService("RunService")
local wait = require(workspace.FastWait)

local map_size_in_blocks
if (RunService:IsStudio()) then
	map_size_in_blocks = Vector3.new(128,32,128)
else
	map_size_in_blocks = Vector3.new(256,64,256)
end
local block_size = Vector3.new(2,2,2)

local noise_scale = 40
local amplitude = 15

local rand = Random.new(os.clock()+os.time())

local seed = rand:NextNumber(1,500000)

for X = 0,(map_size_in_blocks.X-1) do
	for Y = 0,(map_size_in_blocks.Y-1) do
		for Z = 0,(map_size_in_blocks.Z-1) do
			local noise_x = math.noise(Z/noise_scale,Y/noise_scale,seed)*amplitude
			local noise_y = math.noise(X/noise_scale,Z/noise_scale,seed)*amplitude
			local noise_z = math.noise(X/noise_scale,Y/noise_scale,seed)*amplitude
			
			local density = (noise_x + noise_y + noise_z)
			
			if (Y == 0) then -- Similar to "Bedrock" in MC
				local part = Instance.new("Part")
				part.Anchored = true
				part.Size = block_size
				part.Position = Vector3.new(X,Y,Z) * block_size
				part.Parent = workspace.World
			elseif (((density + Y) <= 15)) then
				local part = Instance.new("Part")
				part.Anchored = true
				part.Size = block_size
				part.Position = Vector3.new(X,Y,Z) * block_size
				part.Parent = workspace.World
			end
		end
	end
	wait()
end
4 Likes

add different layers to try and accomplish your goal, it’s possible but you’ll need to add some things for more layers like stone.

A few months ago, I was making a similar terrain generation system. Now, I never got around to making it 3D with overhangs, but the same ideas should still apply.
There are a few different things you can do to make it look more realistic which I found out:

Ridges instead of bumps
Normal noise terrain is just overlapping sine waves - but if you change that function, you can make it a lot more interesting. Using math.abs to make ridges instead of the broad peaks makes it looks more realistic (though this could change throughout the terrain). Any values that would’ve fallen below 0 are now made positive. I think I also flipped the entire thing upside down too.

Without and with ridges


image

Layered noise
The previous images were using 2 ‘layers’ of noise. Have a look at this, with different amounts of noise layers (they get smaller with each layer - these are known as octaves). I’m using the same seed each time here so you can get a better picture of it.

Noise octaves


1 octave (typical generation)

2 octaves. You can see a clear difference in the amount of detail since the second layer is only slightly smaller.

3 octaves

5 octaves. Makes the terrain a lot rougher at higher octaves

10 octaves. Maybe too much at this point, but it shows there’s flexibility

My implementation of this was like so:


It’s a bit scuffed, but basically gain is how much the next layer of noise affects the height, and lacunarity is how much more ‘detailed’ the next layer of noise is.
I use a value of 2 for lacunarity (half the size of the next noise layer, so twice the detail) and 0.45 for gain (only changes by 45% of the previous layer’s height).

Biomes
As you can see in the other images, I have some sort of biomes present. I admit, I’m not really very happy with how I’ve done them, since the way they work is through getting another noise layer, and if the number is between certain ranges, it’ll be that biome.
That means that the volcano biome can only be in the desert biome, which is sort of cool but not what I want in hindsight - it’s not a great way to add biomes, but maybe you can still take something from this.

My biome implementation stuff


Module for adding different biomes - it’s quite limited because I have to adjust each other biome if I want to add a new one in. There’s definitely a better way to do it.


Biome finding function


Biome colour blending (biome colours transition into eachother)

Hope this has helped. If you want any specifics about what I’ve talked about, feel free to reply on here, or DM on the DevForums or Discord (Lightlim#8531).

The solutions I’ve used aren’t necessarily my own, I’ve mostly just adapted them from other places.
Here’s one great website I used for some of the ideas:

5 Likes