Table of Contents

Namespace Map.Rendering.Border

Classes

BorderChainMerger

Merges multiple border pixel chains into single connected polylines Extracted from BorderCurveExtractor for single responsibility

Contains logic for:

  • Merging multiple chains by finding closest endpoints
  • U-turn detection and rejection to prevent bad geometry
  • Chain simplification (keeping only longest chains)
  • Junction bridging (connecting gaps to junctions via BFS)
BorderDebugUtility

Debug and benchmarking utilities for border rendering Extracted from BorderComputeDispatcher for single responsibility

Responsibilities:

  • Benchmark border detection performance
  • Generate debug visualizations
  • Clear/fill border textures for debugging
  • Save debug textures to disk
BorderGeometryUtils

Geometric utility functions for border processing Extracted from BorderCurveExtractor for reusability

Contains:

  • Line segment intersection detection
  • Path self-intersection checking
  • Convex hull computation (Graham scan)
  • Distance calculations
  • Angle calculations
BorderParameterBinder

Manages border rendering mode state Extracted from BorderComputeDispatcher for single responsibility

NOTE: Visual parameters (colors, widths, distance field settings) are now controlled via VisualStyleConfiguration - the single source of truth for visuals. This class only tracks the rendering mode for compute shader orchestration.

BorderPolylineSimplifier

Utilities for simplifying and smoothing polylines Extracted from BorderCurveExtractor for single responsibility

Methods:

  • SimplifyPolyline: Ramer-Douglas-Peucker algorithm to reduce vertex count
  • SmoothCurve: Chaikin subdivision smoothing algorithm
  • TessellatePolyline: Subdivide long segments for dense vertex coverage
BorderRendererBase

ENGINE: Abstract base class for border renderers with common functionality. Handles both GPU compute and CPU-based implementations. Extend this class to create custom border renderers.

BorderShaderManager

Manages compute shader loading and kernel initialization for border rendering Extracted from BorderComputeDispatcher for single responsibility

Responsibilities:

  • Lazy loading of compute shaders (BorderDetection, BorderCurveRasterizer, BorderSDF)
  • Kernel index caching
  • Shader validation and error reporting
BorderStyleUpdater

Updates border styles based on province ownership changes Extracted from BorderComputeDispatcher for single responsibility

Responsibilities:

  • Classify borders as country or province borders
  • Update border colors based on owner changes
  • Coordinate with BorderCurveCache for style updates
DistanceFieldBorderRenderer

ENGINE: Distance field border renderer implementation. Wraps BorderDistanceFieldGenerator for pluggable interface.

Uses Jump Flooding Algorithm (JFA) for GPU-based smooth anti-aliased borders. Results in silky smooth borders at any zoom level (CK3/Stellaris quality).

JunctionDetector

Detects junction pixels (where 3+ provinces meet) and snaps polyline endpoints to them Extracted from BorderCurveExtractor for single responsibility

Contains logic for:

  • Junction pixel detection (3+ provinces meeting at a point)
  • Endpoint snapping with spatial grid optimization (O(n) performance)
  • Degenerate loop prevention (same polyline endpoints)
MedianFilterProcessor

Processes border pixels using median filtering and pixel chaining Extracted from BorderCurveExtractor for single responsibility

Contains logic for:

  • Median filtering (removes single-pixel noise from province ID texture)
  • Pixel chaining (converts scattered border pixels into ordered polylines)
  • Junction-aware chaining (starts/ends chains at junction points)
MeshGeometryBorderRenderer

ENGINE: Mesh-based border renderer implementation. Generates actual geometry for borders using CPU curve extraction.

Best for 3D map effects where borders need depth/thickness. Requires per-frame rendering via OnRenderFrame().

NoneBorderRenderer

ENGINE: No-op border renderer for when borders are disabled. Provides clean shutdown of border rendering.

PixelPerfectBorderRenderer

ENGINE: Pixel-perfect border renderer implementation. Uses compute shader for crisp, aliased 1-pixel border detection.

Best for retro/pixel art aesthetics where sharp borders are desired. Supports configurable thickness and optional anti-aliasing.

Structs

BorderGenerationParams

Parameters for border generation.

BorderRendererContext

Context provided to border renderers during initialization. Contains references to systems needed for border generation.

BorderStyleParams

Style parameters from VisualStyleConfiguration. Passed to ApplyToMaterial for visual customization.

Interfaces

IBorderRenderer

ENGINE: Interface for pluggable border rendering implementations. ENGINE provides defaults (DistanceField, PixelPerfect, MeshGeometry). GAME can register custom implementations via MapRendererRegistry.