## Writes a top-down map of an island: band colours with hillshading and a contour line ## at each tide phase's sea level. For eyeballing worldgen, not for the game. ## ## tools/godot.sh --script res://tools/island_map.gd -- --seed=N --out=path.png extends SceneTree const COLOURS: Dictionary = { Island.Band.SEA: Color(0.16, 0.29, 0.36), Island.Band.BEACH: Color(0.82, 0.74, 0.55), Island.Band.MARSH: Color(0.42, 0.47, 0.30), Island.Band.FOREST: Color(0.27, 0.40, 0.22), Island.Band.HIGHLAND: Color(0.50, 0.46, 0.38), Island.Band.SUMMIT: Color(0.80, 0.78, 0.74), } func _init() -> void: var seed_value: int = 1 var out: String = "res://captures/island.png" for arg: String in OS.get_cmdline_user_args(): if arg.begins_with("--seed="): seed_value = arg.get_slice("=", 1).to_int() elif arg.begins_with("--out="): out = arg.get_slice("=", 1) var island: Island = Island.generate(seed_value) var ground: SimGround = island.ground var side: int = ground.samples var image: Image = Image.create(side, side, false, Image.FORMAT_RGB8) var light: Vector3 = Vector3(-1.0, 1.4, -1.0).normalized() for gz: int in side: for gx: int in side: var x: float = gx * ground.cell var z: float = gz * ground.cell var height: float = ground.heights[gz * side + gx] var colour: Color = COLOURS[island.bands[gz * side + gx]] if height > 0.0: var shade: float = clampf(ground.terrain_normal(x, z).dot(light), 0.0, 1.0) colour = colour * (0.55 + 0.6 * shade) for phase: Dictionary in Tuning.TIDE_PHASES: if absf(height - float(phase["level"])) < 0.25: colour = colour.darkened(0.45) else: colour = colour.lightened(clampf((height + 3.0) / 3.0, 0.0, 0.5)) image.set_pixel(gx, gz, colour) DirAccess.make_dir_recursive_absolute(ProjectSettings.globalize_path(out).get_base_dir()) image.save_png(out) print("seed %d -> %s, max %.1f m, %d summits, hash %s" % [ seed_value, out, island.max_height(), island.summits.size(), island.heightmap_hash()]) quit()