1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-08 00:39:30 +02:00
ComfyFactorio/utils/get_noise.lua

143 lines
5.0 KiB
Lua
Raw Normal View History

2020-05-09 13:21:17 +02:00
local simplex_noise = require 'utils.simplex_noise'.d2
2019-12-20 18:02:23 +02:00
--add or use noise templates from here
local noises = {
2020-05-09 13:21:17 +02:00
['bb_biterland'] = {
{modifier = 0.001, weight = 1},
{modifier = 0.01, weight = 0.35},
{modifier = 0.1, weight = 0.015}
},
['bb_ore'] = {{modifier = 0.0042, weight = 1}, {modifier = 0.031, weight = 0.08}, {modifier = 0.1, weight = 0.025}},
['cave_ponds'] = {{modifier = 0.01, weight = 1}, {modifier = 0.1, weight = 0.06}},
2020-06-25 17:59:16 +02:00
['smol_areas'] = {{modifier = 0.01, weight = 1}, {modifier = 0.1, weight = 0.02}, {modifier = 0.1, weight = 0.03}},
2020-05-09 13:21:17 +02:00
['cave_worms'] = {{modifier = 0.001, weight = 1}, {modifier = 0.1, weight = 0.06}},
['cave_rivers'] = {
{modifier = 0.005, weight = 1},
{modifier = 0.01, weight = 0.25},
{modifier = 0.05, weight = 0.01}
},
['cave_rivers_2'] = {
{modifier = 0.003, weight = 1},
{modifier = 0.01, weight = 0.21},
{modifier = 0.05, weight = 0.01}
},
['cave_rivers_3'] = {
{modifier = 0.002, weight = 1},
{modifier = 0.01, weight = 0.15},
{modifier = 0.05, weight = 0.01}
},
['cave_rivers_4'] = {
{modifier = 0.001, weight = 1},
{modifier = 0.01, weight = 0.11},
{modifier = 0.05, weight = 0.01}
},
['decoratives'] = {{modifier = 0.03, weight = 1}, {modifier = 0.05, weight = 0.25}, {modifier = 0.1, weight = 0.05}},
['dungeons'] = {{modifier = 0.0025, weight = 1}, {modifier = 0.005, weight = 0.25}},
['dungeon_sewer'] = {
{modifier = 0.0005, weight = 1},
{modifier = 0.005, weight = 0.015},
{modifier = 0.025, weight = 0.0015}
},
['large_caves'] = {
{modifier = 0.0033, weight = 1},
{modifier = 0.01, weight = 0.22},
{modifier = 0.05, weight = 0.05},
{modifier = 0.1, weight = 0.04}
},
['n1'] = {{modifier = 0.0001, weight = 1}},
['n2'] = {{modifier = 0.001, weight = 1}},
['n3'] = {{modifier = 0.01, weight = 1}},
2021-03-24 17:46:00 +02:00
['n4'] = {{modifier = 0.1, weight = 1}},
2020-09-03 05:50:45 +02:00
['n5'] = {{modifier = 0.07, weight = 1}},
2020-05-09 13:21:17 +02:00
['watery_world'] = {
{modifier = 0.0007, weight = 1},
{modifier = 0.01, weight = 0.02},
{modifier = 0.1, weight = 0.005}
},
['no_rocks'] = {
{modifier = 0.0033, weight = 1},
{modifier = 0.01, weight = 0.22},
{modifier = 0.05, weight = 0.05},
{modifier = 0.1, weight = 0.04}
},
['no_rocks_2'] = {{modifier = 0.013, weight = 1}, {modifier = 0.1, weight = 0.1}},
['oasis'] = {
{modifier = 0.0015, weight = 1},
{modifier = 0.0025, weight = 0.5},
{modifier = 0.01, weight = 0.15},
{modifier = 0.1, weight = 0.017}
},
['scrapyard'] = {
{modifier = 0.005, weight = 1},
{modifier = 0.01, weight = 0.35},
{modifier = 0.05, weight = 0.23},
{modifier = 0.1, weight = 0.11}
2020-10-19 18:26:24 +02:00
},
2021-03-24 17:46:00 +02:00
['big_cave'] = {
2020-10-19 18:26:24 +02:00
{modifier = 0.003, weight = 1},
{modifier = 0.02, weight = 0.05},
{modifier = 0.15, weight = 0.02}
2020-05-09 13:21:17 +02:00
},
['small_caves'] = {
{modifier = 0.008, weight = 1},
{modifier = 0.03, weight = 0.15},
{modifier = 0.25, weight = 0.05}
},
['small_caves_2'] = {
{modifier = 0.009, weight = 1},
{modifier = 0.05, weight = 0.25},
{modifier = 0.25, weight = 0.05}
2020-08-09 20:22:33 +02:00
},
['forest_location'] = {
{modifier = 0.006, weight = 1},
{modifier = 0.01, weight = 0.25},
{modifier = 0.05, weight = 0.15},
{modifier = 0.1, weight = 0.05}
},
['forest_density'] = {
{modifier = 0.01, weight = 1},
{modifier = 0.05, weight = 0.5},
{modifier = 0.1, weight = 0.025}
2020-10-19 18:26:24 +02:00
},
2021-03-24 17:46:00 +02:00
['cave_miner_01'] = {
2020-11-07 08:40:36 +02:00
{modifier = 0.0015, weight = 1},
2021-03-24 17:46:00 +02:00
{modifier = 0.0030, weight = 0.15},
2020-11-07 08:40:36 +02:00
{modifier = 0.0100, weight = 0.025},
{modifier = 0.1000, weight = 0.01}
2020-10-27 02:28:24 +02:00
},
2021-03-24 17:46:00 +02:00
['cave_miner_02'] = {
2020-10-27 02:28:24 +02:00
{modifier = 0.006, weight = 1},
{modifier = 0.02, weight = 0.15},
{modifier = 0.25, weight = 0.025}
},
2021-03-24 17:46:00 +02:00
['cm_ponds'] = {{modifier = 0.025, weight = 1}, {modifier = 0.05, weight = 0.25}, {modifier = 0.1, weight = 0.05}},
['cm_ocean'] = {
{modifier = 0.002, weight = 1},
{modifier = 0.004, weight = 1},
{modifier = 0.02, weight = 0.05}
},
2022-03-01 20:11:08 +02:00
['scrap_towny_ffa'] = {
{modifier = 0.005, weight = 1},
{modifier = 0.025, weight = 0.25},
{modifier = 0.1, weight = 0.125},
{modifier = 0.01, weight = 0.025}
},
['journey_swamps'] = {{modifier = 0.02, weight = 1}, {modifier = 0.04, weight = 0.35}, {modifier = 0.1, weight = 0.08}}
2019-12-20 18:02:23 +02:00
}
--returns a float number between -1 and 1
local function get_noise(name, pos, seed)
2020-05-09 13:21:17 +02:00
local noise = 0
local d = 0
2020-08-04 12:10:15 +02:00
for i = 1, #noises[name] do
local mod = noises[name]
noise = noise + simplex_noise(pos.x * mod[i].modifier, pos.y * mod[i].modifier, seed) * mod[i].weight
d = d + mod[i].weight
2020-05-09 13:21:17 +02:00
seed = seed + 10000
end
noise = noise / d
return noise
2019-12-20 18:02:23 +02:00
end
2020-05-09 13:21:17 +02:00
return get_noise