Vertical overgeneration. Tune parameters. Multilayer 16x16 clouds

This commit is contained in:
paramat 2014-04-26 05:54:56 +01:00
parent 9b2ad0f6bb
commit 6dc945dadc
2 changed files with 130 additions and 59 deletions

View File

@ -1,4 +1,4 @@
fracture 0.1.0 by paramat fracture 0.1.1 by paramat
For latest stable Minetest back to 0.4.8 For latest stable Minetest back to 0.4.8
Depends default Depends default
Licenses: code WTFPL Licenses: code WTFPL

187
init.lua
View File

@ -1,22 +1,27 @@
-- fracture 0.1.0 by paramat -- fracture 0.1.1 by paramat
-- For latest stable Minetest and back to 0.4.8 -- For latest stable Minetest and back to 0.4.8
-- Depends default -- Depends default
-- License: code WTFPL -- License: code WTFPL
-- 0.1.1
-- tune parameters
-- vertical overgeneration
-- 16x16 clouds
-- Parameters -- Parameters
local YMIN = -33000 local YMIN = -33000
local YMAX = 33000 local YMAX = 33000
local DENOFF = -0.4 -- Density offset, 0 = equal volumes of air and floatland local DENOFF = -0.4 -- Density offset, -2 to 2, 0 = equal volumes of air and floatland
local TSTONE = 0.08 -- Stone density threshold, controls average depth of stone below surface local TSTONE = 0.05 -- Stone density threshold, controls average depth of stone below surface
local STABLE = 2 -- Minimum number of stacked stone nodes in column required to support dirt/sand local STABLE = 2 -- Minimum number of stacked stone nodes in column required to support dirt/sand
local BLEND = 0.04 -- Controls biome blend distance local BLEND = 0.03 -- Controls biome blend distance
local PINCHA = 36 -- Pine chance 1/x chance local PINCHA = 36 -- Pine chance 1/x chance
local APPCHA = 36 -- Appletree 1/x chance local APPCHA = 36 -- Appletree 1/x chance
local CACCHA = 841 -- Cactus 1/x chance local CACCHA = 841 -- Cactus 1/x chance
local TCAC = 0.2 -- Cactus threshold, width of cactus areas local TCAC = 0.2 -- Cactus threshold, width of cactus areas
local TFOR = 0.2 -- Forest threshold, width of forest clearings local TFOR = 0.2 -- Forest threshold, width of forest paths/clearings
-- 3D noise for terrain -- 3D noise for terrain
@ -34,10 +39,10 @@ local np_terrain = {
local np_biome = { local np_biome = {
offset = 0, offset = 0,
scale = 1, scale = 1,
spread = {x=512, y=512, z=512}, spread = {x=512, y=171, z=512},
seed = -188900, seed = -188900,
octaves = 3, octaves = 3,
persist = 0.5 persist = 0.33
} }
-- 3D noise for flora -- 3D noise for flora
@ -51,6 +56,17 @@ local np_flora = {
persist = 0.67 persist = 0.67
} }
-- 3D noise for cloud noise
local np_cloud = {
offset = 0,
scale = 1,
spread = {x=52, y=52, z=52},
seed = -144111,
octaves = 2,
persist = 1
}
-- Stuff -- Stuff
fracture = {} fracture = {}
@ -108,6 +124,20 @@ minetest.register_node("fracture:cactus", {
on_place = minetest.rotate_node on_place = minetest.rotate_node
}) })
minetest.register_node("fracture:cloud", {
description = "Cloud",
drawtype = "glasslike",
tiles = {"fracture_cloud.png"},
paramtype = "light",
is_ground_content = false,
sunlight_propagates = true,
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
post_effect_color = {a=63, r=241, g=248, b=255},
})
-- Set mapgen parameters -- Set mapgen parameters
minetest.register_on_mapgen_init(function(mgparams) minetest.register_on_mapgen_init(function(mgparams)
@ -136,9 +166,9 @@ minetest.register_on_generated(function(minp, maxp, seed)
local data = vm:get_data() local data = vm:get_data()
local c_air = minetest.get_content_id("air") local c_air = minetest.get_content_id("air")
local c_frstone = minetest.get_content_id("fracture:stone") local c_stone = minetest.get_content_id("fracture:stone")
local c_frdestone = minetest.get_content_id("fracture:desertstone") local c_destone = minetest.get_content_id("fracture:desertstone")
local c_sand = minetest.get_content_id("default:sand") local c_cloud = minetest.get_content_id("fracture:cloud")
local c_desand = minetest.get_content_id("default:desert_sand") local c_desand = minetest.get_content_id("default:desert_sand")
local c_dirt = minetest.get_content_id("default:dirt") local c_dirt = minetest.get_content_id("default:dirt")
local c_grass = minetest.get_content_id("default:dirt_with_grass") local c_grass = minetest.get_content_id("default:dirt_with_grass")
@ -146,28 +176,24 @@ minetest.register_on_generated(function(minp, maxp, seed)
local c_snowblock = minetest.get_content_id("default:snowblock") local c_snowblock = minetest.get_content_id("default:snowblock")
local sidelen = x1 - x0 + 1 local sidelen = x1 - x0 + 1
local chulens = {x=sidelen, y=sidelen, z=sidelen} local chulens = {x=sidelen, y=sidelen+2, z=sidelen}
local minposxyz = {x=x0, y=y0, z=z0} local minposxyz = {x=x0, y=y0-1, z=z0}
local nvals_terrain = minetest.get_perlin_map(np_terrain, chulens):get3dMap_flat(minposxyz) local nvals_terrain = minetest.get_perlin_map(np_terrain, chulens):get3dMap_flat(minposxyz)
local nvals_biome = minetest.get_perlin_map(np_biome, chulens):get3dMap_flat(minposxyz) local nvals_biome = minetest.get_perlin_map(np_biome, chulens):get3dMap_flat(minposxyz)
local nvals_flora = minetest.get_perlin_map(np_flora, chulens):get3dMap_flat(minposxyz) local nvals_flora = minetest.get_perlin_map(np_flora, chulens):get3dMap_flat(minposxyz)
local nvals_cloud = minetest.get_perlin_map(np_cloud, chulens):get3dMap_flat(minposxyz)
local ungen = false
if minetest.get_node({x=x0, y=y0-1, z=z0}).name == "ignore" then
ungen = true
end
local nixyz = 1 local nixyz = 1
local stable = {} local stable = {}
local under = {} local under = {}
for z = z0, z1 do for z = z0, z1 do
for x = x0, x1 do for y = y0 - 1, y1 + 1 do
local si = x - x0 + 1
under[si] = 0
local nodename = minetest.get_node({x=x,y=y0-1,z=z}).name
if nodename == "air" then
stable[si] = 0
else
stable[si] = STABLE
end
end
for y = y0, y1 do
local vi = area:index(x0, y, z) local vi = area:index(x0, y, z)
local viu = area:index(x0, y-1, z) local viu = area:index(x0, y-1, z)
for x = x0, x1 do for x = x0, x1 do
@ -185,48 +211,93 @@ minetest.register_on_generated(function(minp, maxp, seed)
biome = 2 biome = 2
end end
if density >= TSTONE then if y == y0 - 1 then
if biome == 3 then
data[vi] = c_frdestone
else
data[vi] = c_frstone
end
stable[si] = stable[si] + 1
under[si] = 0 under[si] = 0
elseif density >= 0 and density < TSTONE and stable[si] >= 2 then if ungen then
if biome == 3 then if density >= 0 then
data[vi] = c_desand stable[si] = 2
under[si] = 3
elseif biome == 1 then
data[vi] = c_dirt
under[si] = 1
else
data[vi] = c_dirt
under[si] = 2
end
elseif density < 0 and under[si] ~= 0 then
if under[si] == 1 then
if math.random(PINCHA) == 2 and n_flora > TFOR then
fracture_snowypine(x, y, z, area, data)
else else
stable[si] = 0
end
else
local nodename = minetest.get_node({x=x,y=y,z=z}).name
if nodename == "fracture:stone"
or nodename == "fracture:redstone"
or nodename == "default:dirt"
or nodename == "default:dirt_with_grass"
or nodename == "default:dirt_with_snow"
or nodename == "default:snowblock"
or nodename == "default:desert_sand" then
stable[si] = 2
else
stable[si] = 0
end
end
elseif y >= y0 and y <= y1 then
if density >= TSTONE then
if biome == 3 then
data[vi] = c_destone
else
data[vi] = c_stone
end
stable[si] = stable[si] + 1
under[si] = 0
elseif density >= 0 and density < TSTONE and stable[si] >= 2 then
if biome == 3 then
data[vi] = c_desand
under[si] = 3
elseif biome == 1 then
data[vi] = c_dirt
under[si] = 1
else
data[vi] = c_dirt
under[si] = 2
end
elseif density < 0 and under[si] ~= 0 then
if under[si] == 1 then
if math.random(PINCHA) == 2 and n_flora > TFOR then
fracture_snowypine(x, y, z, area, data)
else
data[viu] = c_dirtsnow
data[vi] = c_snowblock
end
elseif under[si] == 2 then
if math.random(APPCHA) == 2 and n_flora > TFOR then
fracture_appletree(x, y, z, area, data)
else
data[viu] = c_grass
end
elseif under[si] == 3 then
if math.random(CACCHA) == 2 and n_flora < TCAC then
fracture_cactus(x, y, z, area, data)
end
end
stable[si] = 0
under[si] = 0
elseif y == y0 + 1 then
local xrq = 16 * math.floor((x - x0) / 16)
local zrq = 16 * math.floor((z - z0) / 16)
local yrq = 79
local qixyz = zrq * 6400 + yrq * 80 + xrq + 1
if math.abs(nvals_flora[qixyz]) < 0.2
and nvals_cloud[qixyz] >= 0 then
data[vi] = c_cloud
end
stable[si] = 0
under[si] = 0
else -- air
stable[si] = 0
under[si] = 0
end
elseif y == y1 + 1 then
if density < 0 and under[si] ~= 0 then
if under[si] == 1 then
data[viu] = c_dirtsnow data[viu] = c_dirtsnow
data[vi] = c_snowblock data[vi] = c_snowblock
end elseif under[si] == 2 then
elseif under[si] == 2 then
if math.random(APPCHA) == 2 and n_flora > TFOR then
fracture_appletree(x, y, z, area, data)
else
data[viu] = c_grass data[viu] = c_grass
end end
elseif under[si] == 3 then
if math.random(CACCHA) == 2 and n_flora < TCAC then
fracture_cactus(x, y, z, area, data)
end
end end
under[si] = 0
else -- air
stable[si] = 0
under[si] = 0
end end
nixyz = nixyz + 1 nixyz = nixyz + 1
vi = vi + 1 vi = vi + 1