Table of Contents

Terrain Detail Spawning


Unity's built-in terrain detail system relies on ComputeDetailInstanceTransforms, which runs on the main thread, allocates garbage every frame, and causes hitches — especially with dense vegetation or large terrains.

BRG Instanced Renderer replaces this entirely with a custom detail extraction algorithm that runs on worker threads via the Unity Job System, produces zero garbage, and causes no hitches.

How It Works

The system reads the terrain's detail density maps directly and computes instance transforms in parallel using Burst-compiled jobs. As the camera moves, new terrain patches are loaded and old ones recycled — all without blocking the main thread or allocating managed memory.

Async Terrain Initialization

Reading a terrain's heightmap and holes textures normally blocks the main thread twice per terrain during initialization. With Allow Async Detail Loading enabled (the default), those reads go through an async GPU readback instead, removing both stalls — which matters most when terrains stream in at runtime. The trade-off is that details for a newly initialized terrain don't begin streaming until the readback completes a few frames later. See Terrain Config.

Compatibility

The custom algorithm is a direct reimplementation of Unity's placement, not an approximation of it. It reproduces the same per-cell seeding, the same density dithering and coverage stepping, the same Perlin-based width and height scaling, the same hole rejection, and the same ground alignment — so detail layers land where Unity would put them, at the size Unity would give them.

It also follows the settings Unity's own placement responds to, including the Use Legacy Detail Distribution quality setting and each layer's noise seed, noise spread, min/max width and height, position jitter, and align-to-ground.

If you need a guaranteed byte-for-byte match, enable Use Unity Transforms on the BRG Terrain Registerer. It calls Unity's own ComputeDetailInstanceTransforms instead, which is slower and allocates garbage, but removes any question of divergence.

For terrain setup, see Getting Started: Terrain and BRG Terrain Registerer.