Module noise

Module noise 

Source
Expand description

Procedural noise textures for the noise texture pack.

MilkDrop 2 ships every preset with a fixed set of noise textures sampled by user comp shaders. The names and resolutions follow Geiss’s reference implementation (mirrored in projectM’s PerlinNoise.cpp):

NameShapeChannelsUsed by
noise_lq256 × 256RGBA874 / 168 in-the-wild comps
noise_mq64 × 64RGBA81 / 168
noise_hq32 × 32RGBA842 / 168
noisevol_lq32 × 32 × 32RGBA84 / 168
noisevol_hq8 × 8 × 8RGBA877 / 168

Reference MilkDrop generates each byte with rand() & 0xFF and lets the sampler’s bilinear/trilinear filtering produce smooth pseudo-noise. Matching that exactly fixes the visual style every authored preset was tuned against, so we mirror it: independent xorshift32 stream per texture, seeded deterministically so reload paths produce bit-identical frames.

The textures are generated once at engine init; the data lives in CPU memory long enough to upload to the GPU and is then dropped.

Structs§

NoisePack
Full noise pack used by the comp pass. Names match MD2 sampler conventions (sampler_noise_lq, sampler_noisevol_hq, …) without the sampler_ prefix.
NoiseTexture
Dimensions + byte payload for one noise texture. RGBA8 layout in all cases: 4 bytes per texel, tightly packed in row-major (and slice-major for the 3D textures), no padding.
XorShift32 🔒
Tiny deterministic PRNG. Replaces rand() from MilkDrop’s reference without taking a workspace-wide dependency for a few hundred KB of init data. Mixed with the texture name’s first byte so the three 2D and two 3D textures don’t share a stream.

Functions§

gen_2d 🔒
gen_3d 🔒