2 patterns-psychedelic-Fractal-Noise-Gradient
Balazs Horvath edited this page 2026-04-18 11:13:10 +02:00

Fractal Noise Gradient

Multi-scale noise with psychedelic color mapping and subtle rotation effect.

Mathematical Formula


\text{noise} = \sum_{i=0}^{N} 2^{-i} \cdot n(2^i \cdot x)

\text{gradient} = \frac{\text{noise} - \min}{\max - \min}

R = \text{gradient}

G = \text{gradient} + \frac{2\pi}{3}

B = \text{gradient} + \frac{4\pi}{3}

Where:

  • i is octave index
  • n() is noise function
  • Normalization maps to [0, 1].

How It Works

Fractal noise creates organic-looking textures by summing noise at multiple scales. Each octave has higher frequency but lower amplitude, creating detail at multiple scales. Cross-channel color mixing creates a psychedelic palette.

Implementation

import torch
from scipy.ndimage import gaussian_filter
import numpy as np

width, height = 512, 512
frames = []

for t in range(30):
    # Generate noise at multiple scales
    noise_layers = []
    for scale in [4, 8, 16, 32]:
        noise = torch.rand(height//scale, width//scale).numpy()
        noise = gaussian_filter(noise, sigma=2)
        noise = torch.tensor(noise).unsqueeze(-1).repeat(1, 1, 3)
        noise = torch.nn.functional.interpolate(
            noise.unsqueeze(0), 
            size=(height, width), 
            mode='bilinear'
        ).squeeze(0)
        noise_layers.append(noise)
    
    # Combine layers
    fractal = sum(noise_layers) / len(noise_layers)
    
    # Map to psychedelic palette (purple, pink, cyan)
    r = fractal[:, :, 0] * 0.6 + fractal[:, :, 1] * 0.4
    g = fractal[:, :, 1] * 0.5 + fractal[:, :, 2] * 0.5
    b = fractal[:, :, 2] * 0.7 + fractal[:, :, 0] * 0.3
    
    rgb = torch.stack([r, g, b], dim=-1).clamp(0, 1)
    
    # Add subtle rotation effect
    angle = t * 0.05
    rgb = torch.rot90(rgb, k=int(angle / (torch.pi/2)))
    
    frames.append(rgb)

output_image = torch.stack(frames, dim=0)

Line-by-Line Explanation

for scale in [4, 8, 16, 32]:

Iterates through octaves (powers of 2).

noise = gaussian_filter(noise, sigma=2)

Smooths noise to create spatially coherent patterns.

r = fractal[:, :, 0] * 0.6 + fractal[:, :, 1] * 0.4

Cross-channel mixing: red gets 60% from itself + 40% from green.

rgb = torch.rot90(rgb, k=int(angle / (torch.pi/2)))

Rotates by 90° increments based on time.

Customization

More Octaves

for scale in [2, 4, 8, 16, 32, 64]:

Different Sigma

noise = gaussian_filter(noise, sigma=5)  # Smoother

No Rotation

# Remove rotation line

References