Guest User

Untitled

a guest
Jun 9th, 2019
71
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const vec2 mid = vec2(0.5,0.5);
  2. const float PI = 3.1415926535897932384626433832795;
  3. uniform float timer;
  4.  
  5. float rand(vec2 n)
  6. {
  7. return fract(sin(dot(n, vec2(12.9898,12.1414))) * 83758.5453);
  8. }
  9.  
  10. float noise(vec2 n)
  11. {
  12. const vec2 d = vec2(0.0, 1.0);
  13. vec2 b = floor(n);
  14. vec2 f = mix(vec2(0.0), vec2(1.0), fract(n));
  15. return mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);
  16. }
  17.  
  18. vec3 ramp(float t)
  19. {
  20. return t <= .5 ? vec3( 1. - t * 1.4, .2, 1.05 ) / t : vec3( .3 * (1. - t) * 2., .2, 1.05 ) / t;
  21. }
  22.  
  23. float fire(vec2 n)
  24. {
  25. return noise(n) + noise(n * 2.1) * .6 + noise(n * 5.4) * .42;
  26. }
  27.  
  28. vec4 electricfire(vec2 fragCoord, float time )
  29. {
  30.  
  31. float t = time;
  32. vec2 uv = fragCoord;
  33.  
  34. uv.y += uv.x < .5 ? 23.0 + t * .35 : -11.0 + t * .3;
  35. uv.x = abs(uv.x - .5);
  36. uv *= 2.0; //originally 5 - control width with this!
  37.  
  38. float q = fire(uv - t * .013) / 2.0;
  39. vec2 r = vec2(fire(uv + q / 2.0 + t - uv.x - uv.y), fire(uv + q - t));
  40. vec3 color = vec3(1.0 / (pow(vec3(0.5, 0.0, .1) + 1.61, vec3(1.0))));
  41.  
  42. float grad = pow((r.y + r.y) * max(.0, uv.x) + .1, 4.0);
  43. color = ramp(grad);
  44. color /= (1.50 + max(vec3(0), color));
  45. return vec4(color, 1.0);
  46. }
  47.  
  48. vec4 Process(vec4 color)
  49. {
  50. vec2 tc = gl_TexCoord[0].st;
  51. vec3 shade = vec3(0,0,0);
  52. vec4 image = getTexel(tc);
  53. float amount = abs(sin(tc.x * (PI)));
  54. vec4 ret = vec4(mix(image.rgb,shade,1-amount),image.a);
  55. vec4 glow = electricfire(tc,timer);
  56.  
  57. return vec4(ret.rgb + glow.rgb,ret.a);
  58. }
RAW Paste Data