GLSL shader example
Raindrop Refraction on Glass
Define a droplet inside each cell and use its local radial field to displace the background only near the droplet.
Live example
Edit the code and the preview updates as you type.
What to observe
Raindrop Refraction on Glass.
Mechanism
Define a droplet inside each cell and use its local radial field to displace the background only near the droplet.
The controlling code
vec2 grid=uv*vec2(8.,5.),id=floor(grid),q=fract(grid)-.5;q.y+=sin(u_time*.4+hash(id)*6.)*.2;float d=length(q);vec2 offset=q*exp(-d*d*30.)*.15;c=texture2D(u_texture,uv+offset).rgb;c+=exp(-length(q-vec2(-.08,.08))*70.)*.3;
Experiment
Change the droplet grid uv*vec2(8.,5.) to uv*vec2(4.,3.). Fewer, larger droplet cells distort the labeled background, while each droplet retains its local radial displacement profile.
Debugging and cost
One background sample is offset by q*exp(-d*d*30.)*.15. Reduce .15 to .05 to weaken refraction without changing the small highlight or droplet motion; this is a cell-based image warp rather than a simulated water film.