Skip to content

Instantly share code, notes, and snippets.

@vlucendo
Last active June 2, 2018 10:37
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 vlucendo/faf1d41b27128e504c9912c6895ceb13 to your computer and use it in GitHub Desktop.
Save vlucendo/faf1d41b27128e504c9912c6895ceb13 to your computer and use it in GitHub Desktop.
float getPath(float progress) {
float scale = 1.5;
float p = (progress + 42.) * (1. / scale);
// float sin1 = sin(p * 0.1) * 5.;
// float sin2 = sin(2.2 * p * 0.1 + 5.52) * 2.5;
// float sin3 = sin(2.9 * p * 0.2 + 0.93) * 1.2;
// float sin4 = sin(4.6 * p * 0.2 + 8.94) * 0.5;
float sin1 = sin(p * 0.1) * 5.;
float sin2 = sin(p * 0.22 + 5.52) * 2.5;
float sin3 = sin(p * 0.58 + 0.93) * 1.2;
float sin4 = sin(p * 0.92 + 8.94) * 0.5;
return (sin1 + sin2 + sin3 + sin4) * scale * 2.2;
// return sin(progress);
}
vec3 flow(vec3 position, float time, float offset, float flowOffset) {
vec2 point = vec2(getPath(time), -time * depth);
vec2 normal = vec2(-time * depth, -getNormal(time));
normal = normalize(normal);
offset *= (sin(time) * sin(time * 2.) + 1.5) * 0.25;
offset *= 18. * flowOffset;
offset += sin(time) * sin(time * 2.) * 0.12;
vec3 current = vec3(point.x, 0., point.y);
current.xz += normal * offset;
float height = 1. * ((sin(position.x) + sin(position.z)) * 0.5);
height += 0.5 * ((sin(position.x * 2.) + sin(position.z * 1.5)) * 0.5);
current.y += height * .2;
return current;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment