My goal is…
1 - sharp mountains
2 - rare mountains
FULL SCRIPT –
local grid = 16
local spacing = 1.5
local seed = math.random(1, 999999)
local blocks = {}
local SPAAGRI = spacing*grid
local size = Vector3.new(spacing, spacing,spacing)
local persistence = 0.8 -- Increase persistence for more variation
local octawaves = 1 -- Keep octaves low for simplicity
local lacunarity = 0.2
local downheight = -16
local upperheight = 256
local chunks = Instance.new("Folder")
local res =128 * spacing
local val = 0
chunks.Name = "Chunks"
chunks.Parent = workspace
function SpawnChunk(plr,x, y)
local chunk = Instance.new("Folder")
chunk.Name = x..", "..y
chunk.Parent = chunks
for x1 = 1, grid do
task.wait(0)
for y1 = 1, grid do
task.wait(0)
local fixedx = (x*SPAAGRI) + (x1*spacing)
local fixedy = (y*SPAAGRI) + (y1*spacing)
local x2 = fixedx
local y2 = fixedy
local Ampilifier = 32
for i = 1, octawaves do
val = math.abs(math.noise(fixedx / res, fixedy / res, seed))* (Ampilifier)
y2 *= lacunarity
x2 *= lacunarity
Ampilifier *= (persistence*spacing)
end
math.clamp(val, -1, 1)
val = val ^ 2
local color = nil
local name = nil
if val > 70 then
color = Color3.fromRGB(255, 255, 255) -- White
name = "snow"
elseif val > 20 then
color = Color3.fromRGB(95, 97, 95) -- Gray
name = "stone"
else
color = Color3.fromRGB(42, 86, 62) -- Green
name = "grass"
end
local c = 1 -- c is some constant you use to customise how the noise feels
local treethreshold = 0.71 -- the TreeChance needs to be greater than this to spawn a tree
local freq = 1
local res = 2
local TreeChance = math.noise(fixedx * freq * c / res, fixedy * freq * c / res, seed)
-- water chance is jsut like treechange execpt the block coclor is water
local c = 1 -- c is some constant you use to customise how the noise feels
local waterthreshold = 0.1 -- the TreeChance needs to be greater than this to spawn a tree
local freq = 1
local res = 256
local WaterChance = math.noise(fixedx * freq * c / res, fixedy * freq * c / res, seed)
local height = math.round(val / spacing) * spacing
height = math.clamp(height, downheight * spacing, upperheight * spacing)
local block = Instance.new("Part")
block.Parent = workspace.Terrain
block.Anchored = true
block.Position = Vector3.new(fixedx,height, fixedy)
block.Size = size
block.Name = name
if WaterChance > waterthreshold and (name == "grass") and (height == 0) then
color = Color3.fromRGB(10, 10, 108)
name = "water"
block.Position = block.Position + Vector3.new(0,-spacing,0)
end
if TreeChance > treethreshold and name == "grass" then
local block = workspace.Tree:Clone()
block.Parent = workspace.Terrain
block:PivotTo( CFrame.new(fixedx,height, fixedy))
end
block.Color = color
end
end
end
local load = 8
local timesran = 0
local loadchunk = load/4
local breaktime = loadchunk*loadchunk
for a =1, load do
for b = 1,load do
timesran +=1
coroutine.wrap(function()
SpawnChunk(nil,a,b)
end)()
task.wait()
end
end
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(SpawnChunk)
Down below are the variables that control the generating and needs tweaking
local Ampilifier = 32
local persistence = 0.8
local octawaves = 1
local lacunarity = 0.2
local res = 128