Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
bevy_symbios_texture
Procedural, tileable texture generation for Bevy.
Generates albedo, normal, roughness (ORM), and optional emissive maps entirely on the CPU — no asset files required. Generation is multi-core (rows are produced in parallel) and seamlessly tileable for all surface textures via toroidal 4-D noise mapping. Alpha-masked card textures (leaf, twig, window, stained glass, iron grille, chain-link, log-end) produce per-pixel transparency and do not tile. Atlas-capable card generators — particle sprites (soft disc, spark, snowflake, puff, ring, petal, shard, flame, flower) and foliage billboards (leaf sprite, grass tuft, frond, reed, needle, broadleaf) — bake alpha-silhouette sheets where every atlas cell is a per-cell-seeded variant of the same config.
Quick start
Synchronous (blocking)
Suitable for startup systems or contexts where a small generation time is acceptable.
use *;
use ;
Asynchronous (non-blocking, recommended)
Offloads pixel math to a private, bounded rayon thread pool (default 4
concurrent tasks; configurable via AsyncTextureConfig::pool_threads) so the
main thread is never stalled. On WASM, falls back to Bevy's
AsyncComputeTaskPool.
Within each texture, rows are generated in parallel: async tasks work-steal
across the private pool (so pool_threads remains the CPU cap), while direct
synchronous generate() calls parallelise on the caller's rayon pool —
usually the global one, using every core. Output is byte-identical to
serial generation.
If rayon::ThreadPoolBuilder::build() fails at first init (out-of-memory, OS
thread limit, sandboxed environments) the library logs a warning and falls
back to running each generator inline on the calling thread. Texture
generation still works — slower and blocking the spawning thread — instead of
panicking.
use *;
use ;
Dropping a PendingTexture entity before generation completes sets a
cancellation flag; tasks that have not yet started exit without doing any work.
One-shot procedural materials
build_procedural_material_async collapses the StandardMaterial-allocate +
PendingTexture-spawn + post-completion-patch dance into a single call. Define
a MaterialSettings (PBR fields + a TextureConfig enum that selects the
generator), call the helper, and use the returned handle immediately:
use ;
Texture cache
To avoid regenerating the same (generator, config, size) tuple across
spawns, insert a TextureCache resource:
use ;
app.insert_resource;
// or, for cross-process persistence:
// app.insert_resource(TextureCache::file("./.texture-cache", manifest_version)?);
Cache hits return previously-uploaded Handle<Image> clones synchronously
and skip the rayon dispatch entirely. Cache keys derive from a fingerprint
of the config struct, so any field change automatically invalidates the
prior entry. manifest_version is mixed into every FileStore on-disk
key, so bumping it rotates the persisted cache without deleting the
directory — use it when generator internals change without a config-field
change.
The library ships two built-in stores — MemoryStore (bounded, FIFO
eviction, default) and FileStore (binary blobs on disk) — and exposes the
TextureCacheStore trait for custom backends. FileStore persists the raw
pixel blobs as generation completes and re-uploads them (regenerating
mipmaps) on the first hit after a restart, so warm caches survive across
processes.
For diagnostics, TextureCache::entry_count() reports how many entries the
backing store currently holds in memory — Some(len) for MemoryStore,
None for FileStore, whose entries live on disk. Because the cache
retains Handle<Image> clones, its entry count is often the missing term
when attributing image-asset growth in a running application.
Animated parameter curves
Time-varying weathering, age, and seasonal change are first-class via the
AnimatedProceduralMaterial component plus a small set of
ParameterCurve impls (Linear, EaseInOut, Stepped, ScriptedFn).
Attach the component to a material entity and the
tick_animated_procedural_materials system regenerates the texture
whenever the curve's output changes:
use ;
let rust = Linear ;
let base = default;
let animator = new
.with_min_regen_interval; // throttle regeneration to 4 Hz
Two thresholds gate regeneration: a wall-clock cooldown
(min_regen_interval, default 0.25 s) and fingerprint equality. Stepped
or plateaued curves cost essentially nothing once the value stops changing.
For sub-second smoothness across the steady-state pixels, drive a fragment-shader uniform on the material — generator output is RGBA8 and is the wrong knob for sub-frame interpolation.
Compute-shader fast path
A wgpu compute-shader port of the hottest generators (FBM-based bark, brick, marble) is on the roadmap but not implemented. The remaining work — porting toroidal noise to WGSL with bit-equivalent CPU/GPU output, dispatch + readback plumbing, a feature flag that swaps in the GPU path when available, and a benchmark suite — is multi-week and was deliberately deferred so this release could ship the asynchronous + cached + animated path on a known-good CPU baseline.
If you need realtime texture editing at 60 FPS today, the alternatives are:
- Rely on the row-parallel CPU path: on a modern many-core desktop the heaviest generator (bark) renders a 512² map in ~20 ms, so interactive editing at moderate resolutions is already feasible without the GPU port.
- Bake the texture once via the regular CPU path and animate a material uniform (rust mask weight, colour blend, etc.) in the fragment shader.
- Use
AnimatedProceduralMaterialwith a coarsemin_regen_intervaland accept the staircase update cadence.
Generators
Surface textures (tileable)
All tileable generators produce three seamlessly-repeating maps:
| Map | Format | Contents |
|---|---|---|
albedo |
Rgba8UnormSrgb |
Base colour |
normal |
Rgba8Unorm |
Tangent-space normal (R=X, G=Y, B=Z) |
roughness |
Rgba8Unorm |
ORM: R=Occlusion, G=Roughness, B=Metallic |
emissive |
Rgba8UnormSrgb |
Optional emissive / glow map |
Upload with map_to_images to get repeat-wrapping samplers. When a
generator produces an emissive map the polling systems assign it to
StandardMaterial::emissive_texture; Bevy multiplies it by the material's
emissive colour factor, which the material flow auto-defaults to white when
MaterialSettings::emission_color / emission_strength are left unset, so
the glow shows out of the box. Set them only to tint or brighten beyond the
map's encoded values.
Bark
Domain-warped FBM noise with an anisotropic Worley plate layer for rhytidome furrows, producing fibrous, streaked bark grain.
use BarkConfig;
let config = BarkConfig ;
Rock
Ridged multifractal noise for cracked, faceted stone.
use RockConfig;
let config = RockConfig ;
Ground
Blended dual-scale FBM for organic soil / dirt surfaces.
use GroundConfig;
let config = GroundConfig ;
Brick
Grid-based SDF with per-cell colour hashing and configurable mortar/bonding pattern.
use BrickConfig;
let config = BrickConfig ;
Plank
Anisotropic grain FBM with domain warp, Worley knots, and horizontal joint gaps. Each plank row has an independent de-correlated grain phase.
use PlankConfig;
let config = PlankConfig ;
Concrete
Smooth FBM surface relief with optional horizontal formwork-panel seams and scattered air-pocket pits.
use ConcreteConfig;
let config = ConcreteConfig ;
Metal
Brushed metal (anisotropic FBM scratches), standing-seam roof panels,
hand-hammered dimples, or diamond tread plate — all with optional rust-patch
weathering. For Hammered and DiamondPlate, scale sets the dimple /
stud count across the tile.
use ;
let config = MetalConfig ;
Shingle
Overlapping roof shingles or tiles with configurable profile shape, moss growth, and staggered bonding.
use ShingleConfig;
let config = ShingleConfig ;
Pavers
Square or flat-top hexagonal paving stones with grout joints, per-stone colour variance, and a rounded-box SDF bevel.
use ;
let config = PaversConfig ;
Stucco
High-frequency FBM bumps over a flat matte base — typical of sand-float or pebble-dash exterior render. Entirely matte with zero metallic response.
use StuccoConfig;
let config = StuccoConfig ;
Ashlar
Irregular cut-stone masonry with per-block colour variance, chisel-edge darkening, and configurable mortar joints.
use AshlarConfig;
let config = AshlarConfig ;
Cobblestone
Voronoi cell decomposition producing domed, irregularly shaped stones separated by mud/dirt gaps.
use CobblestoneConfig;
let config = CobblestoneConfig ;
Marble
Domain-warped FBM noise passed through a sinusoidal vein function for polished marble or granite with thin dark veins on a light background.
use MarbleConfig;
let config = MarbleConfig ;
Thatch
Dense fibrous roofing material with anisotropic straw fibres, lateral domain-warp wiggle, and layered bundle overlap shadows.
use ThatchConfig;
let config = ThatchConfig ;
Corrugated
Corrugated metal sheets with sine-wave ridges and valley-concentrated rust weathering.
use CorrugatedConfig;
let config = CorrugatedConfig ;
Asphalt
Three-band toroidal FBM (macro staining, micro roughness, aggregate flecks) for tarmac / asphalt with exposed stone chips.
use AsphaltConfig;
let config = AsphaltConfig ;
Sand
Wind-rippled sand: a directional sine ridge field phase-warped by FBM so crests meander and merge, plus grain micro-relief and thresholded bright flecks (exposed sparkling grains read as local smooth spots in the ORM).
use SandConfig;
let config = SandConfig ;
Snow
Wind-drifted snow: soft FBM relief with a cool shadow tint in the troughs and thresholded sparkle flecks — crystals that brighten the albedo and drop ORM roughness to near zero for specular glints.
use SnowConfig;
let config = SnowConfig ;
Ice
Polished lake ice: a near-mirror pale-blue base crossed by thin recessed crack veins (sinusoidal bands over FBM contours), with frost patches that whiten the colour and raise roughness toward matte.
use IceConfig;
let config = IceConfig ;
Moss
A dense velvety moss carpet: broad FBM cushion hummocks overlaid with a fine filament-tip stipple, plus scattered patches bleached toward a dry straw tone. Shaded crevices read deep green while the cushion crowns catch a bright yellow-green.
use MossConfig;
let config = MossConfig ;
Lichen
Crustose lichen colonies over bare rock: a thresholded FBM patch field with pale growing margins, a granular interior, and two species tints (sage grey-green and rusty orange) selected by a slower field, so a rock face shows several colonies rather than one flat wash. Uncolonised texels keep the rock substrate colour.
use LichenConfig;
let config = LichenConfig ;
Cactus Skin
A tileable succulent hide: vertical accordion ribs, a periodic lattice of felted areoles seated on the rib crests, and pale spines radiating from each areole. Ribs and areoles are integer-periodic, so the tile wraps seamlessly around an L-system cactus stem.
use CactusSkinConfig;
let config = CactusSkinConfig ;
Wainscoting
Wood-panel wainscoting with recessed panel faces, rail/stile framing, and anisotropic grain FBM with domain warp.
use WainscotingConfig;
let config = WainscotingConfig ;
Fabric
Plain-weave cloth: perpendicular warp/weft threads as half-cylinder profiles, over/under crossing relief, fibre fuzz, and yarn-mottle tinting. Match the two colours for solid cloth or contrast them for two-tone weaves.
use FabricConfig;
let config = FabricConfig ;
Encaustic
Decorative ceramic tiles with glazed surfaces in configurable geometric patterns (checkerboard, octagon, diamond).
use ;
let config = EncausticConfig ;
Cracked earth
Dried mud plates with curled rims, separated by cracks of constant width —
the cheaper F2 − F1 mask widens with the cell, giving large plates canyons
and small ones hairlines.
use CrackedEarthConfig;
let config = CrackedEarthConfig ;
Gravel
Packed graded aggregate over dust. Each stone is sized against the distance to its neighbour rather than a fixed radius, so it fills its own cell; the metric decides whether stones read as water-rounded shingle or crushed rock.
use GravelConfig;
use CellMetric;
let config = GravelConfig ;
Forest floor
Fallen leaf litter over humus. Leaves are stamped as discrete objects and layered with a per-leaf depth so they interleave — noise-based "litter" has no edges you can follow around a single leaf.
use ForestFloorConfig;
let config = ForestFloorConfig ;
Enamel
A smooth fired glaze, optionally crazed. Its character is the absence of directional structure, which is what a brushed-metal finish cannot fake.
use EnamelConfig;
let config = EnamelConfig ;
Obsidian
Near-black polished glass carrying warped flow banding. Keep band_warp well
under half a turn: past that the bend exceeds half a band period and the bands
fold back through one another instead of flowing.
use ObsidianConfig;
let config = ObsidianConfig ;
Chitin
Carapace plating. Built on a soft minimum so plates swell into one another rather than meeting at the crease a hard minimum gives; the suture is then drawn back in deliberately.
use ChitinConfig;
let config = ChitinConfig ;
Solar panel
Photovoltaic wafers behind glass. The wiring is laid in cell-local space so it runs continuously across cells while the silicon does not — that continuity is what reads as a panel rather than a tiled floor.
use SolarPanelConfig;
let config = SolarPanelConfig ;
Parquet
Short boards laid in a repeating figure. Herringbone is not a grid of blocks:
a cell's board direction falls out of (i − j) mod 2·aspect, and because that
key shifts along both axes the runs interlock into the zig-zag.
use ;
let config = ParquetConfig ;
Truchet
Hashed quarter-arcs that meet at every tile edge whichever way the neighbour
fell, so a grid of coin flips reads as one routed network. The emissive
channel is only collected when emissive_intensity is above zero.
use TruchetConfig;
let config = TruchetConfig ;
Weathering (shared)
Every generator depicting a built or dressed surface carries an optional
weathering block that ages it after generation: ashlar, asphalt, brick,
chitin, cobblestone, concrete, corrugated, enamel, encaustic, fabric, marble,
metal, obsidian, parquet, pavers, rock, shingle, solar panel, stucco, thatch,
truchet and wainscoting.
Natural surfaces are deliberately excluded — sand, snow, moss, bark and their
kin already read as weathered, and a second ageing pass over them fights the
generator rather than helping it. plank is the one gap: it still hand-rolls
its pixel loop instead of using the surface driver, so it cannot be handed a
config yet. Every layer
defaults to an amount of zero, so an untouched block leaves the material
exactly as the generator drew it and costs nothing to bake.
Layers are applied in the order material actually ages: edge wear rubs raised arrises back to the substrate, corrosion creeps out of crevices (adding its own crust relief), grime settles into recesses, and runoff streaks draw down from ledges.
use RockConfig;
use ;
let config = RockConfig ;
Alpha-masked cards
Card generators produce an RGBA8 texture where albedo.alpha encodes the
silhouette (0 = fully transparent, 255 = fully opaque). Upload with
map_to_images_card so the sampler does not tile and the alpha silhouette
does not bleed at edges.
Leaf
A discrete leaf silhouette with procedural venation: midrib, secondary veins, a Perlin venule (tertiary vein) network, Worley capillaries, and optional lobed margins.
use LeafConfig;
let config = LeafConfig ;
LeafSampler can also be used directly for per-pixel evaluation without
going through the full generator (e.g., inside a twig compositor):
use ;
let sampler = new;
if let Some = sampler.sample
Twig
A composite foliage card: a tapered, organically curved stem carrying multiple leaf cards. Supports two phyllotaxis modes:
- Monopodial (
sympodial: false) — opposite leaf pairs on a straight axis with a terminal leaf at the apex. - Sympodial (
sympodial: true) — alternate leaves on a zigzag axis, with a terminal leaf at the apex.
use FRAC_PI_2;
use TwigConfig;
use LeafConfig;
let config = TwigConfig ;
Window
An SDF-based window card with configurable frame, mullions/muntins, and per-pane glass. The alpha channel is transparent outside the frame and semi-transparent over glass panes.
use WindowConfig;
let config = WindowConfig ;
Stained Glass
Voronoi-based stained-glass panel with lead came borders and semi-transparent coloured glass panes. Glass alpha is 180 (semi-transparent); lead is 255 (fully opaque).
use StainedGlassConfig;
let config = StainedGlassConfig ;
Iron Grille
Rectangular or round-bar iron grille / portcullis with configurable bar count and joint-concentrated rust weathering.
use IronGrilleConfig;
let config = IronGrilleConfig ;
Chain-Link
A woven diamond wire mesh: two cylindrical wire families at ±45° with over/under crossing relief and rust pooling at the joints. Transparent between the wires.
use ChainLinkConfig;
let config = ChainLinkConfig ;
Log End
The sawn end of a log: irregular round silhouette, FBM-wobbled concentric
growth rings, optional radial drying cracks, and a streaked bark rim.
Completes the wood set alongside bark and plank.
use LogEndConfig;
let config = LogEndConfig ;
Lava
Cooling lava: dark basalt plates from a toroidal Voronoi decomposition,
separated by molten cracks that drive the emissive map — the glow colour
ramps with crack depth and is written to StandardMaterial::emissive_texture.
The material flow auto-enables a white emissive factor when a glow map is
present, so lava glows out of the box; set emission_color /
emission_strength only to tint or brighten it.
use LavaConfig;
let config = LavaConfig ;
Sprite atlases
The atlas family produces alpha-silhouette cards for billboards. Unlike
the single-image cards above, each generator here can bake a
variant_rows × variant_cols atlas in a single image: every cell renders
the same config with a per-cell derived seed, so a particle system using
random atlas frames gets per-particle shape variety from one texture bake.
Atlas dimensions are clamped to 1..=16 per axis; 1 × 1 bakes a single
card.
The family spans two idioms. The particle sprites (soft disc, spark,
snowflake, puff, ring, petal, shard, flame) use soft fractional alpha —
glows and mist fade out smoothly. The foliage billboards (leaf sprite,
grass tuft, frond, reed, needle, broadleaf) cut hard silhouettes like the
foliage cards and default to 1 × 1 — a single vegetation card — with the
atlas as an opt-in for per-instance variety.
Shared scaffolding (the SpriteCell trait, the generate_atlas driver, and
the deterministic CellRng parameter stream) lives in the sprite module.
Upload with map_to_images_card; sprites never tile.
use ;
let map = new
.generate
.expect;
let handles = map_to_images_card;
Soft Disc
Radial-falloff disc with a solid core and tunable halo — the workhorse particle sprite: fireflies, embers, mist motes, bokeh glints, additive glows.
use SoftDiscConfig;
let config = SoftDiscConfig ;
Spark
N-pointed streak burst: a bright core with radial arms fading toward their tips. Embers, glints, impact sparks, magic sparkles.
use SparkConfig;
let config = SparkConfig ;
Snowflake
Dendritic flake with N-fold symmetry: a central plate, one main arm per sector, and paired side branches. Per-variant jitter is where the "no two snowflakes alike" character comes from.
use SnowflakeConfig;
let config = SnowflakeConfig ;
Puff
Billowy blob of domain-warped fractal noise masked by a soft radial falloff. Dust motes, smoke, fog banks, sea mist.
use PuffConfig;
let config = PuffConfig ;
Ring
Soft annulus with optional angular waviness: shockwaves, water-drop ripples, magic circles, halos.
use RingConfig;
let config = RingConfig ;
Petal
A single flower petal: an obovate blade with a soft throat-to-edge gradient
and an optional notched tip. Petal-fall particles, blossom decals, or — at
1 × 1 — a building block for procedural flowers.
use PetalConfig;
let config = PetalConfig ;
Shard
Irregular rock-chip / debris-flake silhouette: a jittered polygon with a darkened rim and noise-grained interior. Impact debris, crumbling masonry, shattered ice, kicked-up gravel.
use ShardConfig;
let config = ShardConfig ;
Flame
A single tongue of fire: a teardrop envelope displaced by fractal turbulence that grows toward the tip, with a core→mid→tip colour ramp. Per-variant cells jitter lean, elongation, and turbulence phase, so random atlas frames read as flicker. Pairs well with additive blending.
use FlameConfig;
let config = FlameConfig ;
Flower
A radially composed blossom: petal blades (the petal sampler re-aimed
outward) under a domed, stamen-dotted centre disc — the sprite counterpart
of how twig composites leaves. Every petal in every variant draws its
own jitter stream.
use FlowerConfig;
use PetalConfig;
let config = FlowerConfig ;
Leaf Sprite
The atlas counterpart of the single-leaf foliage card: every cell bakes a per-cell-seeded leaf variant with bounded jitter on serration, lobes, vein count, and a green-preserving colour tint. Falling-foliage particle systems get per-particle leaf variety from one bake.
use LeafConfig;
use LeafSpriteConfig;
let config = LeafSpriteConfig ;
Grass Tuft
A clump of curved, tip-tapered grass blades fanning from a common root line at the bottom edge — the workhorse ground-cover billboard. Blades jitter height, lean, curvature, width, and dryness per variant.
use GrassTuftConfig;
let config = GrassTuftConfig ;
Reed
A shoreline reed / cattail clump: tall, near-vertical strap leaves rising from a common waterline base, with an optional share of stalks topped by the cattail's brown catkin spike. Far taller and straighter than the grass tuft.
use ReedConfig;
let config = ReedConfig ;
Needle
A conifer needle-cluster shoot — the conifer counterpart of the broadleaf
twig card. Paired needles splay outward and forward from a woody axis,
shortening toward the tip. A wide needle_angle with long needles reads
as pine, a narrow angle with short needles as spruce, a high pair_count
with minimal taper as fir.
use NeedleConfig;
let config = NeedleConfig ;
Frond
A single leaflet (pinna) of a pinnate frond: a narrow lanceolate strap with a strong central midrib and shallow pinnate veins. One depth knob spans an entire (palm-leaflet) margin to the lobed pinnule of a fern — the drop-in leaflet card for an L-system palm or fern whose rachis geometry is drawn by the grammar.
use FrondConfig;
let config = FrondConfig ;
Broadleaf
A palmate broadleaf built in polar coordinates about its petiole
attachment: a radius function with lobe_count peaks carves the classic
maple / sycamore / ivy silhouettes, with main veins radiating to each lobe
tip and an optional cordate (heart) base notch. lobe_count: 1.0 with a
shallow depth yields a plain ovate blade, so one generator covers both the
palmate and simple-broadleaf families — a different leaf form from the
pinnate, midrib-based leaf card.
use BroadleafConfig;
let config = BroadleafConfig ;
Evolutionary parameter search (genetics)
All config types implement symbios_genetics::Genotype, making them
compatible with the evolutionary algorithms in the symbios-genetics crate
(SimpleGA, Nsga2, MapElites).
Each field is independently perturbed during mutation and drawn uniformly from one of two parents during crossover:
use Genotype;
use BarkConfig;
use SeedableRng;
let mut config = default;
let mut rng = seed_from_u64;
config.mutate; // perturb each field with 30 % probability
let parent_b = BarkConfig ;
let child = config.crossover;
The texture_viewer example uses this to mutate any displayed material when
you click Mutate.
The Genotype implementations and the egui editor widgets are generated by
declarative macros (impl_genotype! / impl_config_editor!) rather than
hand-written per-config boilerplate. Each macro invocation declares the
config struct, field kinds (seed, f64, colour, enum, etc.), and optional
post-hooks for tiling-invariant fixups, keeping the per-config call site
small while covering all 48 config types.
TextureConfig itself also implements Genotype (mutation delegates to the
wrapped config; crossover recombines like variants field-wise) and exposes
registry-derived helpers — all_defaults() for dropdowns and benches,
module_name() for stable identifiers, generate_sync() for synchronous
dispatch, and (behind the egui feature) ui::texture_config_editor for
variant-generic parameter editing. The texture_viewer example and the
criterion bench suite are built entirely on these, so they extend
automatically when a generator is added to the registry.
Architecture
The crate is a two-layer stack: the Bevy-free core —
symbios-texture — owns
everything in the diagram below and is re-exported wholesale, while this
wrapper adds the Bevy layer on top: SymbiosTexturePlugin, the async
generation pool, the Image upload adapters (map_to_images /
map_to_images_card), the TextureCache resource, the
procedural-material builder, and the egui editors.
TextureGenerator (trait)
│
│ Tileable surface textures
├── BarkGenerator ─── ToroidalNoise (domain-warped FBM + Worley plates)
├── RockGenerator ─── ToroidalNoise (RidgedMulti)
├── GroundGenerator ─── ToroidalNoise × 2 (dual-scale FBM)
├── BrickGenerator ─── ToroidalNoise FBM + rounded-box SDF grid
├── PlankGenerator ─── ToroidalNoise FBM + Worley knots (anisotropic)
├── ConcreteGenerator ─── ToroidalNoise FBM + cosine formwork + pit FBM
├── MetalGenerator ─── ToroidalNoise FBM (brushed/standing-seam) + rust FBM
├── ShingleGenerator ─── ToroidalNoise FBM + sawtooth overlap ramp
├── PaversGenerator ─── ToroidalNoise FBM + square/hex SDF grid
├── StuccoGenerator ─── ToroidalNoise FBM (high-frequency, matte)
├── AshlarGenerator ─── ToroidalNoise FBM + irregular SDF grid + chisel edge
├── CobblestoneGenerator─── toroidal Voronoi (domed F1, mud gap at F2−F1)
├── MarbleGenerator ─── ToroidalNoise FBM (domain-warped sinusoidal veins)
├── ThatchGenerator ─── ToroidalNoise FBM (anisotropic fibre + sawtooth layers)
├── CorrugatedGenerator ─── sine-wave ridge profile + rust FBM
├── AsphaltGenerator ─── ToroidalNoise FBM × 3 (macro/micro/aggregate)
├── WainscotingGenerator─── ToroidalNoise grain FBM + panel margin SDF
├── EncausticGenerator ─── ToroidalNoise glaze FBM + geometric pattern SDF
├── FabricGenerator ─── perpendicular thread lattice + over/under weave
├── SandGenerator ─── warped sine ripples + grain flecks
├── SnowGenerator ─── FBM drift relief + sparkle flecks
├── IceGenerator ─── sinusoidal crack veins + frost patches
├── LavaGenerator ─── toroidal Voronoi plates + emissive crack glow
├── MossGenerator ─── ToroidalNoise FBM × 3 (cushion/filament/dry)
├── LichenGenerator ─── ToroidalNoise FBM (thresholded thallus patches)
├── CactusSkinGenerator ─── periodic rib/areole lattice + sinusoid mottle
│
│ Alpha-masked cards
├── LeafGenerator ─── LeafSampler (silhouette + venation)
├── TwigGenerator ─── LeafSampler × N (composite stem + leaves)
├── WindowGenerator ─── rounded-box SDF frame/mullions + FBM grime
├── StainedGlassGenerator── toroidal Voronoi + lead came SDF + grime FBM
├── IronGrilleGenerator ─── bar SDF grid + joint rust FBM
├── ChainLinkGenerator ─── diagonal wire lattice + over/under weave
├── LogEndGenerator ─── warped concentric rings + bark rim
│
│ Sprite atlases (alpha-masked cards, via sprite::generate_atlas)
├── SoftDiscGenerator ─── radial-falloff disc (core + halo)
├── SparkGenerator ─── N-armed streak burst
├── SnowflakeGenerator ─── dendritic N-fold flake
├── PuffGenerator ─── domain-warped FBM blob + radial mask
├── RingGenerator ─── soft annulus + angular waviness
├── PetalGenerator ─── obovate blade + throat/edge gradient
├── ShardGenerator ─── jittered polygon chip + grain FBM
├── LeafSpriteGenerator ─── LeafSampler atlas (per-cell leaf variants)
├── FlameGenerator ─── teardrop envelope + FBM turbulence
├── FlowerGenerator ─── PetalCell × N (radial composite blossom)
├── GrassTuftGenerator ─── fanned, curved blade ribbons
├── FrondGenerator ─── lanceolate pinna + pinnate veins
├── ReedGenerator ─── strap leaves + catkin spikes
├── NeedleGenerator ─── paired-needle conifer shoot
└── BroadleafGenerator ─── polar palmate silhouette + radiating veins
│
height_to_normal() → normal map
linear_to_srgb() → albedo encoding
│
TextureMap { albedo, normal, roughness, emissive? }
│
map_to_images() → GeneratedHandles (repeat sampler)
map_to_images_card() → GeneratedHandles (clamp sampler)
│
full mipmap chain (type-correct averaging)
Noise-in-constructor — the surface generators and the SDF-based cards
(window, stained glass, iron grille) build their noise objects
(Fbm<Perlin>, RidgedMulti<Perlin>, ToroidalNoise<…>) once in new()
and store them as struct fields. Calling generate() multiple times (e.g.
to produce size variants of the same material) skips the initialisation cost.
Worley is the exception: it contains an Rc and is therefore !Send /
!Sync, so the generators that use it (BarkGenerator, PlankGenerator)
construct it locally — and, since generation is row-parallel, once per row
inside the parallel loop (the construction cost is microseconds against the
per-row pixel work). The foliage cards (LeafGenerator, TwigGenerator —
leaf sampling also uses Worley) and the atlas generators hold only their
config and build their samplers per generate() call. The cell-decomposition
surfaces (CobblestoneGenerator, LavaGenerator) instead use a dependency-free,
Sync hash-based toroidal Voronoi (noise::toroidal_voronoi).
Workspace buffer pooling — generators that allocate large intermediate
grids (e.g. BarkGenerator, ThatchGenerator) accept an optional
Workspace via generate_with_workspace(). The workspace maintains a
pool of Vec<f64> buffers that are borrowed and returned across calls,
eliminating repeated 128 MB+ allocations at 4096×4096 resolution.
Seamless tiling is provided by ToroidalNoise, which maps 2-D UV
coordinates onto a 4-D torus so that noise wraps perfectly at every edge:
nx = cos(2π·u) · frequency
ny = sin(2π·u) · frequency
nz = cos(2π·v) · frequency
nw = sin(2π·v) · frequency
Because cos(0) = cos(2π) and sin(0) = sin(2π), u=0 and u=1 always
resolve to the same 4-D point, guaranteeing zero-seam tiling.
Normal maps are derived from the height field via central-difference gradients. For the tileable surface textures the neighbours wrap toroidally, so the normals are also seamless. For card textures (the foliage and architectural cards and the whole atlas family) the boundary uses clamp-to-edge so normals do not bleed across the transparent silhouette border. Sprite atlases additionally dilate heights into fully-transparent texels before derivation so the normals do not crease at silhouette edges.
Colour encoding uses a 4096-entry sRGB lookup table (built once via
OnceLock) to avoid repeated f32::powf calls during rasterisation.
A 256-entry table would be insufficient because the sRGB curve is steep
near zero; 4096 bins keep the maximum quantisation error well below one
count in u8.
Mipmap generation uses a 2×2 box filter with type-correct averaging: sRGB
values are decoded to linear light before averaging and re-encoded afterward
(avoiding dark mipmaps), normal-map XYZ vectors are averaged and renormalized
(avoiding zero-length normals in PBR shaders), and ORM values are averaged
directly in linear space. Async generation tasks precompute the full chain
on the worker thread (TextureMap::with_mips), so the main-thread upload in
the polling systems is a pure buffer move; map_to_images /
map_to_images_card compute the chain on demand for maps without one
(synchronous callers, cache loads). 16× anisotropic filtering is enabled on
all samplers.
Examples
texture_viewer
Displays an interactive material viewer with three columns: albedo (left), normal map (centre), and a 3-D PBR preview (right) with the generated material applied. Tileable surface textures are shown on a spinning cube; alpha-masked cards and sprite atlases get a gently swaying alpha-blended quad in front of a checkerboard backdrop instead, so per-pixel alpha is visible. An egui panel on the left lets you select any of the 48 generators from a dropdown, trigger a random Mutate (rate = 0.3), and edit every parameter live.
procedural_material
Side-by-side comparison of build_procedural_material_async (left cube)
against the manual PendingTexture + material-patching flow it replaces
(right cube).
animated_rust
Animates rust coverage on a metal panel from 0 % to 100 % over ten seconds
via AnimatedProceduralMaterial driving a Linear curve, throttled to
roughly four regenerations per second.
License
MIT — see LICENSE.