Combine adjacent terrain tiles and overlapping stamps into a single master landscape. This Burst-powered tool physically merges data arrays, giving you one unified canvas for global editing.The Terrain Merger is an editor and runtime utility designed to stitch multiple terrain tiles into a single master landscape.Unity’s default terrain system and the Terrain Toolkit currently lack a native way to merge existing terrains. When you need to sculpt a mountain range across terrain boundaries, use modular terrain packs, or paint global biomes across a divided map, you typically run into hard seams and tedious manual workarounds. This tool addresses that gap, providing level designers and environment artists with a consolidated canvas for broad modifications.Editor Workflow & CapabilitiesInstead of simply snapping grids together and leaving hard edges where geometry mismatches, the Merger provides specific controls for how your landscapes intersect.Feathering Overlaps (Not Gaps): When placing terrains on top of one another, a customizable "Blend Radius" interpolates heightmaps and splatmaps (textures) across the overlapping thresholds to smooth out the seams. (Note: This blends overlapping data; it does not bridge empty gaps or auto-sculpt misaligned heights between adjacent, non-overlapping tiles).Grid Consolidation: Whether you are combining a 4x4 grid of adjacent terrain tiles or integrating a specific feature into a base landscape, the tool consolidates the underlying data arrays into one unified asset.Overlapping & Stamping: The system calculates height dominance, allowing it to function as a terrain stamper. If you drop a hand-sculpted feature (like a mountain or crater) onto a flat base landscape, the Merger projects and blends it into the surrounding geometry.The Revert Safety Net: Terrain merging is a destructive process. To support faster iteration, the Editor window includes a "Revert Last Merge" function. Built on Unity's GlobalObjectId tracking, this cache survives Editor Domain Reloads (script recompilations), allowing you to quickly delete the generated assets and restore your original source terrains to adjust your blend settings.Smart Auto-Pathing: To help maintain project organization, the tool can automatically generate a dedicated Merged_Terrains folder relative to your primary source asset, saving the newly generated data into timestamped subfolders.The Core Engine & Burst OptimizationMerging multidimensional data points—heightmaps, alphamaps, detail layers, and tree instances—is a heavy mathematical operation. Standard C# loops handling this volume of data will quickly lock up the main thread and freeze the Editor.Multithreaded Processing: The tool leverages Unity's Burst Compiler and the C# Job System to process terrain arrays concurrently across CPU threads, moving the workload off the main thread for asynchronous execution.Atomic Synchronization: Modern URP and HDRP pipelines in Unity 6 can struggle when handling large texture arrays mid-generation. To maintain stability and prevent Out-Of-Memory (OOM) crashes, the engine uses a decoupled, asset-first strategy. It separates the generation of the raw .asset file from the injection of the splatmap payloads, preventing Unity from auto-generating monolithic default textures that can freeze the Editor.System Constraints & LimitationsData Consolidation, Not Edge-Matching: This tool merges adjacent tiles and blends overlapping stamps into a single .asset file. It does not automatically detect and fix gaping holes or misaligned heights between adjacent terrains that were sculpted separately. It simply consolidates the data so you can manually smooth the transitions on a single canvas.Not an Optimization Tool: The Terrain Merger is designed as a workflow step in your level design pipeline, not a runtime optimization. Combining multiple terrains creates a monolithic asset that defeats occlusion and frustum culling. Using a single, massive terrain in a final build can negatively impact your runtime framerate.The Prototype Accumulation Problem: The engine must combine all unique textures (Terrain Layers), tree meshes (Tree Prototypes), and grass textures (Detail Prototypes) from the source terrains into the master terrain. If you merge multiple terrains with entirely unique prototypes, your draw calls will scale accordingly, reducing GPU instancing efficiency. It is recommended that source terrains share a core library of layers and trees prior to merging.RAM-Intensive Operations: Extracting and combining multidimensional arrays from TerrainData requires significant Editor RAM. Attempting to merge a large grid of 4K resolution terrains may cause memory spikes and Editor slowdowns. The UI provides a warning if your selected bounding area exceeds standard thresholds to help you prepare for a heavy calculation.Runtime Generation & Memory SafetyWhile merging is usually handled in the Editor during level design, some projects (like procedural world generators or UGC sandboxes) require dynamic terrain manipulation during gameplay.Dynamic Execution: The included RuntimeTerrainMerger MonoBehaviour hooks directly into the Burst-compiled core engine, allowing you to execute merges asynchronously alongside your main game loop.Spatial Querying: For procedural setups without direct script references, the component includes a GatherTerrainsInBounds() method. Passing a world-space bounding box automatically finds active terrains within that area and queues them for merging.Memory Tracking: Handling large arrays at runtime requires strict memory management. If the merger component is destroyed during or after an operation, it actively flushes transient RAM and destroys the generated unmanaged assets natively to prevent memory leaks.Recommended Ecosystem & Workflow ToolsThis asset integrates well with two other tools available on my publisher page:Terrain Slicer (Free): This tool serves as the inverse to the Merger. After you use the Merger to stitch tiles together and apply global edits across seams, the Terrain Slicer can divide that monolithic terrain back into optimized, streamable grids for your final build.BurstLOD: While slicing terrain helps optimize the ground mesh, the props placed on top of it still impact performance. BurstLOD generates runtime or Editor-based LODs, helping maintain performance targets for custom prefabs across large environments.Compatibility & Getting StartedRequirements: Requires Unity 6 or newer. It relies on standard Unity packages (Unity.Burst, Unity.Collections, Unity.Mathematics) which are included natively in modern engine versions.Clean Footprint: This asset does not include a bloated, pre-packaged demo scene. The documentation features a Quick Start guide explaining how to test a merge using your own blank terrains in just a few minutes.Support the DevelopmentAs a solo developer, creating and maintaining free tools requires a significant time investment. If this asset speeds up your workflow or saves you some manual sculpting time, please consider leaving a rating or review on the Asset Store. It helps the tool gain visibility in the algorithm and supports continued updates. Good luck with your project.Requirements & CompatibilityMinimum Unity Version: Unity 6 or newer.Render Pipelines: Fully compatible with the Built-in Render Pipeline, Universal Render Pipeline (URP), and High Definition Render Pipeline (HDRP).Dependencies: Utilizes native Unity.Burst, Unity.Collections, and Unity.Mathematics packages (included by default in modern Unity projects).Core SystemsMultithreaded Engine: Fully utilizes the C# Job System and Burst Compiler to asynchronously crunch massive multidimensional arrays for heightmaps, detail layers, terrain holes, and tree instances without locking the main thread.Decoupled Payload (Atomic Sync): Employs an asset-first serialization strategy for alphamaps to safely bypass Unity's mid-generation texture wipes, natively preventing Out-Of-Memory (OOM) Editor crashes.Code Architecture: Cleanly organized under the Veridian.Perspective.TerrainMerger namespace, cleanly separating runtime math from Editor UI assemblies so Editor scripts can be safely excluded from your final build.Generated OutputsMaster TerrainData: Generates a single, unified .asset file with accurately projected heights, feather-blended overlaps, and proportional resolution scaling based on the defined world-space bounds.Splatmaps: Automatically packs and explicitly binds generated overlapping splatmap textures as nested sub-assets to prevent data loss or decoupling.Clean Prefabs: Re-instantiates standard Unity Terrain and TerrainCollider objects, seamlessly inheriting configuration settings (shadow casting, basemap distances, material templates, detail scatter modes) from the original source terrains.Runtime API & Memory ManagementThread-Safe API: Includes a fully asynchronous, cancellation-token-supported API (TerrainMergerEngine.MergeTerrainsAsync) designed to safely execute spatial merges from native game loops.Transient RAM Flushing: The included RuntimeTerrainMerger component features built-in safety checks to natively flush transient RAM and instantly destroy unmanaged generated assets if an operation is aborted or the component is destroyed during gameplay.




