mirror of
https://github.com/minetest/minetest.git
synced 2024-11-04 14:53:45 +01:00
Stratum ore: Allow use with no noise for simple horizontal strata
If either of the 2 noise parameters are omitted the ore will occur from y_min to y_max in a simple horizontal stratum. As this does not compute noise performance improves, and is ideal for placing many layers. Clean up some nearby ore documentation.
This commit is contained in:
parent
9fa78b7387
commit
e2afcf85ce
@ -1098,12 +1098,17 @@ Creates a deformed sphere of ore according to 3d perlin noise described by
|
|||||||
### `vein`
|
### `vein`
|
||||||
Creates veins of ore varying in density by according to the intersection of two
|
Creates veins of ore varying in density by according to the intersection of two
|
||||||
instances of 3d perlin noise with diffferent seeds, both described by
|
instances of 3d perlin noise with diffferent seeds, both described by
|
||||||
`noise_params`. `random_factor` varies the influence random chance has on
|
`noise_params`.
|
||||||
placement of an ore inside the vein, which is `1` by default. Note that
|
|
||||||
modifying this parameter may require adjusting `noise_threshold`.
|
`random_factor` varies the influence random chance has on placement of an ore
|
||||||
|
inside the vein, which is `1` by default. Note that modifying this parameter may
|
||||||
|
require adjusting `noise_threshold`.
|
||||||
|
|
||||||
The parameters `clust_scarcity`, `clust_num_ores`, and `clust_size` are ignored
|
The parameters `clust_scarcity`, `clust_num_ores`, and `clust_size` are ignored
|
||||||
by this ore type. This ore type is difficult to control since it is sensitive
|
by this ore type.
|
||||||
to small changes. The following is a decent set of parameters to work from:
|
|
||||||
|
This ore type is difficult to control since it is sensitive to small changes.
|
||||||
|
The following is a decent set of parameters to work from:
|
||||||
|
|
||||||
noise_params = {
|
noise_params = {
|
||||||
offset = 0,
|
offset = 0,
|
||||||
@ -1122,16 +1127,24 @@ computationally expensive than any other ore.
|
|||||||
### `stratum`
|
### `stratum`
|
||||||
Creates a single undulating ore stratum that is continuous across mapchunk
|
Creates a single undulating ore stratum that is continuous across mapchunk
|
||||||
borders and horizontally spans the world.
|
borders and horizontally spans the world.
|
||||||
|
|
||||||
The 2D perlin noise described by `noise_params` varies the Y co-ordinate of the
|
The 2D perlin noise described by `noise_params` varies the Y co-ordinate of the
|
||||||
stratum midpoint. The 2D perlin noise described by `np_stratum_thickness`
|
stratum midpoint. The 2D perlin noise described by `np_stratum_thickness`
|
||||||
varies the stratum's vertical thickness (in units of nodes). Due to being
|
varies the stratum's vertical thickness (in units of nodes). Due to being
|
||||||
continuous across mapchunk borders the stratum's vertical thickness is
|
continuous across mapchunk borders the stratum's vertical thickness is
|
||||||
unlimited.
|
unlimited.
|
||||||
|
|
||||||
`y_min` and `y_max` define the limits of the ore generation and for performance
|
`y_min` and `y_max` define the limits of the ore generation and for performance
|
||||||
reasons should be set as close together as possible but without clipping the
|
reasons should be set as close together as possible but without clipping the
|
||||||
stratum's Y variation.
|
stratum's Y variation.
|
||||||
|
|
||||||
|
If either of the 2 noise parameters are omitted the ore will occur from y_min
|
||||||
|
to y_max in a simple horizontal stratum. As this does not compute noise
|
||||||
|
performance improves, and is ideal for placing many layers.
|
||||||
|
|
||||||
Each node in the stratum has a 1-in-`clust_scarcity` chance of being ore, so a
|
Each node in the stratum has a 1-in-`clust_scarcity` chance of being ore, so a
|
||||||
solid-ore stratum would require a `clust_scarcity` of 1.
|
solid-ore stratum would require a `clust_scarcity` of 1.
|
||||||
|
|
||||||
The parameters `clust_num_ores`, `clust_size`, `noise_threshold` and
|
The parameters `clust_num_ores`, `clust_size`, `noise_threshold` and
|
||||||
`random_factor` are ignored by this ore type.
|
`random_factor` are ignored by this ore type.
|
||||||
|
|
||||||
@ -4713,24 +4726,36 @@ Definition tables
|
|||||||
-- ^ Number of ores in a cluster
|
-- ^ Number of ores in a cluster
|
||||||
clust_size = 3,
|
clust_size = 3,
|
||||||
-- ^ Size of the bounding box of the cluster
|
-- ^ Size of the bounding box of the cluster
|
||||||
-- ^ In this example, there is a 3x3x3 cluster where 8 out of the 27 nodes are coal ore
|
-- ^ In this example, there is a 3x3x3 cluster where 8 out of the 27 nodes
|
||||||
|
-- ^ are coal ore.
|
||||||
y_min = -31000,
|
y_min = -31000,
|
||||||
y_max = 64,
|
y_max = 64,
|
||||||
-- ^ Lower and upper limits for ore.
|
-- ^ Lower and upper limits for ore.
|
||||||
flags = "",
|
flags = "",
|
||||||
-- ^ Attributes for this ore generation
|
-- ^ Attributes for this ore generation
|
||||||
noise_threshold = 0.5,
|
noise_threshold = 0.5,
|
||||||
-- ^ If noise is above this threshold, ore is placed. Not needed for a uniform distribution
|
-- ^ If noise is above this threshold, ore is placed. Not needed for a
|
||||||
noise_params = {offset=0, scale=1, spread={x=100, y=100, z=100}, seed=23, octaves=3, persist=0.70}
|
-- ^ uniform distribution.
|
||||||
-- ^ NoiseParams structure describing the perlin noise used for ore distribution.
|
noise_params = {
|
||||||
-- ^ Needed for sheet ore_type. Omit from scatter ore_type for a uniform ore distribution
|
offset = 0,
|
||||||
|
scale = 1,
|
||||||
|
spread = {x = 100, y = 100, z = 100},
|
||||||
|
seed = 23,
|
||||||
|
octaves = 3,
|
||||||
|
persist = 0.7
|
||||||
|
},
|
||||||
|
-- ^ NoiseParams structure describing one of the perlin noises used for ore
|
||||||
|
-- ^ distribution.
|
||||||
|
-- ^ Omit from "scatter" ore for a uniform ore distribution.
|
||||||
|
-- ^ Omit from "stratum ore for a simple horizontal strata from y_min to y_max.
|
||||||
random_factor = 1.0,
|
random_factor = 1.0,
|
||||||
-- ^ Multiplier of the randomness contribution to the noise value at any
|
-- ^ Multiplier of the randomness contribution to the noise value at any
|
||||||
-- ^ given point to decide if ore should be placed. Set to 0 for solid veins.
|
-- ^ given point to decide if ore should be placed. Set to 0 for solid veins.
|
||||||
-- ^ This parameter is only valid for ore_type == "vein".
|
-- ^ This parameter is only valid for ore_type == "vein".
|
||||||
biomes = {"desert", "rainforest"}
|
biomes = {"desert", "rainforest"}
|
||||||
-- ^ List of biomes in which this decoration occurs. Occurs in all biomes if this is omitted,
|
-- ^ List of biomes in which this decoration occurs.
|
||||||
-- ^ and ignored if the Mapgen being used does not support biomes.
|
-- ^ Occurs in all biomes if this is omitted, and ignored if the Mapgen being
|
||||||
|
-- ^ used does not support biomes.
|
||||||
-- ^ Can be a list of (or a single) biome names, IDs, or definitions.
|
-- ^ Can be a list of (or a single) biome names, IDs, or definitions.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,7 +433,8 @@ void OreStratum::generate(MMVManip *vm, int mapseed, u32 blockseed,
|
|||||||
PcgRandom pr(blockseed + 4234);
|
PcgRandom pr(blockseed + 4234);
|
||||||
MapNode n_ore(c_ore, 0, ore_param2);
|
MapNode n_ore(c_ore, 0, ore_param2);
|
||||||
|
|
||||||
if (!noise) {
|
if (flags & OREFLAG_USE_NOISE) {
|
||||||
|
if (!(noise && noise_stratum_thickness)) {
|
||||||
int sx = nmax.X - nmin.X + 1;
|
int sx = nmax.X - nmin.X + 1;
|
||||||
int sz = nmax.Z - nmin.Z + 1;
|
int sz = nmax.Z - nmin.Z + 1;
|
||||||
noise = new Noise(&np, 0, sx, sz);
|
noise = new Noise(&np, 0, sx, sz);
|
||||||
@ -441,6 +442,7 @@ void OreStratum::generate(MMVManip *vm, int mapseed, u32 blockseed,
|
|||||||
}
|
}
|
||||||
noise->perlinMap2D(nmin.X, nmin.Z);
|
noise->perlinMap2D(nmin.X, nmin.Z);
|
||||||
noise_stratum_thickness->perlinMap2D(nmin.X, nmin.Z);
|
noise_stratum_thickness->perlinMap2D(nmin.X, nmin.Z);
|
||||||
|
}
|
||||||
|
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
|
|
||||||
@ -452,10 +454,18 @@ void OreStratum::generate(MMVManip *vm, int mapseed, u32 blockseed,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int y0;
|
||||||
|
int y1;
|
||||||
|
|
||||||
|
if (flags & OREFLAG_USE_NOISE) {
|
||||||
float nmid = noise->result[index];
|
float nmid = noise->result[index];
|
||||||
float nhalfthick = noise_stratum_thickness->result[index] / 2.0f;
|
float nhalfthick = noise_stratum_thickness->result[index] / 2.0f;
|
||||||
int y0 = MYMAX(nmin.Y, nmid - nhalfthick);
|
y0 = MYMAX(nmin.Y, nmid - nhalfthick);
|
||||||
int y1 = MYMIN(nmax.Y, nmid + nhalfthick);
|
y1 = MYMIN(nmax.Y, nmid + nhalfthick);
|
||||||
|
} else {
|
||||||
|
y0 = nmin.Y;
|
||||||
|
y1 = nmax.Y;
|
||||||
|
}
|
||||||
|
|
||||||
for (int y = y0; y <= y1; y++) {
|
for (int y = y0; y <= y1; y++) {
|
||||||
if (pr.range(1, clust_scarcity) != 1)
|
if (pr.range(1, clust_scarcity) != 1)
|
||||||
|
@ -135,7 +135,7 @@ public:
|
|||||||
|
|
||||||
class OreStratum : public Ore {
|
class OreStratum : public Ore {
|
||||||
public:
|
public:
|
||||||
static const bool NEEDS_NOISE = true;
|
static const bool NEEDS_NOISE = false;
|
||||||
|
|
||||||
NoiseParams np_stratum_thickness;
|
NoiseParams np_stratum_thickness;
|
||||||
Noise *noise_stratum_thickness = nullptr;
|
Noise *noise_stratum_thickness = nullptr;
|
||||||
|
@ -1156,7 +1156,9 @@ int ModApiMapgen::l_register_ore(lua_State *L)
|
|||||||
OreStratum *orestratum = (OreStratum *)ore;
|
OreStratum *orestratum = (OreStratum *)ore;
|
||||||
|
|
||||||
lua_getfield(L, index, "np_stratum_thickness");
|
lua_getfield(L, index, "np_stratum_thickness");
|
||||||
read_noiseparams(L, -1, &orestratum->np_stratum_thickness);
|
// If thickness noise missing unset 'use noise' flag
|
||||||
|
if (!read_noiseparams(L, -1, &orestratum->np_stratum_thickness))
|
||||||
|
ore->flags &= ~OREFLAG_USE_NOISE;
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user