SHARE
TWEET

Untitled

a guest Sep 11th, 2019 120 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local WIDTH = 800
  2. local HEIGHT = 600
  3. local shader_code = [[
  4.   extern vec2 screen_dims;
  5.   extern number time;
  6.  
  7.   number pi = atan(1.0) * 4.0;
  8.  
  9.   vec4 effect(vec4 color, Image image, vec2 uvs, vec2 screen_coords) {
  10.     vec2 screen_coords_norm = vec2(
  11.         screen_coords.x / screen_dims.x,
  12.         screen_coords.y / screen_dims.y
  13.       );
  14.     number y = 40 + sin(4.18 + 1.9 * time + pi * 8.3 * screen_coords_norm.x) * 10 +
  15.      sin(screen_coords_norm.x * pi + time * 0.5) * cos(1.33 + pi * screen_coords_norm.x + pi * 0.7 * time) * 5;
  16.     number y2 = 33 + y + sin(3.58 + 1.6 * time + pi * 5.2 * screen_coords_norm.x) * 11 +
  17.      sin(time * 0.9) * cos(2.33 + pi * screen_coords_norm.x + pi * 1.9 * time) * 6;
  18.     number y3 = 37 + y2 + sin(1.88 + 1.7 * time + pi * 6.5 * screen_coords_norm.x) * 12 +
  19.      sin(time * 0.95) * cos(2.33 + pi * 2 * screen_coords_norm.x + pi * 1.2 * time) * 8;
  20.     number y4 = 38 + y3 + sin(9.66 + 1.4 * time + pi * 5.1 * screen_coords_norm.x) * 10 +
  21.      sin(time) * cos(5.33 + pi * 2 * screen_coords_norm.x + pi * 1.2 * time) * 12;
  22.     number y5 = 44 + y4 + sin(1.66 + 2.4 * time + pi * 3.9 * screen_coords_norm.x) * 8 +
  23.      sin(time * 0.8) * cos(1.88 + pi * 2.3 * screen_coords_norm.x + pi * 1.9 * time) * 11;
  24.     number y6 = 37 + y5 + sin(2.11 + 3.0 * time + pi * 2.7 * screen_coords_norm.x) * 5 +
  25.      sin(time * 0.82) * cos(6.19 + pi * 3.33 * screen_coords_norm.x + pi * 2.4 * time) * 14;
  26.  
  27.     if (screen_coords.y < screen_dims.y - y6) {
  28.       return vec4(0.0, 0.0, 0.6, 1.0);
  29.     } else if (screen_coords.y < screen_dims.y - y5) {
  30.       return vec4(0.0, 0.0, 0.65, 1.0);
  31.     } else if (screen_coords.y < screen_dims.y - y4) {
  32.       return vec4(0.0, 0.0, 0.7, 1.0);
  33.     } else if (screen_coords.y < screen_dims.y - y3) {
  34.       return vec4(0.0, 0.0, 0.75, 1.0);
  35.     } else if (screen_coords.y < screen_dims.y - y2) {
  36.       return vec4(0.0, 0.0, 0.8, 1.0);
  37.     } else if (screen_coords.y < screen_dims.y - y) {
  38.       return vec4(0.0, 0.0, 0.85, 1.0);
  39.     } else {
  40.       return vec4(0.0, 0.0, 0.9, 1.0);
  41.     }
  42.   }
  43. ]]
  44.  
  45. function love.load()
  46.   -- image_data = love.image.newImageData(WIDTH, HEIGHT)
  47.   -- image = love.graphics.newImage(image_data)
  48.   shader = love.graphics.newShader(shader_code)
  49. end
  50.  
  51. local t = 0
  52. function love.update(dt)
  53.   t = t + dt
  54.   shader:send("time", t)
  55. end
  56.  
  57. function love.draw()
  58.   love.graphics.setShader(shader)
  59.   shader:send("screen_dims", {
  60.     love.graphics.getWidth(),
  61.     love.graphics.getHeight()
  62.   })
  63.   love.graphics.rectangle('fill', 0, 0, WIDTH, HEIGHT)
  64.   love.graphics.setShader()
  65. end
  66.  
  67. function love.keypressed(k)
  68.   if k == "r" then love.event.quit "restart" end
  69. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top