Splinetest
This commit is contained in:
parent
37ae9cd44f
commit
09051784e8
92
init.lua
92
init.lua
|
@ -2,31 +2,74 @@
|
|||
luamap.set_singlenode()
|
||||
|
||||
-- main noise
|
||||
local recip_factors = {1115, 743, 446, 318, 202, 171, 131, 117, 97}
|
||||
local recip_factors = {371, 223, 139, 73, 31, 16}
|
||||
|
||||
-- local seed = math.random(2147483647)
|
||||
|
||||
function land_spline(x)
|
||||
if x < -1 or x > 1 then
|
||||
return 0
|
||||
end
|
||||
|
||||
local y = 0.0
|
||||
if x <= -0.528 then
|
||||
y = 1.1948552276997075*x^3 + 3.584565683099122*x^2 + 4.286591395034321*x + 0.8968809396349067
|
||||
elseif x <= -0.336 then
|
||||
y = -6.144176980539161*x^3 - 8.040461334751244*x^2 - 1.8514228703906723*x - 0.18340957107989228
|
||||
elseif x <= -0.067 then
|
||||
y = -0.9240711699722817*x^3 - 2.778594677699831*x^2 - 0.08343567362139721*x + 0.014604994958266554
|
||||
elseif x <= 0.12 then
|
||||
y = 17.58213581226864*x^3 + 0.9411529257305944*x^2 + 0.16578741580844128*x + 0.02017097728886628
|
||||
elseif x <= 0.304 then
|
||||
y = -24.236381697286387*x^3 + 15.995819229170404*x^2 - 1.6407725406043359*x + 0.09243337554537737
|
||||
elseif x <= 0.541 then
|
||||
y = 15.137791660779909*x^3 - 19.913426873386058*x^2 + 9.27563827457283*x - 1.0137629203925753
|
||||
elseif x <= 0.77 then
|
||||
y = -12.983576263592651*x^3 + 25.727553267870604*x^2 - 15.416131981847027*x + 3.438986315848472
|
||||
else
|
||||
y = 6.180446233374517*x^3 - 18.54133870012355*x^2 + 18.670914833508473*x - 5.31002236675944
|
||||
end
|
||||
|
||||
return y
|
||||
end
|
||||
|
||||
for i, r_fac in ipairs(recip_factors) do
|
||||
minetest.log("warning", r_fac)
|
||||
luamap.register_noise("terrain_o" .. i, {
|
||||
type = "2d",
|
||||
np_vals = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x=r_fac, y=r_fac, z=r_fac},
|
||||
scale = 0.5*r_fac,
|
||||
spread = {x=0.8*r_fac, y=0.8*r_fac, z=0.8*r_fac},
|
||||
seed = math.random(2147483647),
|
||||
octaves = 1,
|
||||
persist = 1,
|
||||
lacunarity = 1.0,
|
||||
flags = ""
|
||||
octaves = 4,
|
||||
persist = 0.3,
|
||||
lacunarity = 1.5,
|
||||
flags = "",
|
||||
},
|
||||
ymin = -31000,
|
||||
ymax = 31000,
|
||||
})
|
||||
end
|
||||
|
||||
local c_stone = minetest.get_content_id("default:stone")
|
||||
-- local c_water = minetest.get_content_id("default:water_source")
|
||||
luamap.register_noise("inland", {
|
||||
type = "2d",
|
||||
np_vals = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x=128, y=128, z=128},
|
||||
seed = math.random(2147483647),
|
||||
octaves = 4,
|
||||
persist = 0.4,
|
||||
lacunarity = 2,
|
||||
flags = "",
|
||||
},
|
||||
})
|
||||
|
||||
-- local water_level = 0
|
||||
local c_stone = minetest.get_content_id("default:stone")
|
||||
local c_sandstone = minetest.get_content_id("default:sandstone")
|
||||
local c_water = minetest.get_content_id("default:water_source")
|
||||
|
||||
local water_level = 0
|
||||
|
||||
local old_logic = luamap.logic
|
||||
|
||||
|
@ -34,20 +77,25 @@ function luamap.logic(noise_vals,x,y,z,seed,original_content)
|
|||
-- get any terrain defined in another mod
|
||||
local content = old_logic(noise_vals,x,y,z,seed,original_content)
|
||||
|
||||
-- if y < water_level then
|
||||
-- content = c_water
|
||||
-- end
|
||||
|
||||
local terrain_height = 0
|
||||
for i, r_fac in ipairs(recip_factors) do
|
||||
local name = "terrain_o" .. i
|
||||
terrain_height = terrain_height + r_fac * noise_vals[name]
|
||||
if y < water_level then
|
||||
content = c_water
|
||||
end
|
||||
|
||||
if y < terrain_height * 0.1 then
|
||||
if math.random(10) == 7 then minetest.log("warning", "yes") end
|
||||
local terrain_height = 20
|
||||
for i = 1, #recip_factors do
|
||||
local name = "terrain_o" .. i
|
||||
terrain_height = terrain_height + noise_vals[name]
|
||||
end
|
||||
|
||||
terrain_height = 512 * land_spline(luamap.remap(terrain_height, -512, 512, -1, 1))
|
||||
terrain_height = terrain_height * 0.4
|
||||
|
||||
if y < terrain_height then
|
||||
content = c_stone
|
||||
end
|
||||
if y == math.floor(terrain_height) then
|
||||
content = c_sandstone
|
||||
end
|
||||
|
||||
return content
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue