How to make perlin noise have more variation?

I was playing around with some minecraft like terrain reading up on stuff and make this script below

local Seed = 10
local ROWS = 64
local COLS = 64
local RANGE = 40
local mult = 4
local DivideBy = 16
function Part(PosX, PosY, alpha)
	local Part = Instance.new("Part")
	Part.BrickColor = BrickColor.new("Bright green")
		Part.Parent = workspace
		Part.Size = Vector3.new(mult, mult, mult)
	Part.Anchored = true
	local DirtPart = Instance.new("Part")
	DirtPart.BrickColor = BrickColor.new("Reddish brown")
	DirtPart.Parent = workspace
	DirtPart.Size = Vector3.new(mult, mult, mult)
	DirtPart.Anchored = true
	local StonePart1 = Instance.new("Part")
	StonePart1.BrickColor = BrickColor.new("Smoky grey")
	StonePart1.Parent = workspace
	StonePart1.Size = Vector3.new(mult, mult, mult)
	StonePart1.Anchored = true
	
	local StonePart2 = Instance.new("Part")
	StonePart2.BrickColor = BrickColor.new("Smoky grey")
	StonePart2.Parent = workspace
	StonePart2.Size = Vector3.new(mult, mult, mult)
	StonePart2.Anchored = true
	RANGE = math.random(10, 11)
local noise1 = math.floor(((alpha*RANGE) + 40 / mult) + 0.5) * mult
	Part.Position = Vector3.new(PosX*mult,noise1, PosY*mult)
	DirtPart.Position = Part.Position + Vector3.new(0, -mult, 0)
	StonePart1.Position = DirtPart.Position + Vector3.new(0, -mult, 0)
	StonePart2.Position = StonePart1.Position + Vector3.new(0, -mult, 0)
	--(alpha*RANGE) + 40
end

for y=1, ROWS, 1 do
	for x=1, COLS, 1 do
		
		
		local noise = math.noise(x/DivideBy, y/DivideBy, 0)
		Part(x, y, noise)
	end
end

I was wondering how do i add more variation. Currently the terrain looks super bland and repetitive and i want to have smooth plains and tall mountains. How would i add like a “bias” to it to make it so higher values are more exaggerated but also make the values rarer?

screenshot of code in action:

2 Likes

make it so that at random time it will flatten out a little

You can try layering 2 seeds to each other, with one dominant seed and one sub-seed:

--// 2 different seeds

local Seed1 = 10
local Seed2 = Seed1 + 1

Then, you would get the noise from Seed1 and add it onto half the noise from Seed2. This will add more variation.

2 Likes

this wouldnt work as the terrain is generated in rows that are stacked on top of one another.

I know this isn’t an answer to your question, but setting the parent after you change the size and anchored properties will perform better then what you got

also you got some repeated code with all those property changes

2 Likes

i know the code is far from performant but it is a demo. Thank you anyway though since i didnt know that.

1 Like

i dont think this is how noises work. a greater seed doesnt make terrain have lower min values and higher max values.

I think he means setting the parts position to:

(final math.noise value for seed1) + (final math.noise value for seed2)/2

Not making two separate layers of parts
The + 1 in the seed2 is to make it different from the previous one, not to make it have a change in min or max values, thats what the /2 is for

1 Like


i modified it and now it looks better but how would i add mountainy areas and flatter areas? and how would i tween between both

local Seed = 10
local ROWS = 64
local COLS = 64
local RANGE = 500
local mult = 4
local DivideBy = 16
function Part(PosX, PosY, alpha, alpha2)
	local Part = Instance.new("Part")
	Part.BrickColor = BrickColor.new("Bright green")
		Part.Parent = workspace
		Part.Size = Vector3.new(mult, mult, mult)
	Part.Anchored = true
	local DirtPart = Instance.new("Part")
	DirtPart.BrickColor = BrickColor.new("Reddish brown")
	DirtPart.Parent = workspace
	DirtPart.Size = Vector3.new(mult, mult, mult)
	DirtPart.Anchored = true
	local StonePart1 = Instance.new("Part")
	StonePart1.BrickColor = BrickColor.new("Smoky grey")
	StonePart1.Parent = workspace
	StonePart1.Size = Vector3.new(mult, mult, mult)
	StonePart1.Anchored = true
	
	local StonePart2 = Instance.new("Part")
	StonePart2.BrickColor = BrickColor.new("Smoky grey")
	StonePart2.Parent = workspace
	StonePart2.Size = Vector3.new(mult, mult, mult)
	StonePart2.Anchored = true
	RANGE = math.random(10, 11)
local noise1 = math.floor(((((alpha+alpha2)/2)*RANGE) + 40 / mult) + 0.5) * mult
	Part.Position = Vector3.new(PosX*mult,noise1, PosY*mult)
	DirtPart.Position = Part.Position + Vector3.new(0, -mult, 0)
	StonePart1.Position = DirtPart.Position + Vector3.new(0, -mult, 0)
	StonePart2.Position = StonePart1.Position + Vector3.new(0, -mult, 0)
	--(alpha*RANGE) + 40
end

for y=1, ROWS, 1 do
	for x=1, COLS, 1 do
		
		
		local noise1 = math.noise(x/(DivideBy*5), y/(DivideBy*5), Seed)
		--local noise2 = math.noise(x/(DivideBy*2), y/(DivideBy*2), Seed+3)
		local noise2 = math.noise((x/DivideBy), (y/DivideBy), Seed+10)
		Part(x, y, noise1, noise2)
	end
end

updated code (i made one noise be very flat and i made one noise have hills and did an avg like u said)

image
(ignore the other stuff in the screeenshot but see the contrast between plains and mountains?)

1 Like

I believe Minecraft’s biomes are a different noise entirely (so there’s a seed for terrain generation and a different seed for biome generation). So you have the terrain generation.

You’d have to create a separate seed to have biome generation. For example, if the number is bigger than 0.1, make it a plains biome, if it’s smaller than -0.4, make it an extreme hills biome.

Each biome would have its own set of rules to follow. For example, the amplitude of the extreme hills biome is higher while the amplitude for the plains biome is lower.

NOTE: The Perlin noise for the biome generator would need a smaller noise increment. So instead of using 100% of the position of the block, use something like 0.5% of the position of the block (so if the position of the block is Vector3.new(1, 1, 1), instead of passing the x coordinate as 1, you’d pass the x coordinate as 0.05 [1 * 0.05 = 0.05])

1 Like

I think the most interesting part of this problem is blending two different noises together smoothly
It almost is like perlin noise in and of itself which smoothly blends gradients, but now you’re smoothly blending a smooth blend of gradients in 3D space

I personally cant think of a good solution to this problem but I could try thinking some more

Perhaps the resident math whiz will make a surprise visit

Start focusing on making the different biomes first, then you can focus on blending them in. Remember, do the main things first, little details after.



i combined 2 maps then had a third independent perlin that would dictate how strong to make features of terrain. I am gonna make it a bit more complicated but i got something basic working…

2 Likes

can you opensource this since it looks cool

1 Like