This is great and all, but I’d love to have similar biomes to Dont Starve Together where the biomes appear more in a voronoi noise.
This is what voronoi noise would look like:
local function distance(x1, y1, x2, y2)
return math.sqrt((x2 - x1)^2 + (y2 - y1)^2)
end
local function generateVoronoiNoise(width, height, numPoints)
local points = {}
for i = 1, numPoints do
points[i] = {
x = math.random(1, width),
y = math.random(1, height),
color = Color3.new(math.random(), math.random(), math.random())
}
end
local noise = {}
for x = 1, width do
noise[x] = {}
for y = 1, height do
local minDist = math.huge
local closestPoint
for _, point in ipairs(points) do
local dist = distance(x, y, point.x, point.y)
if dist < minDist then
minDist = dist
closestPoint = point
end
end
noise[x][y] = closestPoint.color
end
end
return noise
end
local function visualizeVoronoiNoise(noise)
local width = #noise
local height = #noise[1]
local model = Instance.new("Model")
model.Name = "VoronoiNoise"
model.Parent = workspace
for x = 1, width do
for y = 1, height do
local part = Instance.new("Part")
part.Size = Vector3.new(1, 1, 0.1)
part.Position = Vector3.new(x, y, 0)
part.Color = noise[x][y]
part.Anchored = true
part.CanCollide = false
part.Parent = model
end
end
end
local width, height = 50, 50
local numPoints = 20
local noise = generateVoronoiNoise(width, height, numPoints)
visualizeVoronoiNoise(noise)