Tile Providers (Samples)

Example Tile Providers for the Procedural Tile Manager

Tile Providers decide which prefab to spawn for each grid cell managed by ProceduralTileManager. They are deterministic (given the same seed and cell coordinates, you get the same result), so streaming in/out won’t cause visible popping inconsistencies.

All providers implement:

public interface IProceduralTileProvider
{
    GameObject GetPrefabForCell(Vector2Int cell);
}

Create them via Assets → Create → Runtime Navmesh Baker → … and assign the asset to ProceduralTileManager → Provider Asset.

Tip: For the best experience with runtime baking, set NavMeshBakeProfile.Bake Mode = Grid Cells and match Profile.Cell Size XZ to ProceduralTileManager.Tile Size XZ.


1) Weighted Hash Tile Provider

Menu: Runtime Navmesh Baker / Weighted Hash Tile Provider Use when: You want deterministic random variety with simple weighting (e.g., 70% grass, 25% dirt, 5% rock), no noise fields needed.

How it works (high level)

  • Computes a stable 32-bit hash from (cellX, cellY, seed).

  • Converts that hash into a float r ∈ [0,sum) where sum is the total weight of all entries.

  • Walks your list of (Prefab, Weight) entries and picks the prefab whose cumulative range contains r.

Key fields

  • Entries (Prefab, Weight): List of candidates; non-negative weights.

  • Seed: Changes the arrangement while preserving weights.

Characteristics

  • Deterministic: Same seed → same layout.

  • Even distribution: Over large areas, frequencies approach weights.

  • No spatial coherence: Adjacent cells are independent (which can be desirable for patchy variety).

Tips

  • Use larger weights for common tiles, tiny weights (e.g., 0.05) for rare “interest” tiles.

  • For biomes / clusters, use a Noise provider instead (below) or layer this with a biome map that gates which entries are eligible.


2) Improved Noise Tile Provider

Menu: Runtime Navmesh Baker / Improved Noise Tile Provider Use when: You want organic, coherent regions (biomes/bands) with controllable chaos and detail.

How it works (high level)

  • Starts with domain-warped fractal noise (fBM):

    • Optional domain warp perturbs the input before sampling (adds swirls/eddies).

    • fBM sums multiple Perlin octaves (frequency ↑, amplitude ↓) for rich detail.

  • The final value n ∈ [0,1] is remapped (via curve) and jittered (small per-cell offset).

  • Maps n into a band index to choose a prefab from your array.

Key fields

  • Prefabs[]: Ordered bands across 0..1 (e.g., [water, sand, grass, rock, snow]).

  • Base Frequency: Size of the broad features (lower = larger landmasses).

  • Octaves / Persistence / Lacunarity: fBM detail and roughness controls.

  • Warp Amplitude / Warp Frequency: Strength and scale of domain warp (more warp → twisty patterns).

  • Remap (AnimationCurve): Re-shape the 0..1 distribution (e.g., bias toward mid/ends).

  • Band Jitter: Tiny per-cell variation to break band edges.

  • Seed: Controls the global pattern deterministically.

Characteristics

  • Spatial coherence: Neighboring cells tend to match, forming natural regions.

  • Highly tunable: From smooth continents to noisy patchwork.

  • Deterministic: Same seed/params → same map.

Tips

  • Start simple: Octaves=3, Persistence≈0.5, Lacunarity≈2.0.

  • Increase warpAmplitude slightly (0.5–1.0) to avoid obvious Perlin “ridges”.

  • Use Remap curve to emphasize certain biomes (e.g., lower half as “plains”).

  • Ensure Prefabs[] ordering matches your intended bands (0=lowest noise, last=highest).


3) Simple Noise Tile Provider

Menu: Runtime Navmesh Baker / Noise Tile Provider Use when: You want fast, lightweight coherent regions without the extra warp/fBM controls.

How it works (high level)

  • Samples plain Perlin noise at (cell + small hashed offset) * frequency.

  • Maps noise n ∈ [0,1] directly into a band index to pick a prefab.

Key fields

  • Prefabs[]: Ordered bands across 0..1.

  • Frequency: Controls feature size (lower = broader regions).

  • Seed: Changes the arrangement deterministically.

Characteristics

  • Very cheap and simple.

  • Coherent regions, but less control than “Improved Noise”.

  • Great for prototypes and mobile targets.

Tips

  • If you see noticeable grid alignment, reduce Frequency or increase the internal offset by tweaking frequency and your cell size.

  • For more variety, move up to Improved Noise (adds octaves, warp, and remap).


Choosing a Provider

Goal
Best Choice
Why

Simple weighted randomness (no regions)

Weighted Hash

Exact frequency control, deterministic, no noise setup

Natural biomes / bands with artistic control

Improved Noise

fBM + warp + remap + jitter → most flexibility

Lightweight coherent regions

Simple Noise

Minimal parameters, fast, good defaults


Performance & Determinism Notes

  • All providers are stateless and deterministic given (cell, seed). You can stream tiles in/out safely.

  • Prefab lookups are O(1) for noise providers and O(N) for the weighted list (N = number of entries).

  • Keep prefab counts reasonable, especially for mobile. Use pooling in the ProceduralTileManager.


  • Weighted Hash

    • 3–6 entries, weights add up to any positive number.

    • Seed = any integer (change to shuffle globally).

  • Improved Noise

    • Base Frequency: 0.25

    • Octaves: 3

    • Persistence: 0.5

    • Lacunarity: 2.0

    • Warp Amplitude: 0.75, Warp Frequency: 0.5

    • Band Jitter: 0.05–0.1

  • Simple Noise

    • Frequency: 0.1–0.2

    • Prefabs: order bands intentionally (low→high noise).

Last updated