Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const vec2 mid = vec2(0.5,0.5);
- const float PI = 3.1415926535897932384626433832795;
- uniform float timer;
- float rand(vec2 n)
- {
- return fract(sin(dot(n, vec2(12.9898,12.1414))) * 83758.5453);
- }
- float noise(vec2 n)
- {
- const vec2 d = vec2(0.0, 1.0);
- vec2 b = floor(n);
- vec2 f = mix(vec2(0.0), vec2(1.0), fract(n));
- return mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);
- }
- vec3 ramp(float t)
- {
- return t <= .5 ? vec3( 1. - t * 1.4, .2, 1.05 ) / t : vec3( .3 * (1. - t) * 2., .2, 1.05 ) / t;
- }
- float fire(vec2 n)
- {
- return noise(n) + noise(n * 2.1) * .6 + noise(n * 5.4) * .42;
- }
- vec4 electricfire(vec2 fragCoord, float time )
- {
- float t = time;
- vec2 uv = fragCoord;
- uv.y += uv.x < .5 ? 23.0 + t * .35 : -11.0 + t * .3;
- uv.x = abs(uv.x - .5);
- uv *= 2.0; //originally 5 - control width with this!
- float q = fire(uv - t * .013) / 2.0;
- vec2 r = vec2(fire(uv + q / 2.0 + t - uv.x - uv.y), fire(uv + q - t));
- vec3 color = vec3(1.0 / (pow(vec3(0.5, 0.0, .1) + 1.61, vec3(1.0))));
- float grad = pow((r.y + r.y) * max(.0, uv.x) + .1, 4.0);
- color = ramp(grad);
- color /= (1.50 + max(vec3(0), color));
- return vec4(color, 1.0);
- }
- vec4 Process(vec4 color)
- {
- vec2 tc = gl_TexCoord[0].st;
- vec3 shade = vec3(0,0,0);
- vec4 image = getTexel(tc);
- float amount = abs(sin(tc.x * (PI)));
- vec4 ret = vec4(mix(image.rgb,shade,1-amount),image.a);
- vec4 glow = electricfire(tc,timer);
- return vec4(ret.rgb + glow.rgb,ret.a);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement