Class 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
public class TerrainBlendMapGenerator : MonoBehaviour
- Inheritance
-
objectTerrainBlendMapGenerator
Methods
Generate(RenderTexture, ComputeBuffer, int, int)
Generate terrain blend maps (DetailIndexTexture + DetailMaskTexture) Call this after ProvinceTerrainAnalyzer completes
public (RenderTexture detailIndex, RenderTexture detailMask) Generate(RenderTexture provinceIDTexture, ComputeBuffer provinceTerrainBuffer, int width, int height)
Parameters
provinceIDTextureRenderTextureProvince ID texture (5632x2048 RG16)
provinceTerrainBufferComputeBufferProvince terrain buffer (65536 entries, uint per province)
widthintMap width (5632)
heightintMap height (2048)
Returns
- (RenderTexture detailIndex, RenderTexture detailMask)
Tuple of (DetailIndexTexture, DetailMaskTexture)
GetActiveTerrainRenderer(string)
Get the active terrain renderer from registry.
public ITerrainRenderer GetActiveTerrainRenderer(string rendererId = null)
Parameters
rendererIdstring
Returns
Initialize(MapTextureManager)
Initialize and register default terrain renderer with MapRendererRegistry. Call this during map initialization.
public void Initialize(MapTextureManager textureManager)
Parameters
textureManagerMapTextureManager
InitializeKernels()
Initialize compute shader kernels. Called by ArchonEngine.
public void InitializeKernels()