| 1 |
// Taken from https://www.shadertoy.com/view/lsSGWw |
| 2 |
|
| 3 |
#define ITERATIONS 12 |
| 4 |
#define SPEED 10.0 |
| 5 |
#define DISPLACEMENT 0.05 |
| 6 |
#define TIGHTNESS 10.0 |
| 7 |
#define YOFFSET 0.1 |
| 8 |
#define YSCALE 0.25 |
| 9 |
#define FLAMETONE vec3(50.0, 5.0, 1.0) |
| 10 |
|
| 11 |
float shape(in vec2 pos) // a blob shape to distort |
| 12 |
{ |
| 13 |
return clamp( sin(pos.x*3.1416) - pos.y+YOFFSET, 0.0, 1.0 ); |
| 14 |
} |
| 15 |
|
| 16 |
float noise( in vec3 x ) // iq noise function |
| 17 |
{ |
| 18 |
vec3 p = floor(x); |
| 19 |
vec3 f = fract(x); |
| 20 |
f = f*f*(3.0-2.0*f); |
| 21 |
vec2 uv = (p.xy+vec2(37.0,17.0)*p.z) + f.xy; |
| 22 |
vec2 rg = textureLod( iChannel0, (uv+ 0.5)/256.0, 0.0 ).yx; |
| 23 |
return mix( rg.x, rg.y, f.z ) * 2.0 - 1.0; |
| 24 |
} |
| 25 |
|
| 26 |
void mainImage( out vec4 fragColor, in vec2 fragCoord ) |
| 27 |
{ |
| 28 |
vec2 uv = fragCoord.xy / iResolution.xy; |
| 29 |
float nx = 0.0; |
| 30 |
float ny = 0.0; |
| 31 |
for (int i=1; i<ITERATIONS+1; i++) |
| 32 |
{ |
| 33 |
float ii = pow(float(i), 2.0); |
| 34 |
float ifrac = float(i)/float(ITERATIONS); |
| 35 |
float t = ifrac * iTime * SPEED; |
| 36 |
float d = (1.0-ifrac) * DISPLACEMENT; |
| 37 |
nx += noise( vec3(uv.x*ii-iTime*ifrac, uv.y*YSCALE*ii-t, 0.0)) * d * 2.0; |
| 38 |
ny += noise( vec3(uv.x*ii+iTime*ifrac, uv.y*YSCALE*ii-t, iTime*ifrac/ii)) * d; |
| 39 |
} |
| 40 |
float flame = shape( vec2(uv.x+nx, uv.y+ny) ); |
| 41 |
vec3 col = pow(flame, TIGHTNESS) * FLAMETONE; |
| 42 |
|
| 43 |
// tonemapping |
| 44 |
col = col / (1.0+col); |
| 45 |
col = pow(col, vec3(1.0/2.2)); |
| 46 |
col = clamp(col, 0.0, 1.0); |
| 47 |
|
| 48 |
fragColor = vec4(col, 1.0); |
| 49 |
} |