Textures in foo_vis_milk2

Presets use textures to add images, patterns, and visual detail to their effects. foo_vis_milk2 supports both built-in textures (procedurally generated noise and blur) and user textures (image files loaded from disk). This guide explains how textures work and how to set up your texture library.

Supported Formats

Extension Format
.jpg JPEG
.jpeg JPEG (explicit filename loads via WIC)
.png PNG (with alpha)
.bmp .dib Windows Bitmap
.tga Targa
.dds DirectDraw Surface

All formats are loaded via Windows Imaging Component (WIC) or the DDS loader from DirectXTK and converted to GPU-compatible formats internally.

Where to Put Textures

When a preset requests a texture (or sprite), foo_vis_milk2 searches for a matching file in the following order:

Priority Location
1 milkdrop2\textures\
2 milkdrop2\sprites\
3 The configured preset directory (milkdrop2\presets\ by default)
4 The directory containing the current preset file

At each location, the following extensions are tried in order: .jpg, .png, .dds, .tga, .bmp, .dib. The first match found is used. If the current preset's directory is the same as one of the earlier paths, it is skipped to avoid redundant lookups.

Built-in Textures

These textures are always available to presets. They are generated procedurally at startup and don't require files on disk.

2D Noise Textures

Sampler Name Size Description
noise_lq 256×256 Low-quality noise (bilinear interpolation)
noise_lq_lite 32×32 Low-quality noise (smaller, lighter)
noise_mq 256×256 Mid-quality noise (4× cubic interpolation)
noise_hq 256×256 High-quality noise (8× cubic interpolation)

3D Volume Textures

Sampler Name Size Description
noisevol_lq 32×32×32 Low-quality 3D noise volume
noisevol_hq 32×32×32 High-quality 3D noise volume (4× cubic interpolation)

Volume textures are sampled with tex3D() in shader code and are useful for smooth, organic 3D noise effects.

Blur Textures

Sampler Name Description
blur1 First blur level (lightest blur)
blur2 Second blur level
blur3 Third blur level (heaviest blur)

Up to 6 blur layers are available. These provide Gaussian-blurred versions of the current frame at decreasing resolutions.

Frame Textures

Sampler Name Description
main The previous frame's rendered output

The main sampler gives presets access to the previous frame for feedback effects, trails, and motion blur.

Random Textures

Presets can request a random texture using the rand## naming convention:

sampler_rand05             — random texture from slot 5
sampler_rand05_smalltiled  — random texture with "smalltiled" prefix filter

The number after rand identifies a slot. Each slot picks a random file independently. The optional suffix filters files by filename prefix.

Sampler Options (Preset Authors)

Preset shaders declare texture samplers with an optional two-letter prefix that controls filtering and edge behavior:

Prefix Filtering Wrapping Use Case
FW_ (or WF_) Bilinear Wrap (tile) Tiling textures (default for disk textures)
FC_ (or CF_) Bilinear Clamp Non-tiling textures, photo overlays
PW_ (or WP_) Point (nearest) Wrap Pixel-art textures that tile
PC_ (or CP_) Point (nearest) Clamp Pixel-art, lookup tables

Examples in HLSL:

sampler2D sampler_fw_clouds;  // bilinear + wrap (tiling clouds)
sampler2D sampler_pc_lut;     // point + clamp (color lookup table)
sampler2D sampler_clouds;     // no prefix = bilinear + wrap (default)

Texture Cache

foo_vis_milk2 keeps loaded textures in a GPU memory cache to avoid reloading the same file repeatedly. The cache size is configurable:

Setting Default Description
Max cached images 32 Maximum number of cached texture images
Max cached bytes Memory limit for the texture cache

When the cache is full, older textures from previous presets are evicted. They are reloaded automatically if a future preset needs them.

Tips