Alright, so this may seem like a large, over the top issue, but one of my friends has tasked me with generating a base map for his game (so he doesn’t have to make the terrain himself.) Obviously, roblox’s current generations isn’t the quality we are looking for, so I decided to make my own terrain generator. The code is linked below
Height = 100
Xrange = Vector2.new(-50000,50000)
Zrange = Vector2.new(-50000,50000)
Intensity = 500
Difference = 1000
Seed = 0
SeaLevel = 50
pi = math.pi
root2 = math.sqrt(2)
Xrange = Vector2.new(math.round(Xrange.X / 4),math.round(Xrange.Y / 4))
Zrange = Vector2.new(math.round(Zrange.X / 4),math.round(Zrange.Y / 4))
Difference = 1 / Difference
local lowestPoint = Height - (2 * Intensity)
local ticker = 0
for x = Xrange.X, Xrange.Y do
print(math.round(((x - Xrange.X) / (Xrange.Y - Xrange.X)) * 100))
for z = Zrange.X, Zrange.Y do
ticker = ticker + 1
if ticker % 50000 == 0 then
wait()
end
local terrainHeight = Height + (Intensity * math.noise(0.25 * x * root2 * Difference, Seed * root2, 0.25 * z * root2 * Difference))
local localIntensity = 5 * (math.noise(0.1 * Difference * root2 * x,Seed * root2,0.1 * Difference * root2 * z))
for i = 1, 5 do
terrainHeight = terrainHeight + ((Intensity / (2^i) * localIntensity) * math.noise(x * root2 * (2^i) * Difference, Seed * root2, z * root2 * (2^i) * Difference))
end
local cFrame = CFrame.new(x * 4 + 2, (lowestPoint + SeaLevel) / 2, z * 4 + 2)
local Size = Vector3.new(4, (SeaLevel - lowestPoint), 4)
game.Workspace.Terrain:FillBlock(cFrame, Size, Enum.Material.Water)
local cFrame = CFrame.new(x * 4 + 2, (lowestPoint + terrainHeight) / 2, z * 4 + 2)
local Size = Vector3.new(4, (terrainHeight - lowestPoint), 4)
game.Workspace.Terrain:FillBlock(cFrame, Size, Enum.Material.Grass)
end
end
The terrain which this script generates looks incredible, but I am facing the problem that it seems to take forever to generate the terrain. My friend requested a 100,000 by 100,000 generation for his upcoming open-world fantasy game, but even at maximum speed the script is taking days to finish. (I’m running it in the command bar.)
I was wondering if anybody knew any ways to speed up the script, or if a 100k x 100k map is too big for Roblox. If anybody has any opinions on this topic, please let me know! As always, thanks for taking the time to read this!