Skip to main content

Ocean Gen Config

Based on game build 714014 | Last updated: 2026-02-27

Overview

This module defines a static configuration table watergen used during ocean terrain generation. It specifies parameters for depth-based water tiling, noise-based feature placement (e.g., coral, shipwrecks), elevation thresholds, and Gaussian blur settings for smooth transitions between ocean tile types. The configuration drives procedural ocean generation by controlling how raw heightmaps are interpreted and transformed into playable ocean tiles.

Usage example

This file is a pure configuration module and is not instantiated as a component. It is returned as a table and typically imported by ocean generation scripts (e.g., ocean_gen.lua) to apply consistent rules for terrain generation.

local watergen = require "map/ocean_gen_config"

-- Example: Access a configuration value
local coral_threshold = watergen.init_level_coral

-- Example: Iterate elevation levels for custom logic
for _, ellevel in ipairs(watergen.ellevels) do
local tile = ellevel[1]
local elevation = ellevel[2]
print(tile .. " has elevation threshold " .. tostring(elevation))
end

Dependencies & tags

Components used: None identified.
Tags: None identified.

Properties

PropertyTypeDefault ValueDescription
depthShallownumber2Minimum depth for shallow water tile assignment.
depthMednumber0Minimum depth for medium water tile assignment.
fillDepthnumber4Depth used for prefilling ocean tiles; increasing may impact performance.
fillOffsetnumber8Offset used in fill calculations (likely related to terrain padding).
shallowRadiusnumber4Radius (in tiles) for square-fill around shallow water features.
mediumRadiusnumber0Radius for square-fill around medium water features.
ocean_prefill_setpieces_min_land_distnumber5Minimum distance between landmass and ocean setpieces; must not be less than shallowRadius.
noise_octave_waternumber6Number of octaves for water height noise.
noise_octave_coralnumber4Number of octaves for coral distribution noise.
noise_octave_gravenumber4Number of octaves for shipgrave (shipwreck) placement noise.
noise_persistence_waternumber0.5Persistence (amplitude decay per octave) for water height noise.
noise_persistance_coralnumber0.5Persistence for coral noise. Note: Typo in key name (persistance vs persistence) is preserved.
noise_persistance_gravenumber0.5Persistence for shipgrave noise.
noise_scale_waternumber3Scale (frequency) for water height noise — higher values yield smaller patches.
noise_scale_coralnumber6Scale for coral noise.
noise_scale_gravenumber18Scale for shipgrave noise.
init_level_coralnumber0.65Threshold: noise value greater than this → coral tiles.
init_level_mediumnumber0.55Threshold: noise value greater than this → medium depth tiles.
init_level_gravenumber0.65Threshold: noise value greater than this → shipgrave tiles.
kernelSizenumber15Size (radius + 1) of the Gaussian blur kernel.
sigmanumber3.0Standard deviation for Gaussian blur smoothing.
ellevelstable见下文List of {tile_type, elevation_threshold} pairs used to construct the grayscale elevation map before blurring.

ellevels

An array of {WORLD_TILES.X, elevation} entries. Only active entries (uncommented) define elevation weights:

EntryElevationDescription
{WORLD_TILES.OCEAN_BRINEPOOL, 1.0}1.0Brine pool tile marked highest elevation (white).
{WORLD_TILES.OCEAN_COASTAL, 0.9}0.9Coastal ocean tile.
{WORLD_TILES.OCEAN_SWELL, 0.4}0.4Swell ocean tile.
{WORLD_TILES.OCEAN_ROUGH, 0.0}0.0Rough ocean tile (black).
{WORLD_TILES.OCEAN_HAZARDOUS, 0.0}0.0Hazardous ocean tile.
{WORLD_TILES.IMPASSABLE, 0.0}0.0Impassable terrain (non-ocean, excluded from water generation).

Main functions

None. This module returns a static configuration table and exports no functions.

Events & listeners

None.