GLSL shader example
Plasma
The classic plasma effect: add a few sine waves together and map the result to a cosine color palette.
Live example
Edit the code and the preview updates as you type.
How it works
Each sin(...) line is a set of parallel bands moving across the screen: one horizontal, one vertical, one diagonal, and one made of rings around the center (length(p)). Each runs at a slightly different speed.
Adding them together makes the bands interfere. Where crests line up the value peaks, where they cancel it dips. That interference is what produces the organic, swirling look. Dividing by 4 keeps the sum between -1 and 1.
The color line is a cosine palette. The same value v goes into three cosine waves, one per channel, shifted by a third of a cycle each. As v changes smoothly, the color cycles smoothly through the whole spectrum.
Try changing it
| Change | Result |
|---|---|
All 4.0 to 10.0 | Finer, busier bands |
Delete the length(p) line | No rings: a straighter, more grid-like plasma |
vec3(0.0, 0.33, 0.67) to vec3(0.0, 0.1, 0.2) | A warm palette of red, orange and purple |
u_time * 0.8 to u_time * 0.2 | Slow, calm motion |