Page:
patterns-animation-Plasma-Effect
Pages
Home
nodes-scriptable-conditioning
nodes-scriptable-empty-latent
nodes-scriptable-image
nodes-scriptable-latent
nodes-scriptable-mask
nodes-scriptable-noise
patterns-Overview
patterns-animation-Mandelbrot-Zoom
patterns-animation-Overview
patterns-animation-Perlin-Noise-Fractal
patterns-animation-Plasma-Effect
patterns-animation-Recursive-Pattern
patterns-animation-Sine-Wave-Interference
patterns-earthbound-Color-Cycling-Gradient
patterns-earthbound-Earthbound-Warping-Distortion
patterns-earthbound-Fractal-Brownian-Motion
patterns-earthbound-HDMA-Scanline-Loop
patterns-earthbound-HDMA-Scanline-Shift
patterns-earthbound-Kaleidoscope-Loop
patterns-earthbound-Moire-Interference-Loop
patterns-earthbound-Moire-Interference
patterns-earthbound-Multi-Layer-Plasma
patterns-earthbound-Overview
patterns-earthbound-Radial-Breathing-Loop
patterns-earthbound-Rotating-Fractal-Loop
patterns-earthbound-Seamless-Plasma-Loop
patterns-mathematical-foundations
patterns-psychedelic-Fractal-Noise-Gradient
patterns-psychedelic-Overview
patterns-psychedelic-Plasma-Color-Cycling
patterns-psychedelic-Scanline-Shift
scriptable-conditioning
scriptable-empty-latent
scriptable-image
scriptable-latent
scriptable-mask
scriptable-noise
No results
2
patterns-animation-Plasma-Effect
Balazs Horvath edited this page 2026-04-18 11:13:06 +02:00
Plasma Effect
Torch-based plasma effect with color cycling, demonstrating sine wave superposition.
Mathematical Formula
P(x, y, t) = \frac{\sin(x + \omega_1 t) + \sin(y + \omega_2 t) + \sin(\frac{x+y}{2} + \omega_3 t)}{3}
Where:
\omega_1, \omega_2, \omega_3are temporal frequencies- Three sine waves create interference pattern
- Color cycling with phase shifts
How It Works
Plasma effects demonstrate wave superposition. Multiple sine waves with different orientations combine to create complex, flowing patterns. Color cycling adds time-based color shifts.
Implementation
import torch
# Generate plasma effect frames
width, height = 512, 512
frames = []
for t in range(30):
x = torch.linspace(0, 2*torch.pi, width)
y = torch.linspace(0, 2*torch.pi, height)
X, Y = torch.meshgrid(x, y, indexing='ij')
# Plasma formula with time variation
plasma = torch.sin(X + t/5) + torch.sin(Y + t/5) + torch.sin((X+Y)/2 + t/5)
plasma = (plasma + 3) / 6 # Normalize to 0-1
# Convert to RGB with color cycling
r = torch.sin(plasma * torch.pi + t/10)
g = torch.sin(plasma * torch.pi + t/10 + 2*torch.pi/3)
b = torch.sin(plasma * torch.pi + t/10 + 4*torch.pi/3)
rgb = torch.stack([r, g, b], dim=-1)
rgb = ((rgb + 1) / 2) # Normalize to 0-1
frames.append(rgb)
output_image = torch.stack(frames, dim=0) # Shape: [30, H, W, 3]
Line-by-Line Explanation
plasma = torch.sin(X + t/5) + torch.sin(Y + t/5) + torch.sin((X+Y)/2 + t/5)
Three sine waves: horizontal, vertical, and diagonal.
plasma = (plasma + 3) / 6
Normalizes from [-3, 3] to [0, 1].
r = torch.sin(plasma * torch.pi + t/10)
Maps plasma value to red with time variation.
Customization
More Waves
plasma = (torch.sin(X + t/5) + torch.sin(Y + t/5) +
torch.sin((X+Y)/2 + t/5) + torch.sin((X-Y)/2 + t/5)) / 4
Different Speed
plasma = torch.sin(X + t/10) + torch.sin(Y + t/10) # Slower
References
- See also: Multi-Layer Plasma