hmm
This commit is contained in:
parent
112e6bf86b
commit
f2d0306d96
13 changed files with 1434 additions and 516 deletions
|
|
@ -1816,6 +1816,11 @@ export function generateInitialTerrainRect(seed, options = {}) {
|
|||
|
||||
|
||||
export function generateTerrainAndRivers(seed, options = {}) {
|
||||
const generationContext = options.generationContext || {};
|
||||
const originX = Math.floor(Number.isFinite(options.originX) ? options.originX : (Number.isFinite(generationContext.originX) ? generationContext.originX : 0));
|
||||
const originY = Math.floor(Number.isFinite(options.originY) ? options.originY : (Number.isFinite(generationContext.originY) ? generationContext.originY : 0));
|
||||
const variant = Math.max(0, Math.floor(Number.isFinite(options.variant) ? options.variant : (Number.isFinite(generationContext.variant) ? generationContext.variant : 0))) >>> 0;
|
||||
const worldNative = options.worldNative === true || generationContext.worldNative === true;
|
||||
const fields = createMapFields();
|
||||
fields.visibleRavineField = new Float32Array(SIZE);
|
||||
fields.surfaceTextureField = new Float32Array(SIZE);
|
||||
|
|
@ -1835,9 +1840,11 @@ export function generateTerrainAndRivers(seed, options = {}) {
|
|||
for (let y = 0; y < MAP_H; y++) {
|
||||
for (let x = 0; x < MAP_W; x++) {
|
||||
const i = indexOf(x, y);
|
||||
const wx = originX + x;
|
||||
const wy = originY + y;
|
||||
const { px, py } = normalizeCoord(x, y);
|
||||
const terrainLarge = (fbm(x * 0.65, y * 0.65, seed + 1) - 0.5) * 0.23;
|
||||
const terrainRegional = (valueNoise(x * 0.8, y * 0.8, seed + 2, 42) - 0.5) * 0.16;
|
||||
const terrainLarge = (fbm(wx * 0.65, wy * 0.65, seed + 1) - 0.5) * 0.23;
|
||||
const terrainRegional = (valueNoise(wx * 0.8, wy * 0.8, seed + 2, 42) - 0.5) * 0.16;
|
||||
const { pressure: coastPressure } = computeCoastLower(px, py, terrainTemplate, seed);
|
||||
let e = 0.42 + terrainLarge + terrainRegional - coastPressure * (terrainTemplate.coastStrength ?? 0.96) * (0.22 + terrainTemplate.deposition * 0.040);
|
||||
let mountainMaskMax = 0;
|
||||
|
|
@ -1862,7 +1869,7 @@ export function generateTerrainAndRivers(seed, options = {}) {
|
|||
const dx = (px - 0.5) * ASPECT;
|
||||
const dy = py - 0.5;
|
||||
const { u, v } = rotate(dx, dy, terrainTemplate.mountainAngle);
|
||||
const warp = (valueNoise(x * 0.50, y * 0.50, seed + 504, 28) - 0.5) * 18;
|
||||
const warp = (valueNoise(wx * 0.50, wy * 0.50, seed + 504, 28) - 0.5) * 18;
|
||||
macro = (fbm(u * 520 + warp, v * 1850 - warp * 0.35, seed + 500) - 0.5) * 2;
|
||||
scratch = (fbm(u * 920 + warp * 0.8, v * 2300 + warp * 0.25, seed + 502) - 0.5) * 2;
|
||||
const passBreak = clamp((valueNoise(u * 760 + 17, v * 1800 - 11, seed + 505, 18) - 0.62) * 2.6);
|
||||
|
|
@ -1870,10 +1877,10 @@ export function generateTerrainAndRivers(seed, options = {}) {
|
|||
e += lateralBranch * mountainMaskMax * 0.022;
|
||||
e -= passBreak * mountainMaskMax * 0.052;
|
||||
} else {
|
||||
macro = (fbm(x * terrainTemplate.macroNoiseScale * 48, y * terrainTemplate.macroNoiseScale * 48, seed + 500) - 0.5) * 2;
|
||||
scratch = (fbm(x * 2.2, y * 2.2, seed + 502) - 0.5) * 2;
|
||||
macro = (fbm(wx * terrainTemplate.macroNoiseScale * 48, wy * terrainTemplate.macroNoiseScale * 48, seed + 500) - 0.5) * 2;
|
||||
scratch = (fbm(wx * 2.2, wy * 2.2, seed + 502) - 0.5) * 2;
|
||||
}
|
||||
const global = (valueNoise(x * 0.23, y * 0.23, seed + 501, 38) - 0.5) * 2;
|
||||
const global = (valueNoise(wx * 0.23, wy * 0.23, seed + 501, 38) - 0.5) * 2;
|
||||
e += macro * terrainTemplate.macroNoiseStrength * (0.38 + mountainMaskMax * 0.80);
|
||||
e += global * 0.020;
|
||||
e += scratch * terrainTemplate.scratchNoiseStrength * mountainMaskMax;
|
||||
|
|
@ -1886,7 +1893,7 @@ export function generateTerrainAndRivers(seed, options = {}) {
|
|||
if (terrainTemplate.terrainType === "setouchi_inland_sea") {
|
||||
// Setouchi maps should have many low hills and island backbones rather
|
||||
// than a few high alpine ridges. Add broad low relief, then cap peaks.
|
||||
const lowHillNoise = clamp((fbm(x * 0.95 + 17, y * 0.95 - 23, seed + 571) - 0.38) * 2.9);
|
||||
const lowHillNoise = clamp((fbm(wx * 0.95 + 17, wy * 0.95 - 23, seed + 571) - 0.38) * 2.9);
|
||||
const lowHillMask = clamp(0.34 + mountainMaskMax * 0.72 + lowHillNoise * 0.50 - coastPressure * 0.12);
|
||||
e += lowHillMask * 0.145;
|
||||
// Do not add the previous fine speckle uplift here: it created too many
|
||||
|
|
@ -1897,7 +1904,7 @@ export function generateTerrainAndRivers(seed, options = {}) {
|
|||
}
|
||||
if (terrainTemplate.terrainType === "oceanic_archipelago") {
|
||||
// 海洋型は大きな山塊ではなく、島列を読むための低い起伏を点在させる。
|
||||
const islandCore = clamp((fbm(x * 0.82 + 41, y * 0.82 - 29, seed + 572) - 0.46) * 2.7);
|
||||
const islandCore = clamp((fbm(wx * 0.82 + 41, wy * 0.82 - 29, seed + 572) - 0.46) * 2.7);
|
||||
const islandChain = clamp(mountainMaskMax * 0.92 + islandCore * 0.54 - coastPressure * 0.24);
|
||||
e += islandChain * 0.135;
|
||||
e -= clamp((coastPressure - 0.38) * 1.55) * 0.040;
|
||||
|
|
@ -1910,7 +1917,7 @@ export function generateTerrainAndRivers(seed, options = {}) {
|
|||
visibleRavineField[i] = clamp(Math.abs(scratch) * mountainMaskMax * 0.30 + Math.max(0, -scratch) * mountainMaskMax * 0.40);
|
||||
surfaceTextureField[i] = clamp(Math.abs(macro) * 0.12 + Math.abs(scratch) * mountainMaskMax * 0.46);
|
||||
valleyField[i] = clamp(Math.max(0, -scratch) * mountainMaskMax * 0.18);
|
||||
moisture[i] = clamp(0.45 + coastPressure * 0.28 - elevation[i] * 0.20 + (fbm(x * 1.1, y * 1.1, seed + 503) - 0.5) * 0.16);
|
||||
moisture[i] = clamp(0.45 + coastPressure * 0.28 - elevation[i] * 0.20 + (fbm(wx * 1.1, wy * 1.1, seed + 503) - 0.5) * 0.16);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1972,9 +1979,20 @@ export function generateTerrainAndRivers(seed, options = {}) {
|
|||
mountainRatio: mountainCount / Math.max(1, landCount),
|
||||
plainRatio: plainCount / Math.max(1, landCount),
|
||||
mountainSystemCount: systems.length,
|
||||
originX,
|
||||
originY,
|
||||
width: MAP_W,
|
||||
height: MAP_H,
|
||||
variant,
|
||||
worldNative,
|
||||
};
|
||||
|
||||
return {
|
||||
originX,
|
||||
originY,
|
||||
width: MAP_W,
|
||||
height: MAP_H,
|
||||
generationContext: { ...generationContext, originX, originY, width: MAP_W, height: MAP_H, variant, worldNative },
|
||||
terrainTemplate,
|
||||
seaLevel,
|
||||
elevation,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue