2021-03-24 17:46:00 +02:00
|
|
|
local simplex_noise = require 'utils.simplex_noise'.d2
|
2019-08-06 23:54:07 +02:00
|
|
|
|
|
|
|
local noises = {
|
2021-03-24 17:46:00 +02:00
|
|
|
['trees_01'] = {{modifier = 0.03, weight = 1}, {modifier = 0.05, weight = 0.3}, {modifier = 0.1, weight = 0.05}},
|
|
|
|
['scrap_01'] = {{modifier = 0.04, weight = 1}, {modifier = 0.06, weight = 0.3}, {modifier = 0.08, weight = 0.1}}
|
2019-08-06 23:54:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
local function get_noise(name, pos, seed)
|
2021-03-24 17:46:00 +02:00
|
|
|
local noise = 0
|
|
|
|
local x = pos.x
|
|
|
|
local y = pos.y
|
|
|
|
if not x then
|
|
|
|
x = pos[1]
|
|
|
|
end
|
|
|
|
if not y then
|
|
|
|
y = pos[2]
|
|
|
|
end
|
|
|
|
for _, n in pairs(noises[name]) do
|
|
|
|
noise = noise + simplex_noise(x * n.modifier, y * n.modifier, seed) * n.weight
|
|
|
|
seed = seed + 10000
|
|
|
|
end
|
|
|
|
return noise
|
2019-08-06 23:54:07 +02:00
|
|
|
end
|
|
|
|
|
2021-03-24 17:46:00 +02:00
|
|
|
return get_noise
|