home/ atoms/ sine-wave-palette-variation

Aliased high-frequency sine waves produce pseudo-random variation suitable for per-instance seeding

A pure sine wave is periodic and predictable. By inputting very large arguments (e.g. sin(cellID.x * 127.1 + cellID.y * 311.7)), the sine samples at irregular phases that appear random to the eye. This exploits Nyquist aliasing: the effective sampling is much coarser than the period, producing apparently uncorrelated outputs for nearby integer IDs. This avoids the need for hash functions or noise textures for per-instance randomization. The technique is limited to non-correlated variation; for high-quality randomness a proper hash or blue noise texture is preferred.

Examples

float rnd = fract(sin(dot(cellID, vec2(127.1, 311.7))) * 43758.5453);

Assessment

What happens if you use sin(cellID.x * 1.0) (low frequency) for color variation? Describe the visual pattern and why it fails as pseudo-random seeding.

“big numbers that we enter the territory of aliasing, so the sine wave will aliase, because we are gonna be evaluating it at apart points”
corpus · inigo-quilez-live-coding-happy-jumping-video · chunk 15