Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uniform float tau = 6.2832;
- extern bool paused;
- extern bool gameover;
- extern float width;
- extern float height;
- extern float time;
- vec3 hue2rgb(float hue) {
- hue = mod(hue, 360);
- vec3 rgb = vec3(0, 0, 0);
- float hdash = hue / 60.0;
- float n = 1 * (1.0 - abs((mod(hdash, 2.0)) - 1.0));
- if(hdash < 1.0) {
- rgb.r = 1;
- rgb.g = n;
- } else if(hdash < 2.0) {
- rgb.r = n;
- rgb.g = 1;
- } else if(hdash < 3.0) {
- rgb.g = 1;
- rgb.b = n;
- } else if(hdash < 4.0) {
- rgb.g = n;
- rgb.b = 1;
- } else if(hdash < 5.0) {
- rgb.r = n;
- rgb.b = 1;
- } else if(hdash <= 6.0) {
- rgb.r = 1;
- rgb.b = n;
- }
- return rgb;
- }
- vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) {
- vec4 pixel = texture2D(texture, vec2(texture_coords.x, texture_coords.y));
- if(pixel.a == 1) {
- pixel.r = pixel.g = pixel.b = 1;
- //pixel.r = texture_coords.x;
- //pixel.b = texture_coords.y;
- pixel.a = 1;
- } else if(pixel.a == 0) {
- if(gameover) {
- pixel.r = texture_coords.y * 0.05 + 0.1;
- } else if(paused) {
- pixel.g = texture_coords.y * 0.05 + 0.1;
- pixel.b = texture_coords.y * 0.10 + 0.1;
- }
- int offset = 10;
- int iterations = 25;
- float intensity = 0.03;
- for(float ang = tau / iterations; ang < tau; ang += tau / iterations) {
- float dx = cos(ang) * offset / width;
- float dy = sin(ang) * offset / height;
- vec4 target = texture2D(texture, vec2(texture_coords.x + dx, texture_coords.y + dy));
- if(target.b == 1) {
- pixel += vec4(hue2rgb(time * 200) * intensity, 1.0);
- }
- if(target.r == 1) {
- pixel.r += intensity;
- pixel.g += intensity;
- pixel.b += intensity;
- }
- }
- pixel.a = 1;
- } else {
- }
- return pixel;
- }
Advertisement
Add Comment
Please, Sign In to add comment