Overview
Themath/ directory contains reusable mathematical functions and noise samplers used throughout the Origen configuration pack. These provide the mathematical foundation for terrain generation, biome distribution, and feature placement.
Directory Structure
Functions vs Samplers
Functions
Mathematical operations that transform input values
- Take arguments and return computed values
- Used for calculations and transformations
- Reusable across configs
Samplers
Noise generators that produce values for coordinates
- Generate values based on X, Y, Z positions
- Used for terrain, temperature, biomes, etc.
- Can reference functions and other samplers
Functions
Functions are defined inmath/functions/ and imported in pack.yml:
terrace.yml
Provides terracing functions for creating stepped terrain.View Full Configuration
View Full Configuration
reference
terrace(i, sc, o, g, d)
terrace(i, sc, o, g, d)
Basic terracing with sharp edges.Parameters:
i- Input value (usually elevation)sc- Scale (terrace height)o- Offset (shifts terraces vertically)g- Gap (spacing between terraces)d- Depth (terrace step height)
terraceStrata(i, sc, o, g, d)
terraceStrata(i, sc, o, g, d)
Terracing with layered strata appearance.Creates horizontal bands with smooth transitions, like sedimentary rock layers.Use case: Badlands strata, terracotta pillars
terraceParabolic(i, sc, o, g, d)
terraceParabolic(i, sc, o, g, d)
Terracing with parabolic (curved) steps.Smooth bowl-shaped terraces instead of sharp edges.Use case: Natural-looking stepped terrain
terraceParalinear(i, sc, o, g, d)
terraceParalinear(i, sc, o, g, d)
Hybrid between parabolic and linear terracing.Combines curved centers with flat edges.Use case: Mixed terrain styles
interpolation.yml
Provides interpolation functions for smooth transitions.lerp(t, a, b)
lerp(t, a, b)
Linear interpolation between two values.Parameters:
t- Interpolation factor (0-1)a- Start valueb- End value
herp(t, t1, v1, t2, v2)
herp(t, t1, v1, t2, v2)
Hermite interpolation with control points.Smooth curve between two points with zero derivative at endpoints.Use case: Smooth continental transitions, biome blending
smoothstep(edge0, edge1, x)
smoothstep(edge0, edge1, x)
Smooth step function with zero derivatives at edges.Returns 0 when x < edge0, 1 when x > edge1, smooth curve between.Use case: Smooth transitions, blending regions
maskSmooth.yml
Functions for masking and smoothing noise values.mask(value, threshold)
mask(value, threshold)
Binary masking - returns 0 or 1.
smoothMask(value, threshold, range)
smoothMask(value, threshold, range)
Smooth masking with transition zone.
clamp.yml
Value clamping and bounding functions.clamp(value, min, max)
clamp(value, min, max)
Constrains value to range.
clamp01(value)
clamp01(value)
Clamps to 0-1 range.
Samplers
Samplers are defined inmath/samplers/ and imported in pack.yml:
terrain.yml
Core terrain elevation samplers.View Full Configuration
View Full Configuration
reference
rawElevation(x, z)
rawElevation(x, z)
Base terrain noise before continental shaping.
- Uses ridged noise for mountainous terrain
- Cubed for more dramatic peaks
- Controlled by
elevation-scaleandglobal-scalein customization.yml
elevation(x, z)
elevation(x, z)
Final surface elevation for land.
- Combines rawElevation with continents sampler
- Applies river erosion
- Uses hermite interpolation for smooth transitions
- Primary sampler for terrain height
oceanElevation(x, z)
oceanElevation(x, z)
Ocean floor elevation.
- Separate from land elevation
- Typically negative values (below sea level)
- Allows for deep ocean trenches
continents.yml
Determines ocean vs land distribution.continents(x, z)
continents(x, z)
Continental noise - positive = land, negative = ocean.
- Uses low-frequency noise for large continents
- Smooth transitions between ocean and land
- Referenced by terrain samplers and biome distribution
temperature.yml
Temperature distribution for biome zones.temperature(x, z)
temperature(x, z)
Temperature value at position.
- Higher values = warmer biomes (desert, jungle)
- Lower values = colder biomes (tundra, ice)
- Used in biome distribution stages
- Latitude-based with noise variation
precipitation.yml
Rainfall/moisture distribution.precipitation(x, z)
precipitation(x, z)
Moisture level at position.
- Higher values = wet biomes (jungle, swamp)
- Lower values = dry biomes (desert, savanna)
- Combined with temperature for biome selection
rivers.yml
River generation and terrain erosion.rivers(x, z)
rivers(x, z)
River noise - low values indicate river presence.
- Creates winding river patterns
- Used for river biome placement
- Can be threshold to create binary river mask
riverTerrainErosion(x, z)
riverTerrainErosion(x, z)
Terrain height reduction near rivers.
- Carves river valleys into terrain
- Smooth falloff from river center
- Applied in elevation sampler
simplex.yml
Generic simplex noise samplers for various uses.simplex2D(x, z, frequency)
simplex2D(x, z, frequency)
2D simplex noise.Parameters:
x, z- Positionfrequency- Noise scale (higher = more detail)
simplex3D(x, y, z, frequency)
simplex3D(x, y, z, frequency)
3D simplex noise.Used for caves, 3D structures, vertical variation.
spots.yml
Random spot/patch generation.spots(x, z)
spots(x, z)
Creates random circular regions.
- Used for oases, clearings, special features
- Cellular-based for distinct spots
- Configurable size and frequency
spawnIsland.yml
Flattens terrain near spawn for player spawn area.spawnIsland(x, z)
spawnIsland(x, z)
Spawn area modifier.
- Returns 1 near spawn, -1 far from spawn
- Creates gentle terrain near world spawn
- Controlled by
spawn-island-elevation-scale
Using Functions and Samplers
In Biome Configs
In Feature Distributors
In Biome Distribution
Customization Variables
Many samplers referencecustomization.yml for easy tuning:
Expression Syntax
Expressions support standard mathematical operations: Operators:+,-,*,/- Basic arithmetic^- Exponentiation%- Modulo|x|- Absolute value
floor(x),ceil(x),round(x)min(a, b),max(a, b)sqrt(x),abs(x)sin(x),cos(x),tan(x)if(condition, true_value, false_value)
Creating Custom Functions
Add new functions to existing YAML files or create new ones:pack.yml:
Creating Custom Samplers
Performance Tips
Cache Expensive Samplers
Reuse sampler results instead of recalculating
Reduce Octaves
Lower octaves = faster generation
Use Lower Frequency
Higher frequency = more detail = slower
Simplify Expressions
Avoid deeply nested calculations
Related References
Configuration Overview
How math functions fit into the overall config structure
Biome Distribution
Using samplers in biome placement
Features
Using samplers in feature distribution
