Class MapModeColorizerBase
- Namespace
- Map.MapModes.Colorization
- Assembly
- MapAssembly.dll
ENGINE: Abstract base class for map mode colorizers. Provides common utilities for GPU compute shader-based colorization.
Subclasses implement:
- ColorizerId, DisplayName - identification
- InitializeColorizer() - load compute shader, create buffers
- DoColorize() - dispatch compute shader
- DisposeResources() - release GPU resources
public abstract class MapModeColorizerBase : IMapModeColorizer
- Inheritance
-
objectMapModeColorizerBase
- Implements
- Derived
Fields
THREAD_GROUP_SIZE
protected const int THREAD_GROUP_SIZE = 8
Field Value
- int
context
protected MapModeColorizerContext context
Field Value
isInitialized
protected bool isInitialized
Field Value
- bool
Properties
ColorizerId
Unique identifier for this colorizer (e.g., "Gradient", "DiscreteBands", "MultiColor")
public abstract string ColorizerId { get; }
Property Value
- string
DisplayName
Human-readable name for UI/debugging
public abstract string DisplayName { get; }
Property Value
- string
RequiresPerFrameUpdate
Whether this colorizer needs per-frame updates (e.g., animated effects)
public virtual bool RequiresPerFrameUpdate { get; }
Property Value
- bool
Methods
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)
ColorToVector4(Color)
Convert Color to Vector4 for shader.
protected Vector4 ColorToVector4(Color color)
Parameters
colorColor
Returns
Colorize(RenderTexture, RenderTexture, float[], ColorizationStyleParams)
Apply colorization to generate output texture. Core operation: province values + style params → colored texture
public void Colorize(RenderTexture provinceIDTexture, RenderTexture outputTexture, float[] provinceValues, ColorizationStyleParams styleParams)
Parameters
provinceIDTextureRenderTextureInput: Province ID texture (RG16 encoded)
outputTextureRenderTextureOutput: Colorized RGBA texture
provinceValuesfloat[]Per-province normalized values (0-1), negative = skip
styleParamsColorizationStyleParamsColorization style parameters
Dispose()
Release GPU resources.
public void Dispose()
DisposeResources()
Subclass resource cleanup. Release compute buffers, etc.
protected abstract void DisposeResources()
DoColorize(RenderTexture, RenderTexture, float[], ColorizationStyleParams)
Subclass colorization implementation. Dispatch compute shader with appropriate parameters.
protected abstract void DoColorize(RenderTexture provinceIDTexture, RenderTexture outputTexture, float[] provinceValues, ColorizationStyleParams styleParams)
Parameters
provinceIDTextureRenderTextureoutputTextureRenderTextureprovinceValuesfloat[]styleParamsColorizationStyleParams
EnsureGradientBuffer(ComputeBuffer, int)
Create or resize a compute buffer for gradient colors.
protected ComputeBuffer EnsureGradientBuffer(ComputeBuffer existing, int colorCount)
Parameters
existingComputeBuffercolorCountint
Returns
EnsureProvinceValueBuffer(ComputeBuffer, int)
Create or resize a compute buffer for province values.
protected ComputeBuffer EnsureProvinceValueBuffer(ComputeBuffer existing, int minSize)
Parameters
existingComputeBufferminSizeint
Returns
Initialize(MapModeColorizerContext)
Initialize the colorizer with required resources. Called once when colorizer is first activated.
public void Initialize(MapModeColorizerContext ctx)
Parameters
InitializeColorizer()
Subclass initialization hook. Load compute shaders, create buffers, etc.
protected abstract void InitializeColorizer()
OnRenderFrame()
Called each frame if RequiresPerFrameUpdate is true. Use for animated effects, pulsing, etc.
public virtual void OnRenderFrame()
UploadGradientColors(ComputeBuffer, ColorGradient, int)
Sample gradient at specified points and upload to buffer.
protected void UploadGradientColors(ComputeBuffer buffer, ColorGradient gradient, int sampleCount)
Parameters
bufferComputeBuffergradientColorGradientsampleCountint