Namespace Map.Rendering.Terrain
Classes
- DefaultTerrainRenderer
ENGINE: Default terrain renderer using Imperator Rome-style 4-channel blending.
Features:
- GPU-accelerated blend map generation via compute shader
- Configurable sample radius (5x5 default) for terrain transition width
- Configurable blend sharpness (1.0 = linear, >1 = sharper transitions)
- Outputs DetailIndexTexture (4 terrain indices) + DetailMaskTexture (4 blend weights)
Pattern 20: Pluggable Implementation (Interface + Registry)
- TerrainBitmapReader
ENGINE: Reads terrain.bmp and converts RGB pixels to terrain type indices Handles both direct BMP palette reading and Unity Texture2D RGB conversion
- TerrainBlendMapGenerator
ENGINE: Generates terrain blend maps for Imperator Rome-style 4-channel blending Pre-computes DetailIndexTexture + DetailMaskTexture at load time (~50-100ms)
Algorithm:
- Sample ProvinceIDTexture in 5x5 radius per pixel
- Count terrain types via ProvinceTerrainBuffer lookup
- Take top 4 terrain types by frequency
- Normalize to weights (0-1 range)
- Write indices to DetailIndexTexture, weights to DetailMaskTexture
Output:
- DetailIndexTexture (RGBA8): 4 material indices per pixel
- DetailMaskTexture (RGBA8): 4 blend weights per pixel
Usage: MapDataLoader calls Generate() after province terrain analysis complete
- TerrainOverrideApplicator
ENGINE: Applies terrain overrides from terrain.json5 EU4 uses terrain_override arrays to force specific provinces to specific terrain types regardless of what the terrain.bmp shows
- TerrainRGBLookup
ENGINE: Loads terrain.json5 and provides fast RGB → Terrain Type Index lookups. Uses terrain.json5 as single source of truth (same as TerrainLoader and TerrainColorMapper). Terrain type indices are determined by ORDER in terrain.json5 categories section.
- TerrainRendererBase
ENGINE: Abstract base class for terrain renderer implementations. Provides common utilities and state management.
Pattern 20: Pluggable Implementation (Interface + Registry)
Structs
- TerrainRendererContext
Context provided during terrain renderer initialization
- TerrainStyleParams
Style parameters for terrain rendering (from VisualStyleConfiguration)
Interfaces
- ITerrainRenderer
ENGINE: Interface for pluggable terrain rendering implementations.
ENGINE provides default Imperator Rome-style 4-channel blend map generation. GAME can register custom implementations for different terrain styles:
- Different blending algorithms (8-channel, height-based, etc.)
- Stylized terrain rendering
- Performance-optimized variants
Pattern 20: Pluggable Implementation (Interface + Registry)