The terrain generation system supports multiple algorithmic approaches for creating diverse landscapes. Perlin noise generates smooth, natural-looking terrain features, while Fractal noise layers multiple octaves to produce more detailed and varied landscapes with realistic mountain ranges and valley systems. The SimpleMiner algorithm, adapted from my previous voxel game project, combines layered noise with biome-specific modifications including hilliness and oceanness factors to create distinct geographical features.
Central difference normal calculation replaces traditional gradient estimation methods, using symmetric sampling of neighboring height values to compute surface normals. This mathematical approach eliminates directional bias and preserves both steep ridges and smooth undulations, resulting in more accurate lighting and visual fidelity. The system also implements configurable height smoothing through 3x3 neighborhood averaging with linear interpolation blending, allowing users to control terrain feature refinement.
The heightmap pipeline supports both procedural generation and custom heightmap import, with real-time parameter adjustment through curve-based smoothing functions. Users can export generated heightmaps for use in external tools, creating a complete content creation workflow.
The biome system implements GPU weight-texture blending using RGBA texture channels where each channel encodes coverage intensity for specific biomes: Red=Desert, Green=Grass, Blue=Wetland, Alpha=Base Terrain. This approach enables smooth transitions between different surface types through single texture sampling in the pixel shader.
Height-slope based blending provides an alternative approach that dynamically assigns biomes based on pixel elevation and surface slope analysis. The system divides terrain height into elevation bands (low altitude, mid-altitude, high altitude, peak altitude), with each band supporting different biome assignments. Slope-based adjustments favor different materials based on surface steepness - gentle slopes use grass textures while steep slopes blend toward rocky materials.
Procedural biome generation calculates temperature, wetness, and exposure parameters through multi-octave Perlin noise functions. Temperature varies based on latitude and altitude, wetness combines large-scale and fine-detail moisture patterns, and exposure increases with elevation to simulate environmental conditions. These parameters determine biome intensities that are packed into RGBA textures for GPU sampling.
Triplanar mapping addresses UV stretching on steep surfaces by sampling textures from three planar projections (XY, YZ, ZX) and blending them according to the surface normal's dominant axis. This technique is selectively applied only when slope exceeds a threshold, maintaining performance while ensuring visual quality on cliff faces.
The water system implements Gerstner wave mathematics to simulate realistic water surface motion. Each wave contributes to vertex displacement through sine functions with configurable amplitude, wavelength, direction, and speed parameters. The system supports dual-layer waves for increased complexity, with the secondary wave at 1.4x frequency and 0.6x direction scaling to create natural interference patterns.
Dual normal calculation combines analytical gradient computation with central difference sampling to achieve both mathematical accuracy and natural appearance. The analytical method provides precise surface slopes through partial derivatives, while central differences capture local variations that create natural ebb and flow effects. The final normal is a weighted blend (40% analytical, 60% central difference) optimized for visual quality.
Dynamic rain rendering uses GPU-based vertex shaders to simulate continuous rainfall. Each raindrop particle's position is calculated based on time, height range, and wind direction, with modulo operations creating seamless looping without particle respawning. Horizontal displacement simulates wind influence, while randomized initial offsets ensure natural distribution across different heights.
Weather transitions provide seamless skybox blending between clear, day/night, and storm environments. The system uses time-based interpolation with configurable transition windows, automatically adjusting lighting and atmospheric conditions to match weather states.
Vegetation placement uses grid-based distribution with randomized offsets to avoid rigid, uniform patterns. The system iterates over a 2D grid corresponding to terrain dimensions, applying random position offsets within specified ranges while filtering unsuitable locations (below water level, insufficient wetness/grassiness).
Biome-driven filtering determines vegetation spawning based on wetness and grassiness threshold values calculated from the biome system. Areas with high moisture and moderate temperature favor grass placement, while dry or extreme temperature regions remain barren. This creates natural-looking vegetation distribution that responds to environmental conditions.
GPU instanced rendering efficiently renders vegetation models with positional and rotational variations. The system supports multiple vegetation types (grass variants, flowers) with random selection algorithms to increase visual diversity across the terrain.
The editor interface provides comprehensive real-time control over all terrain generation parameters through organized ImGui panels. The General Panel displays system performance metrics, camera modes, and global settings. The Heightmap Generation Panel offers noise parameter adjustment, terrain sizing, and heightmap import/export functionality.
Biome Generation Panels separate height-slope based controls from procedural biome generation, allowing users to switch between different biome assignment methods. The Environment Panel includes water wave parameters, weather transition controls, and vegetation distribution settings.
Live parameter adjustment enables immediate visual feedback without recompilation or application restart. Users can modify noise scales, biome intensities, water properties, and weather conditions while observing real-time changes to the generated terrain. Asset management includes file browsers for heightmap, biome map, and material import/export, supporting industry-standard formats.
Debug visualization modes display biome weight values as color overlays, helping users understand how procedural algorithms affect terrain appearance. Performance monitoring tracks frame rates, vertex/index counts, and memory usage to ensure optimization targets are maintained.
The rendering system implements mip-mapping and anisotropic filtering to maintain texture quality across varying viewing distances and angles. Mip-mapping reduces aliasing and improves cache efficiency by automatically selecting appropriate texture resolution levels, while anisotropic filtering adapts sampling footprints for surfaces viewed at oblique angles.
Texture array management optimizes GPU memory usage by grouping biome materials into texture arrays, reducing texture binding overhead and enabling efficient material blending in pixel shaders. The system supports unlimited material combinations through 4-channel weight blending.
Multi-threaded architecture leverages the custom engine's job system for parallel processing of terrain generation and biome calculations. CPU-intensive operations like heightmap generation and biome value computation execute on worker threads, while the main thread handles rendering and user interface updates.
Batched rendering minimizes draw calls through intelligent geometry and texture state management. The terrain mesh is rendered as a single draw call with material blending handled entirely in shaders, while vegetation uses instanced rendering to draw multiple models efficiently.