Green Fog wallpaper, Try Fractals!
A WebGL reconstruction of the recursive domain warping technique found in Android’s “Magic Smoke” live wallpaper.
It simulates fluid dynamics and cloud formations not through Navier-Stokes equations, but via iterated fractional Brownian motion (FBM), where the noise domain is distorted by the noise itself.
more retro-goods like Phase Beam、Bubble、Nexus、Water Ripple、Grass can be found in livewall.zip
normal phys:
field:
Logic projection of the shader’s main() loop.
import numpy as np
import matplotlib.pyplot as plt
def noise(p):
# Grid coords & fractional offsets
i = np.floor(p).astype(int); f = p - i
f = f*f*(3 - 2*f) # Hermite smoothing
# Hashing logic (Vectorized)
def h(c):
return (np.sin(c[...,0]*12.9898 + c[...,1]*78.233) * 43758.5453) % 1
# Bilinear interpolation across the 4 corners
a, b = h(i), h(i + [1,0])
c, d = h(i + [0,1]), h(i + [1,1])
return a + (b-a)*f[...,0] + (c-a)*f[...,1] + (a-b-c+d)*f[...,0]*f[...,1]
def fbm(p, octaves=6):
v, amp = 0, .5
for _ in range(octaves):
v += amp * noise(p); p *= 2.; amp *= .5
return v
def warp(p, t):
# q = f(p + d1)
q = np.stack([fbm(p + t), fbm(p + t + 5.2)], axis=-1)
# r = f(p + 4q + d2)
r = np.stack([fbm(p + 4*q + 1.7), fbm(p + 4*q + 9.2)], axis=-1)
# output = f(p + 4r)
return fbm(p + 4*r)
# Execute
res = 256
x = np.linspace(0, 5, res)
grid = np.stack(np.meshgrid(x, x), axis=-1)
img = warp(grid, 0.5)
plt.imshow(img, cmap='magma', origin='lower')
plt.axis('off')
plt.show()