Skip to content

Instantly share code, notes, and snippets.

@Blokyk
Last active February 23, 2022 16:39
Show Gist options
  • Save Blokyk/caea08ed2b11332cedeebc44a9c0a8d2 to your computer and use it in GitHub Desktop.
Save Blokyk/caea08ed2b11332cedeebc44a9c0a8d2 to your computer and use it in GitHub Desktop.
Cool fluid flow functions -- from anvaka.github.io/fieldplay
// Pay attention to the scaling !
// Some results might look boring or glitchy from afar (or close), but don't fret !
// p.x and p.y are current coordinates
// v.x and v.y is a velocity at point p
// https://bit.ly/3bmvQ58 -- zoomed in
vec2 get_velocity(vec2 p) {
vec2 v = vec2(0., 0.);
// change this to get a new vector field
v.x = max(sin((length(p)+length(p))),(p.y+(cos(cos(p.y))+p.x)));
v.y = cos(sin(min(p.y*length(p),p.x/p.x)));
return v;
}
// https://bit.ly/3BrmoIs -- zoomed in
vec2 get_velocity(vec2 p) {
vec2 v = vec2(0., 0.);
// change this to get a new vector field
v.x = cos(p.y);
v.y = (length(p)+p.y)/sin(p.y);
return v;
}
// https://bit.ly/3mtfiPj -- zoomed out
vec2 get_velocity(vec2 p) {
vec2 v = vec2(0., 0.);
// change this to get a new vector field
v.x = (min(length(p),cos(log(length(p))))*p.x-p.y);
v.y = ((p.y+p.y)-p.x);
return v;
}
// https://bit.ly/3nGjtXs -- really zoomed in
vec2 get_velocity(vec2 p) {
vec2 v = vec2(0., 0.);
// change this to get a new vector field
v.x = length(p)*min(p.y,length(p));
v.y = sin(p.y/max(p.x/p.x,pow(p.y, sin(p.y))));
return v;
}
// https://bit.ly/3CtXt8v -- mostly zoomed in
vec2 get_velocity(vec2 p) {
vec2 v = vec2(0., 0.);
// change this to get a new vector field
v.x = sin(p.y)/min(cos(length(p)),sin(max(p.x*p.x,p.x)));
v.y = cos(p.y/max(p.x,min((length(p)+log(p.x)),p.x)));
return v;
}
//???
vec2 get_velocity(vec2 p) {
vec2 v = vec2(0., 0.);
// change this to get a new vector field
v.x = p.y;
v.y = max((cos(p.x)-p.y),p.x);
return v;
}
//https://bit.ly/3LX1U0s
vec2 get_velocity(vec2 p) {
vec2 v = vec2(0., 0.);
// change this to get a new vector field
v.x = cos(p.x);
v.y = p.y;
return v;
}
//???
vec2 get_velocity(vec2 p) {
vec2 v = vec2(0., 0.);
// change this to get a new vector field
v.x = max(min(p.y,sin(p.y)),p.y/p.x);
v.y = sin(sin((max(p.y,p.x)-max(p.y,(p.y+p.y)))));
return v;
}
//???
vec2 get_velocity(vec2 p) {
vec2 v = vec2(0., 0.);
// change this to get a new vector field
v.x = max(cos((p.y+p.y)),(sin(cos(p.y))-cos(p.x)));
v.y = (sin(min(p.x,exp(sin(p.x)))*length(p)/p.x)+sin(length(p)));
return v;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment