Skip to content

Instantly share code, notes, and snippets.

@volfegan
Created June 3, 2022 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save volfegan/21be142e2448fe994c67c583523338d4 to your computer and use it in GitHub Desktop.
Save volfegan/21be142e2448fe994c67c583523338d4 to your computer and use it in GitHub Desktop.
Eerie plasma fog in XOR landscape
//remix of https://www.youtube.com/watch?v=R-8fEyod3fw
//https://github.com/leonardo-ono/JavaOldPlasmaEffectTest/blob/master/src/oldplasmaeffecttest/OldPlasmaEffectTestPanel.java
float t;
void setup() {
size(1280, 720);
colorMode(HSB, 255, 255, 255);
noStroke();
}
void draw() {
clear();
t+=.1;
for (int y=0; y< height; y+=5) {
for (int x=0; x< width; x+=5) {
int v = (int)plasma(x, y, t);
int b = ((int)(plasma(x^y, y&x, t*.5)));
//fill(v); //metalic rotating reflection
//fill(b/3+v/2); //XOR patterns and round plasma with rotating reflection
fill(b/3+v/2, 128, b);
rect(x, y, 5, 5);
}
}
//saveFrame("frame_######.png");
}
float plasma(float x, float y, float t) {
float k = (t + ((int)x>>16)) * .05; //((int)x>>16) gives a rotation light effect
float l = (t - y) * .01;
float v1 = 128 + 128 * sin(0.075 * (x * sin(k) + y * cos(k * 3)));
float v2 = 128 + 128 * sin(0.0055 * (x * cos(l * .3) + y * sin(k * 7)));
float v3 = 128 + 128 * cos((t + y/43) * .5);
float v4 = 128 + 128 * sin((t + x/19) * .4);
float v5 = 128 + 128 * sin(k+l + sqrt(v3 + v4));
float v6 = (v1 + v2 + v5) / 3;
return v6;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment