Created
December 22, 2022 09:34
-
-
Save tarmo888/392fd88056f88be8baa0b8d42e6c9fa3 to your computer and use it in GitHub Desktop.
"Shooting Stars" by @XorDev for Love2D
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local prevW, prevH = 1280, 720 | |
| function love.load(arg) | |
| love.filesystem.setIdentity('ShootingStars') | |
| local pixelcode = [[ | |
| /* | |
| "Shooting Stars" by @XorDev | |
| I got hit with inspiration for the concept of shooting stars. | |
| This is what I came up with. | |
| <300 chars playlist: shadertoy.com/playlist/fXlGDN | |
| */ | |
| uniform float iTime; | |
| vec4 effect(vec4 O, Image texture, vec2 texture_coords, vec2 pixel_coords){ | |
| vec2 I = texture_coords * love_ScreenSize.xy; | |
| //Clear fragcolor | |
| O *= 0.; | |
| //Line dimensions (box) and position relative to line | |
| vec2 b = vec2(0,.2), p; | |
| //Rotation matrix | |
| mat2 R; | |
| //Iterate 20 times | |
| for(number i=.9; i++<40.; | |
| //Add attenuation | |
| O += 1e-3/length(clamp(p=R | |
| //Using rotated boxes | |
| *(fract((I/-love_ScreenSize.y*i*.1+iTime*b*5)*R)-.2),-b,b)-p) | |
| //My favorite color palette | |
| *(cos(p.y/.1+vec4(0,1,2,3))+1.)) | |
| //Rotate for each iteration | |
| R=mat2(cos(i+vec4(0,33,11,0))); | |
| return O; | |
| } | |
| ]] | |
| shader = love.graphics.newShader(pixelcode) | |
| canvas = love.graphics.newCanvas(love.graphics.getDimensions()) | |
| time = 0 | |
| end | |
| function love.update(dt) | |
| time = time + dt; | |
| shader:send('iTime', time) | |
| end | |
| function love.draw() | |
| love.graphics.setShader(shader) | |
| love.graphics.draw(canvas) | |
| love.graphics.setShader() | |
| end | |
| function love.resize() | |
| canvas = love.graphics.newCanvas(love.graphics.getDimensions()) | |
| end | |
| function love.keypressed(button, unicode) | |
| if button == "escape" then | |
| love.event.quit() | |
| end | |
| if button == "f5" then | |
| love.event.quit("restart") | |
| end | |
| if button == "f11" then | |
| if love.window.getFullscreen() then | |
| love.window.updateMode(prevW, prevH, {fullscreen = false, resizable = true}) | |
| else | |
| prevW, prevH = love.graphics.getDimensions() | |
| love.window.setFullscreen(true, "desktop") | |
| end | |
| canvas = love.graphics.newCanvas(love.graphics.getDimensions()) | |
| end | |
| if button == "f12" then | |
| love.graphics.captureScreenshot(os.time() .. ".png") | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment