Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mapSize = 500
- local noise = math.noise
- local seed = tick()
- local heightMap = table.create(mapSize, table.create(mapSize))
- local abs = math.abs
- local colorTable = {
- [0] = BrickColor.Blue();
- [1] = BrickColor.new("Beige");
- [2] = BrickColor.Green();
- [3] = BrickColor.DarkGray();
- [4] = BrickColor.White();
- }
- --SETTINGS
- wait(3)
- local FREQUENCY = 2;
- local REDISTRIBUTION = 1;
- local PERSISTANCE = 0.5;
- local OCTAVES = 5;
- local LACUNARITY = 2;
- local AMPLITUDE = 500;
- local function ridgeNoise(nx, ny)
- return noise(nx, ny, seed) --2 * (0.5 - abs(0.5 - noise(nx, ny, seed)));
- end
- local function getBiome(hm)
- if hm < 0.05 then
- return 0
- elseif hm < 0.1 then
- return 1
- elseif hm < 0.2 then
- return 2
- elseif hm < 0.3 then
- return 3
- else
- return 4
- end
- end
- for x = 1,mapSize do
- if x % 10 == 0 then
- game:GetService("RunService").Heartbeat:Wait()
- end
- for y = 1,mapSize do
- local nx, ny = x/mapSize - 0.5, y/mapSize - 0.5
- local elevation = 0
- for i = 1,OCTAVES do
- local newElev = PERSISTANCE^i * ridgeNoise(nx * FREQUENCY * LACUNARITY^(i-1),ny * FREQUENCY * LACUNARITY^(i-1))
- elevation += newElev
- end
- heightMap[x][y] = math.pow(elevation, REDISTRIBUTION);
- local biome = getBiome(heightMap[x][y])
- local part = Instance.new("Part")
- part.Anchored = true
- part.Size = Vector3.new(1,50,1)
- part.Position = Vector3.new(x, math.clamp(heightMap[x][y],0.05,10000)*AMPLITUDE, y);
- part.BrickColor = colorTable[biome]
- part.Material = Enum.Material.SmoothPlastic
- part.Parent = workspace
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement