distraction/shaders/ripples.py
2020-02-12 13:11:57 +01:00

20 lines
496 B
Python

import math
from pixel import Pixel
def main(pixel: Pixel, resolution: tuple, frag_coord: tuple, time: float): # https://www.shadertoy.com/view/ldX3zr
invAr = resolution[1] / resolution[0]
uv = (frag_coord[0] / resolution[0], frag_coord[1] / resolution[1])
col = [*uv, 0.5 + 0.5 * math.sin(time)]
x = 0.5 - uv[0]
y = (0.5 - uv[1]) * invAr
r = -(x * x + y * y)
z = 1.0 + 0.5 * math.sin((r + time * 0.035) / 0.013)
for i in range(3):
col[i] *= z
pixel.background_color.set( *col )