| 1 |
// Taken from https://www.shadertoy.com/view/MdlXz8 |
| 2 |
|
| 3 |
// Found this on GLSL sandbox. I really liked it, changed a few things and made it tileable. |
| 4 |
// :) |
| 5 |
// by David Hoskins. |
| 6 |
|
| 7 |
|
| 8 |
// Water turbulence effect by joltz0r 2013-07-04, improved 2013-07-07 |
| 9 |
|
| 10 |
|
| 11 |
// Redefine below to see the tiling... |
| 12 |
//#define SHOW_TILING |
| 13 |
|
| 14 |
#define TAU 6.28318530718 |
| 15 |
#define MAX_ITER 5 |
| 16 |
|
| 17 |
void mainImage( out vec4 fragColor, in vec2 fragCoord ) |
| 18 |
{ |
| 19 |
float time = iTime * .5+23.0; |
| 20 |
// uv should be the 0-1 uv of texture... |
| 21 |
vec2 uv = fragCoord.xy / iResolution.xy; |
| 22 |
|
| 23 |
#ifdef SHOW_TILING |
| 24 |
vec2 p = mod(uv*TAU*2.0, TAU)-250.0; |
| 25 |
#else |
| 26 |
vec2 p = mod(uv*TAU, TAU)-250.0; |
| 27 |
#endif |
| 28 |
vec2 i = vec2(p); |
| 29 |
float c = 1.0; |
| 30 |
float inten = .005; |
| 31 |
|
| 32 |
for (int n = 0; n < MAX_ITER; n++) |
| 33 |
{ |
| 34 |
float t = time * (1.0 - (3.5 / float(n+1))); |
| 35 |
i = p + vec2(cos(t - i.x) + sin(t + i.y), sin(t - i.y) + cos(t + i.x)); |
| 36 |
c += 1.0/length(vec2(p.x / (sin(i.x+t)/inten),p.y / (cos(i.y+t)/inten))); |
| 37 |
} |
| 38 |
c /= float(MAX_ITER); |
| 39 |
c = 1.17-pow(c, 1.4); |
| 40 |
vec3 colour = vec3(pow(abs(c), 8.0)); |
| 41 |
colour = clamp(colour + vec3(0.0, 0.35, 0.5), 0.0, 1.0); |
| 42 |
|
| 43 |
|
| 44 |
#ifdef SHOW_TILING |
| 45 |
// Flash tile borders... |
| 46 |
vec2 pixel = 2.0 / iResolution.xy; |
| 47 |
uv *= 2.0; |
| 48 |
|
| 49 |
float f = floor(mod(iTime*.5, 2.0)); // Flash value. |
| 50 |
vec2 first = step(pixel, uv) * f; // Rule out first screen pixels and flash. |
| 51 |
uv = step(fract(uv), pixel); // Add one line of pixels per tile. |
| 52 |
colour = mix(colour, vec3(1.0, 1.0, 0.0), (uv.x + uv.y) * first.x * first.y); // Yellow line |
| 53 |
|
| 54 |
#endif |
| 55 |
fragColor = vec4(colour, 1.0); |
| 56 |
} |