Expand description
User-loaded texture pool for the comp pass.
MilkDrop 2 lets preset authors reference image files on disk via
sampler sampler_<NAME>; declarations in the comp shader, then sample them
through tex2D(sampler_<NAME>, uv). The image filename (stem) becomes the
sampler name — clouds.png → sampler_clouds. Authors also reference
sampler_rand00..15 to pull a deterministic-per-preset random texture from
whatever’s on disk, optionally filtered by name prefix
(sampler_rand02_smalltiled → only smalltiled*.png).
This module owns the disk-loaded GPU textures. The comp pipeline reads
through it at preset load time to populate the 8 user-texture binding slots.
Lookup is by canonicalised name (lowercase stem, no extension); presets in
the wild mix case freely (sampler_Worms vs sampler_worms).
Pool population is best-effort:
- Missing directory → empty pool (engine continues with the fallback 1×1 white texture). Logged once at debug level.
- Unreadable / undecodable file → skipped with a warn log; rest of the directory loads.
- Name collisions across directories → first hit wins; later directories only fill gaps. Matches MD2’s “search path” semantics.
Structs§
- Texture
Pool - Texture pool. Hold one per renderer; the comp pipeline borrows it whenever a preset’s user shader needs to bind disk-loaded textures.
- User
Texture - One GPU-resident user texture.
Functions§
- canonical_
stem 🔒 - default_
texture_ dirs - XDG-default search paths for user textures. The renderer’s caller (CLI / GUI) typically extends this with config-driven dirs.
- load_
texture_ 🔒file - make_
fallback_ 🔒texture - upload_
rgba8 🔒