Realm limits with exponential blend
This commit is contained in:
parent
304f61b042
commit
1af8b2cfd1
@ -1,4 +1,4 @@
|
||||
subterrain 0.1.0 by paramat
|
||||
subterrain 0.1.1 by paramat
|
||||
For Minetest 0.4.8 stable
|
||||
Depends default
|
||||
Licenses: code WTFPL
|
||||
|
25
init.lua
25
init.lua
@ -1,13 +1,14 @@
|
||||
-- subterrain 0.1.0 by paramat
|
||||
-- subterrain 0.1.1 by paramat
|
||||
-- For Minetest 0.4.8 stable
|
||||
-- Depends default
|
||||
-- License: code WTFPL
|
||||
|
||||
-- Parameters
|
||||
|
||||
local YMAX = -113
|
||||
local TCAVE = 0.6 -- Cave threshold.
|
||||
-- 1 = small rare caves, 0 = 1/2 ground volume, 0.5 = 1/3rd ground volume
|
||||
local YMIN = -33000 -- Cave realm limits
|
||||
local YMAX = -256
|
||||
local TCAVE = 0.6 -- Cave threshold. 1 = small rare caves, 0.5 = 1/3rd ground volume, 0 = 1/2 ground volume
|
||||
local BLEND = 128 -- Cave blend distance near YMIN, YMAX
|
||||
|
||||
-- 3D noise for caves
|
||||
|
||||
@ -24,10 +25,13 @@ local np_cave = {
|
||||
|
||||
subterrain = {}
|
||||
|
||||
local yblmin = YMIN + BLEND * 1.5
|
||||
local yblmax = YMAX - BLEND * 1.5
|
||||
|
||||
-- On generated function
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
if maxp.y > YMAX then
|
||||
if minp.y > YMAX or maxp.y < YMIN then
|
||||
return
|
||||
end
|
||||
|
||||
@ -56,9 +60,17 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||
local nixyz = 1
|
||||
for z = z0, z1 do -- for each xy plane progressing northwards
|
||||
for y = y0, y1 do -- for each x row progressing upwards
|
||||
local tcave
|
||||
if y < yblmin then
|
||||
tcave = TCAVE + ((yblmin - y) / BLEND) ^ 2
|
||||
elseif y > yblmax then
|
||||
tcave = TCAVE + ((y - yblmax) / BLEND) ^ 2
|
||||
else
|
||||
tcave = TCAVE
|
||||
end
|
||||
local vi = area:index(x0, y, z)
|
||||
for x = x0, x1 do -- for each node do
|
||||
if nvals_cave[nixyz] > 0.6 then
|
||||
if nvals_cave[nixyz] > tcave then
|
||||
data[vi] = c_air
|
||||
end
|
||||
nixyz = nixyz + 1
|
||||
@ -71,6 +83,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||
vm:set_lighting({day=0, night=0})
|
||||
vm:calc_lighting()
|
||||
vm:write_to_map(data)
|
||||
|
||||
local chugent = math.ceil((os.clock() - t1) * 1000)
|
||||
print ("[subterrain] "..chugent.." ms")
|
||||
end)
|
||||
|
Loading…
x
Reference in New Issue
Block a user