Hey! I am experimenting with noise to make islands, but I’d like to add cliffs if possible by overlaying more noise, how would I go about doing this? (In a scaleable way)
Thanks!
This is what I hope to add
local Simplex = require(script.SimplexModule)
local Octave = Simplex()
Octave:Init()
local noiseMap = {}
local falloffMap = {}
local scale, size = 10000, 300
local sealevel = 20
local max, min = -math.huge, math.huge
local falloffMax, falloffMin = -math.huge, math.huge
local octaves = 8
local lacunarity = .3
local persistance = 4
local distance = Vector3.new(8, 1, 8)
local function determineColor(height)
local color = if height <= 1 then Color3.new(1, 0.803922, 0.309804) else Color3.new(0.188235, 0.666667, 0.137255)
return color
end
workspace:WaitForChild('Baseplate'):Destroy()
workspace.Terrain:FillBlock(CFrame.new(Vector3.new(0, -150, 0)), Vector3.new(8 * size, 300, 8 * size), Enum.Material.Water)
local function FallOfTestfMap(x, y)
local nx = ((x + size/2) / size) * 2 - 1
local ny = ((y + size/2) / size) * 2 - 1
return math.max(math.max(math.abs(nx), math.abs(ny)), math.sqrt(nx^2 + ny^2))
end
for x = -size/2, size/2 do
falloffMap[x] = {}
for y = -size/2, size/2 do
falloffMap[x][y] = FallOfTestfMap(x, y)
end
end
for x = -size/2, size/2 do
noiseMap[x] = {}
for y = -size/2, size/2 do
local Noise2D = 0
local normalizer = 0
local amplitude, frequency = 1, 1
for octave = 1, octaves do
Noise2D += (Octave:Get2DValue(((x + size/2) * (scale / size)) * frequency, ((y + size/2) * (scale / size)) * frequency) * amplitude) -- * falloffMap[x][y] -- -1 to 1
frequency *= lacunarity
normalizer += amplitude
amplitude *= persistance
end
Noise2D /= normalizer
Noise2D -= falloffMap[x][y]
Noise2D *= 60
noiseMap[x][y] = Noise2D
if Noise2D > max then max = Noise2D end
if Noise2D < min then min = Noise2D end
end
end
for x, yRow in pairs(noiseMap) do
task.wait(.05)
coroutine.wrap(function()
for y, noise in pairs(yRow) do
-- Normalize the noise value between 0 and 1
local normalizedNoise = (noise - min) / (max - min)
local height = math.round(noise) + sealevel
local part = Instance.new('Part')
part.Size = Vector3.new(8, 1, 8)
part.Position = Vector3.new(x, height, y) * distance
part.Color = determineColor(height) -- Color3.new(normalizedNoise, normalizedNoise, normalizedNoise)
part.Anchored = true
part.Parent = workspace.Camera
local lowestNeighbour = 0
for i = -1, 1 do
for j = -1, 1 do
if math.abs(i) == math.abs(j) then continue end
local neighbour = if noiseMap[x + i] and noiseMap[x + i][y + j] then noiseMap[x + i][y + j] else nil
if not neighbour then continue end
if math.round(neighbour) >= math.round(noise) then continue end
local neighbourHeight = math.round(noise) - math.round(neighbour)
if neighbourHeight <= 0 then continue end
lowestNeighbour = math.max(lowestNeighbour, neighbourHeight)
end
end
if lowestNeighbour ~= 0 then
part.Size += Vector3.new(0, lowestNeighbour, 0)
part.Position -= Vector3.new(0, lowestNeighbour/2, 0)
part.Color = determineColor(height - lowestNeighbour)
end
task.wait(.05)
end
end)()
end