Rework biome generation according to tectonic
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
// renders the world generator to png files, for tuning it without starting the game:
|
||||
// deno run -A tools/worldgen_preview.ts [seed] [out dir]
|
||||
// deno run -A tools/worldgen_preview.ts [seed] [out dir] [x z, the middle, in chunks]
|
||||
// map.png: 4096 blocks across from the terrain's heights and biomes (fast, no caves or 3d noise)
|
||||
// blocks.png: 768 blocks across from real generated chunks, top block with hill shading
|
||||
// section.png: a slice down through the world along x, showing caves, overhangs and islands
|
||||
// section.png: a slice down through the world along x, showing caves, overhangs and underground rivers
|
||||
import { CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE, SEA_LEVEL } from "$/common/constants.ts";
|
||||
import { generate_raw_chunk } from "$/common/generation.ts";
|
||||
import { OverworldTerrain } from "$/common/worldgen/terrain.ts";
|
||||
@@ -10,6 +10,7 @@ import { pick_biome } from "$/common/worldgen/overworld.ts";
|
||||
|
||||
const seed = Deno.args[0] ?? "preview";
|
||||
const out = Deno.args[1] ?? ".";
|
||||
const [center_x, center_z] = [Number(Deno.args[2] ?? 0), Number(Deno.args[3] ?? 0)];
|
||||
|
||||
const NAMES = [
|
||||
"bworld:stone",
|
||||
@@ -67,17 +68,10 @@ const BIOME_COLORS: Record<string, [number, number, number]> = {
|
||||
"bworld:savanna": [190, 180, 90],
|
||||
"bworld:jungle": [40, 160, 40],
|
||||
"bworld:desert": [240, 215, 140],
|
||||
"bworld:alpine_highlands": [120, 150, 110],
|
||||
"bworld:snowy_slopes": [220, 230, 240],
|
||||
"bworld:stony_peaks": [150, 145, 140],
|
||||
"bworld:jagged_peaks": [200, 200, 215],
|
||||
"bworld:frozen_peaks": [210, 225, 250],
|
||||
"bworld:yosemite_cliffs": [120, 120, 90],
|
||||
"bworld:snowy_cliffs": [200, 205, 210],
|
||||
"bworld:painted_mountains": [200, 120, 70],
|
||||
"bworld:stony_spires": [110, 120, 100],
|
||||
"bworld:shattered_savanna": [170, 150, 80],
|
||||
"bworld:skylands": [255, 120, 220],
|
||||
};
|
||||
|
||||
async function write_png(path: string, width: number, height: number, rgb: Uint8Array) {
|
||||
@@ -140,14 +134,13 @@ const shade = (color: [number, number, number], factor: number): [number, number
|
||||
const started = performance.now();
|
||||
for (let pz = 0; pz < size; pz++) {
|
||||
for (let px = 0; px < size; px++) {
|
||||
const x = (px - size / 2) * step;
|
||||
const z = (pz - size / 2) * step;
|
||||
const x = (px - size / 2) * step + center_x * CHUNK_SIZE;
|
||||
const z = (pz - size / 2) * step + center_z * CHUNK_SIZE;
|
||||
const column = terrain.column(x, z);
|
||||
heights[pz * size + px] = column.height;
|
||||
const surface = Math.round(column.height);
|
||||
const biome = pick_biome(column, surface, false);
|
||||
let color = BIOME_COLORS[biome] ?? [255, 0, 255];
|
||||
if (column.island) color = [255, 120, 220];
|
||||
const color = BIOME_COLORS[biome] ?? [255, 0, 255];
|
||||
rgb.set(color, (pz * size + px) * 3);
|
||||
}
|
||||
}
|
||||
@@ -181,8 +174,8 @@ const shade = (color: [number, number, number], factor: number): [number, number
|
||||
const started = performance.now();
|
||||
for (let cz = 0; cz < chunks; cz++) {
|
||||
for (let cx = 0; cx < chunks; cx++) {
|
||||
const chunk_x = origin / CHUNK_SIZE + cx;
|
||||
const chunk_z = origin / CHUNK_SIZE + cz;
|
||||
const chunk_x = origin / CHUNK_SIZE + cx + center_x;
|
||||
const chunk_z = origin / CHUNK_SIZE + cz + center_z;
|
||||
const { blocks } = generate_raw_chunk(chunk_x, chunk_z, seed, block_ids);
|
||||
for (let lz = 0; lz < CHUNK_SIZE; lz++) {
|
||||
for (let lx = 0; lx < CHUNK_SIZE; lx++) {
|
||||
|
||||
Reference in New Issue
Block a user