Interference
This sketch shows an interference pattern between two waves: one centered at the origin pulsing at 15Hz, and one centered at the position of the mouse at 20Hz
Toggle shader source Remix this
:: wave ( p freq -- val )
\ generate a wave at point p
p length time 2 / - freq * sin
\ [-1,1] -> [0, 1]
1 + 2 /
;
:: mouse-uv ( -- p )
\ The mouse position in "uv-space"
\ aspect-corrected, centered at 0,0
mouse
resolution 2 /
-
2 *
\ aspect-correct
resolution .x resolution .y min
/
;
: main
\ 15Hz wave at the origin
uv 15 wave
\ 20Hz wave at the mouse position
uv mouse-uv - 20 wave
+ 2 /
0.4 0.71 1.0 1.0 vec4
*
;