Noise varied density of grass, cacti. Corrected pinewood texture. WIP ores in strata. 3D temperature noise
This commit is contained in:
parent
dba27370d3
commit
2a07a46997
@ -1,4 +1,4 @@
|
|||||||
riverdev 0.5.9 by paramat
|
riverdev 0.6.0 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
|
||||||
|
87
init.lua
87
init.lua
@ -1,15 +1,14 @@
|
|||||||
-- riverdev 0.5.9 by paramat
|
-- riverdev 0.6.0 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
|
||||||
|
|
||||||
-- improve strata
|
-- WIP ores in strata
|
||||||
|
-- noise varied density of grass, cacti
|
||||||
|
-- 3d temperature noise
|
||||||
-- TODO
|
-- TODO
|
||||||
-- regeneration command: use of mapgen loop function
|
-- regeneration command: use of mapgen loop function
|
||||||
-- coloured stone: desertstone orange sandstone green blue violet
|
-- coloured stone: desertstone orange sandstone green blue violet
|
||||||
-- inclined strata with 3d biomes of coloured stone mixes
|
|
||||||
-- ores in strata
|
|
||||||
-- dry long grass to replace dry shrub
|
|
||||||
|
|
||||||
-- Parameters
|
-- Parameters
|
||||||
|
|
||||||
@ -24,7 +23,7 @@ local TERSCA = 512 -- Terrain vertical scale in nodes
|
|||||||
local BASAMP = 0.3 -- Base amplitude relative to 3D noise amplitude. Ridge network structure
|
local BASAMP = 0.3 -- Base amplitude relative to 3D noise amplitude. Ridge network structure
|
||||||
local MIDAMP = 0.05 -- Mid amplitude relative to 3D noise amplitude. River valley structure
|
local MIDAMP = 0.05 -- Mid amplitude relative to 3D noise amplitude. River valley structure
|
||||||
|
|
||||||
local TSTONE = 0.015 -- Depth of stone under surface
|
local TSTONE = 0.02 -- Maximum depth of stone under surface
|
||||||
local TRIVER = -0.018 -- River depth
|
local TRIVER = -0.018 -- River depth
|
||||||
local TRSAND = -0.02 -- Depth of river sand
|
local TRSAND = -0.02 -- Depth of river sand
|
||||||
local TPFLO = 0.02 -- Width of flora clearing around paths
|
local TPFLO = 0.02 -- Width of flora clearing around paths
|
||||||
@ -40,11 +39,11 @@ local ORECHA = 1 / 5 ^ 3 -- Ore chance per stone node
|
|||||||
local BOLCHA = 1 / 128 ^ 2 -- Boulder chance per surfacenode
|
local BOLCHA = 1 / 128 ^ 2 -- Boulder chance per surfacenode
|
||||||
local FLOCHA = 1 / 48 ^ 2 -- Flower ^
|
local FLOCHA = 1 / 48 ^ 2 -- Flower ^
|
||||||
local JUNCHA = 1 / 4 ^ 2 -- Jungletree ^
|
local JUNCHA = 1 / 4 ^ 2 -- Jungletree ^
|
||||||
local CACCHA = 1 / 128 ^ 2 -- Cactus ^
|
|
||||||
local GRACHA = 1 / 2 ^ 2 -- Grasses ^
|
|
||||||
local APPCHA = 1 / 5 ^ 2 -- Appletree maximum chance per surface node
|
local APPCHA = 1 / 5 ^ 2 -- Appletree maximum chance per surface node
|
||||||
local PINCHA = 1 / 6 ^ 2 -- Pinetree ^
|
local PINCHA = 1 / 6 ^ 2 -- Pinetree ^
|
||||||
local ACACHA = 1 / 64 ^ 2 -- Acaciatree ^
|
local ACACHA = 1 / 64 ^ 2 -- Acaciatree ^
|
||||||
|
local CACCHA = 1 / 128 ^ 2 -- Cactus ^
|
||||||
|
local GRACHA = 1 / 2 ^ 2 -- Grasses ^
|
||||||
|
|
||||||
local LOTET = -0.4 -- Low temperature threshold
|
local LOTET = -0.4 -- Low temperature threshold
|
||||||
local HITET = 0.4 -- High ^
|
local HITET = 0.4 -- High ^
|
||||||
@ -73,17 +72,6 @@ local np_base = {
|
|||||||
persist = 0.33
|
persist = 0.33
|
||||||
}
|
}
|
||||||
|
|
||||||
-- 2D noise for temperature
|
|
||||||
|
|
||||||
local np_temp = {
|
|
||||||
offset = 0,
|
|
||||||
scale = 1,
|
|
||||||
spread = {x=3072, y=3072, z=3072},
|
|
||||||
seed = 18882,
|
|
||||||
octaves = 3,
|
|
||||||
persist = 0.4
|
|
||||||
}
|
|
||||||
|
|
||||||
-- 2D noises for patha / top terrain
|
-- 2D noises for patha / top terrain
|
||||||
|
|
||||||
local np_patha = {
|
local np_patha = {
|
||||||
@ -128,17 +116,28 @@ local np_grass = {
|
|||||||
persist = 0.7
|
persist = 0.7
|
||||||
}
|
}
|
||||||
|
|
||||||
-- 3D noise for highland terrain
|
-- 3D noise for highland/floatland terrain
|
||||||
|
|
||||||
local np_terrain = {
|
local np_terrain = {
|
||||||
offset = 0,
|
offset = 0,
|
||||||
scale = 1,
|
scale = 1,
|
||||||
spread = {x=192, y=192, z=192},
|
spread = {x=384, y=192, z=384},
|
||||||
seed = 5900033,
|
seed = 5900033,
|
||||||
octaves = 4,
|
octaves = 5,
|
||||||
persist = 0.67
|
persist = 0.67
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- 3D noise for temperature
|
||||||
|
|
||||||
|
local np_temp = {
|
||||||
|
offset = 0,
|
||||||
|
scale = 1,
|
||||||
|
spread = {x=3072, y=3072, z=3072},
|
||||||
|
seed = 18882,
|
||||||
|
octaves = 3,
|
||||||
|
persist = 0.4
|
||||||
|
}
|
||||||
|
|
||||||
-- 3D noises for tunnels
|
-- 3D noises for tunnels
|
||||||
|
|
||||||
local np_weba = {
|
local np_weba = {
|
||||||
@ -195,7 +194,7 @@ local np_fissure = {
|
|||||||
local np_strata = {
|
local np_strata = {
|
||||||
offset = 0,
|
offset = 0,
|
||||||
scale = 1,
|
scale = 1,
|
||||||
spread = {x=768, y=16, z=768},
|
spread = {x=3072, y=48, z=3072},
|
||||||
seed = 92219,
|
seed = 92219,
|
||||||
octaves = 4,
|
octaves = 4,
|
||||||
persist = 1
|
persist = 1
|
||||||
@ -281,12 +280,12 @@ local function riverdev_surface(x, y, z, area, data, y1, vi, viu,
|
|||||||
data[viu] = c_grass
|
data[viu] = c_grass
|
||||||
if math.random() < FLOCHA then
|
if math.random() < FLOCHA then
|
||||||
riverdev_flower(data, vi)
|
riverdev_flower(data, vi)
|
||||||
elseif math.random() < GRACHA and n_grass > 0.6 then
|
elseif math.random() < GRACHA * n_grass then
|
||||||
data[vi] = c_grass5
|
data[vi] = c_grass5
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif under[si] == 5 then -- desert
|
elseif under[si] == 5 then -- desert
|
||||||
if math.random() < CACCHA then
|
if math.random() < CACCHA * n_tree then
|
||||||
riverdev_cactus(x, y, z, area, data)
|
riverdev_cactus(x, y, z, area, data)
|
||||||
end
|
end
|
||||||
elseif under[si] == 6 then -- savanna
|
elseif under[si] == 6 then -- savanna
|
||||||
@ -380,6 +379,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
local minposxz = {x=x0-1, y=z0-1}
|
local minposxz = {x=x0-1, y=z0-1}
|
||||||
|
|
||||||
local nvals_terrain = minetest.get_perlin_map(np_terrain, chulensxyz):get3dMap_flat(minposxyz)
|
local nvals_terrain = minetest.get_perlin_map(np_terrain, chulensxyz):get3dMap_flat(minposxyz)
|
||||||
|
local nvals_temp = minetest.get_perlin_map(np_temp, chulensxyz):get3dMap_flat(minposxyz)
|
||||||
local nvals_weba = minetest.get_perlin_map(np_weba, chulensxyz):get3dMap_flat(minposxyz)
|
local nvals_weba = minetest.get_perlin_map(np_weba, chulensxyz):get3dMap_flat(minposxyz)
|
||||||
local nvals_webb = minetest.get_perlin_map(np_webb, chulensxyz):get3dMap_flat(minposxyz)
|
local nvals_webb = minetest.get_perlin_map(np_webb, chulensxyz):get3dMap_flat(minposxyz)
|
||||||
local nvals_webc = minetest.get_perlin_map(np_webc, chulensxyz):get3dMap_flat(minposxyz)
|
local nvals_webc = minetest.get_perlin_map(np_webc, chulensxyz):get3dMap_flat(minposxyz)
|
||||||
@ -392,7 +392,6 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
local nvals_humid = minetest.get_perlin_map(np_base, chulensxz):get2dMap_flat({x=x0-1, y=z0+383})
|
local nvals_humid = minetest.get_perlin_map(np_base, chulensxz):get2dMap_flat({x=x0-1, y=z0+383})
|
||||||
local nvals_patha = minetest.get_perlin_map(np_patha, chulensxz):get2dMap_flat(minposxz)
|
local nvals_patha = minetest.get_perlin_map(np_patha, chulensxz):get2dMap_flat(minposxz)
|
||||||
local nvals_pathb = minetest.get_perlin_map(np_pathb, chulensxz):get2dMap_flat(minposxz)
|
local nvals_pathb = minetest.get_perlin_map(np_pathb, chulensxz):get2dMap_flat(minposxz)
|
||||||
local nvals_temp = minetest.get_perlin_map(np_temp, chulensxz):get2dMap_flat(minposxz)
|
|
||||||
local nvals_tree = minetest.get_perlin_map(np_tree, chulensxz):get2dMap_flat(minposxz)
|
local nvals_tree = minetest.get_perlin_map(np_tree, chulensxz):get2dMap_flat(minposxz)
|
||||||
local nvals_grass = minetest.get_perlin_map(np_grass, chulensxz):get2dMap_flat(minposxz)
|
local nvals_grass = minetest.get_perlin_map(np_grass, chulensxz):get2dMap_flat(minposxz)
|
||||||
|
|
||||||
@ -444,16 +443,16 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
local grad = (YTER - y) / TERSCA -- noise gradient
|
local grad = (YTER - y) / TERSCA -- noise gradient
|
||||||
local densitybase = n_invbase * BASAMP + grad -- ridge surface
|
local densitybase = n_invbase * BASAMP + grad -- ridge surface
|
||||||
local densitymid = n_absmid * MIDAMP + densitybase -- river valley surface
|
local densitymid = n_absmid * MIDAMP + densitybase -- river valley surface
|
||||||
local density =
|
local density = -- actual surface
|
||||||
n_terrain * n_invbase * n_absmid * n_abspatha ^ 1.5 * n_abspathb ^ 1.5
|
n_terrain * n_invbase * n_absmid * n_abspatha ^ 1.5 * n_abspathb ^ 1.5
|
||||||
+ densitymid -- actual surface
|
+ densitymid
|
||||||
|
|
||||||
local n_tree = math.min(math.max(nvals_tree[nixz], 0), 1)
|
local n_tree = math.min(math.max(nvals_tree[nixz], 0), 1)
|
||||||
local n_grass = math.abs(nvals_grass[nixz])
|
local n_grass = math.min(math.max(nvals_grass[nixz], 0), 1)
|
||||||
local n_strata = nvals_strata[nixyz]
|
local n_strata = math.abs(nvals_strata[nixyz])
|
||||||
local n_temp = nvals_temp[nixz]
|
local n_temp = nvals_temp[nixyz]
|
||||||
local n_humid = math.abs(nvals_humid[nixz]) - n_absmid * 0.5 + 0.5
|
local n_humid = math.abs(nvals_humid[nixz]) - n_absmid * 0.5 + 0.5
|
||||||
local tstone = TSTONE * (1 + grad * 2)
|
local tstone = math.max(TSTONE * (1 + grad * 2), 0)
|
||||||
local triver = TRIVER * n_absbase
|
local triver = TRIVER * n_absbase
|
||||||
local trsand = TRSAND * n_absbase
|
local trsand = TRSAND * n_absbase
|
||||||
local wood = densitybase > trsand * 2 and density < 0
|
local wood = densitybase > trsand * 2 and density < 0
|
||||||
@ -518,13 +517,11 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
under[si] = 0
|
under[si] = 0
|
||||||
end
|
end
|
||||||
elseif density >= tstone and (novoid
|
elseif density >= tstone and (novoid
|
||||||
or (density < tstone * 1.5
|
or (density < tstone * 1.5 and (y <= YWATER or densitybase >= triver))) then
|
||||||
and (y <= YWATER or densitybase >= triver))) then
|
if n_strata < 0.2 then -- sandstone strata
|
||||||
if math.abs(n_strata) < 0.2 then
|
data[vi] = c_sandstone
|
||||||
data[vi] = c_sandstone -- redstone layer
|
elseif n_strata > 0.3 and n_strata < 0.35 -- ores
|
||||||
elseif biome == 5 then
|
and density > TSTONE then
|
||||||
data[vi] = c_redstone -- redstone layer
|
|
||||||
elseif math.random() < ORECHA and density > TSTONE then -- ores
|
|
||||||
local osel = math.random(24)
|
local osel = math.random(24)
|
||||||
if osel == 24 then
|
if osel == 24 then
|
||||||
data[vi] = c_stodiam
|
data[vi] = c_stodiam
|
||||||
@ -539,6 +536,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
else
|
else
|
||||||
data[vi] = c_stocoal
|
data[vi] = c_stocoal
|
||||||
end
|
end
|
||||||
|
elseif biome == 5 then
|
||||||
|
data[vi] = c_redstone -- redstone layer
|
||||||
else
|
else
|
||||||
data[vi] = c_stone -- stone
|
data[vi] = c_stone -- stone
|
||||||
end
|
end
|
||||||
@ -596,9 +595,10 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
end
|
end
|
||||||
stable[si] = 0
|
stable[si] = 0
|
||||||
under[si] = 0
|
under[si] = 0
|
||||||
elseif density < 0 and under[si] ~= 0 -- detect surface, place surface nodes
|
elseif density < 0 and y > YWATER
|
||||||
|
and under[si] ~= 0 -- detect surface, place surface nodes
|
||||||
and nodid ~= c_stone
|
and nodid ~= c_stone
|
||||||
and nodid ~= c_ice and nodidu ~= c_ice
|
and nodid ~= c_snow and nodidu ~= c_snow
|
||||||
and nodid ~= c_path and nodidu ~= c_path
|
and nodid ~= c_path and nodidu ~= c_path
|
||||||
and nodid ~= c_wood and nodidu ~= c_wood then
|
and nodid ~= c_wood and nodidu ~= c_wood then
|
||||||
|
|
||||||
@ -623,9 +623,10 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
riverdev_pathbrush(x, y, z, area, data,
|
riverdev_pathbrush(x, y, z, area, data,
|
||||||
y0, wood, emerlen, stable, under, si)
|
y0, wood, emerlen, stable, under, si)
|
||||||
|
|
||||||
elseif density < 0 and under[si] ~= 0 -- detect surface, place surface nodes
|
elseif density < 0 and y > YWATER
|
||||||
|
and under[si] ~= 0 -- detect surface, place surface nodes
|
||||||
and nodid ~= c_stone
|
and nodid ~= c_stone
|
||||||
and nodid ~= c_ice and nodidu ~= c_ice
|
and nodid ~= c_snow and nodidu ~= c_snow
|
||||||
and nodid ~= c_path and nodidu ~= c_path
|
and nodid ~= c_path and nodidu ~= c_path
|
||||||
and nodid ~= c_wood and nodidu ~= c_wood then
|
and nodid ~= c_wood and nodidu ~= c_wood then
|
||||||
|
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 366 B After Width: | Height: | Size: 455 B |
Loading…
x
Reference in New Issue
Block a user