Class TerrainRendererBase
ENGINE: Abstract base class for terrain renderer implementations. Provides common utilities and state management.
Pattern 20: Pluggable Implementation (Interface + Registry)
public abstract class TerrainRendererBase : ITerrainRenderer
- Inheritance
-
objectTerrainRendererBase
- Implements
- Derived
Fields
DetailStrengthID
protected static readonly int DetailStrengthID
Field Value
- int
DetailTilingID
protected static readonly int DetailTilingID
Field Value
- int
NormalMapAmbientID
protected static readonly int NormalMapAmbientID
Field Value
- int
NormalMapHighlightID
protected static readonly int NormalMapHighlightID
Field Value
- int
NormalMapStrengthID
protected static readonly int NormalMapStrengthID
Field Value
- int
THREAD_GROUP_SIZE
protected const int THREAD_GROUP_SIZE = 8
Field Value
- int
TerrainBrightnessID
protected static readonly int TerrainBrightnessID
Field Value
- int
TerrainSaturationID
protected static readonly int TerrainSaturationID
Field Value
- int
blendSharpness
protected float blendSharpness
Field Value
- float
context
protected TerrainRendererContext context
Field Value
isInitialized
protected bool isInitialized
Field Value
- bool
sampleRadius
protected int sampleRadius
Field Value
- int
textureManager
protected MapTextureManager textureManager
Field Value
Properties
DisplayName
Human-readable name for UI/debugging
public abstract string DisplayName { get; }
Property Value
- string
RendererId
Unique identifier for this renderer (e.g., "Default", "Stylized", "HighDetail")
public abstract string RendererId { get; }
Property Value
- string
RequiresPerFrameUpdate
Whether this renderer needs per-frame updates
public virtual bool RequiresPerFrameUpdate { get; }
Property Value
- bool
Methods
ApplyToMaterial(Material, TerrainStyleParams)
Apply style parameters to material (shader uniforms)
public virtual void ApplyToMaterial(Material material, TerrainStyleParams styleParams)
Parameters
materialMaterialstyleParamsTerrainStyleParams
CalculateThreadGroups(int, int)
Calculate thread groups for compute shader dispatch
protected (int x, int y) CalculateThreadGroups(int width, int height)
Parameters
widthintheightint
Returns
- (int x, int y)
CreateBlendMapTexture(int, int, string)
Create RenderTexture for blend maps with explicit format
protected RenderTexture CreateBlendMapTexture(int width, int height, string name)
Parameters
widthintheightintnamestring
Returns
Dispose()
Cleanup resources
public virtual void Dispose()
GenerateBlendMaps(RenderTexture, ComputeBuffer, int, int)
Generate terrain blend maps (DetailIndexTexture + DetailMaskTexture) Called after ProvinceTerrainAnalyzer completes
public abstract (RenderTexture detailIndex, RenderTexture detailMask) GenerateBlendMaps(RenderTexture provinceIDTexture, ComputeBuffer provinceTerrainBuffer, int width, int height)
Parameters
provinceIDTextureRenderTextureProvince ID texture
provinceTerrainBufferComputeBufferProvince terrain buffer (terrain type per province)
widthintMap width
heightintMap height
Returns
- (RenderTexture detailIndex, RenderTexture detailMask)
Tuple of (DetailIndexTexture, DetailMaskTexture)
GetBlendSharpness()
Get the blend sharpness value
public float GetBlendSharpness()
Returns
- float
GetSampleRadius()
Get the sample radius used for terrain blending
public int GetSampleRadius()
Returns
- int
Initialize(MapTextureManager, TerrainRendererContext)
Initialize the renderer with required dependencies
public virtual void Initialize(MapTextureManager textureManager, TerrainRendererContext context)
Parameters
textureManagerMapTextureManagercontextTerrainRendererContext
OnInitialize()
Override to perform implementation-specific initialization
protected virtual void OnInitialize()
OnRenderFrame()
Called each frame if RequiresPerFrameUpdate is true
public virtual void OnRenderFrame()
SetBlendSharpness(float)
Set the blend sharpness value
public virtual void SetBlendSharpness(float sharpness)
Parameters
sharpnessfloat
SetSampleRadius(int)
Set the sample radius for terrain blending
public virtual void SetSampleRadius(int radius)
Parameters
radiusint