Darkwater

Untitled

Apr 17th, 2013
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.04 KB | None | 0 0
  1. uniform float tau = 6.2832;
  2. extern bool paused;
  3. extern bool gameover;
  4. extern float width;
  5. extern float height;
  6. extern float time;
  7. vec3 hue2rgb(float hue) {
  8.     hue = mod(hue, 360);
  9.     vec3 rgb = vec3(0, 0, 0);
  10.     float hdash = hue / 60.0;
  11.     float n = 1 * (1.0 - abs((mod(hdash, 2.0)) - 1.0));
  12.     if(hdash < 1.0) {
  13.         rgb.r = 1;
  14.         rgb.g = n;
  15.     } else if(hdash < 2.0) {
  16.         rgb.r = n;
  17.         rgb.g = 1;
  18.     } else if(hdash < 3.0) {
  19.         rgb.g = 1;
  20.         rgb.b = n;
  21.     } else if(hdash < 4.0) {
  22.         rgb.g = n;
  23.         rgb.b = 1;
  24.     } else if(hdash < 5.0) {
  25.         rgb.r = n;
  26.         rgb.b = 1;
  27.     } else if(hdash <= 6.0) {
  28.         rgb.r = 1;
  29.         rgb.b = n;
  30.     }
  31.     return rgb;
  32. }
  33. vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) {
  34.     vec4 pixel = texture2D(texture, vec2(texture_coords.x, texture_coords.y));
  35.     if(pixel.a == 1) {
  36.         pixel.r = pixel.g = pixel.b = 1;
  37.         //pixel.r = texture_coords.x;
  38.         //pixel.b = texture_coords.y;
  39.         pixel.a = 1;
  40.     } else if(pixel.a == 0) {
  41.         if(gameover) {
  42.             pixel.r = texture_coords.y * 0.05 + 0.1;
  43.         } else if(paused) {
  44.             pixel.g = texture_coords.y * 0.05 + 0.1;
  45.             pixel.b = texture_coords.y * 0.10 + 0.1;
  46.         }
  47.         int offset = 10;
  48.         int iterations = 25;
  49.         float intensity = 0.03;
  50.         for(float ang = tau / iterations; ang < tau; ang += tau / iterations) {
  51.             float dx = cos(ang) * offset / width;
  52.             float dy = sin(ang) * offset / height;
  53.             vec4 target = texture2D(texture, vec2(texture_coords.x + dx, texture_coords.y + dy));
  54.            
  55.             if(target.b == 1) {
  56.                 pixel += vec4(hue2rgb(time * 200) * intensity, 1.0);
  57.             }
  58.            
  59.             if(target.r == 1) {
  60.                 pixel.r += intensity;
  61.                 pixel.g += intensity;
  62.                 pixel.b += intensity;
  63.             }
  64.         }
  65.         pixel.a = 1;
  66.     } else {
  67.     }
  68.     return pixel;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment