Sea Sickness Shader (Underwater View Shader)

underwater view shader, sine wave distortion on image

This is one of the simple screen space post processing shaders that you can apply to your game if you want to simulate sea sickness feeling or the feeling of being under the water. If you reduce the strength of the motion, you can apply it to our simple scene to simulate some motion instead of static bored visual.

This shader is relatively simple: All you need to do is to modify the UVs based on a sine wave & pass it to the texture. The texture will be distorted. If you multiply the UVs with time, you’ll get animated version of it. That’s it!

Complete Source Code

shader_type canvas_item;

uniform sampler2D screen_texture : hint_screen_texture;

void fragment() {
    // Calculate UV coordinates
	vec2 uv = SCREEN_UV;
    // Offset the UV coordinates based on a sine wave
    uv.x += sin(SCREEN_UV.y * 10.0 + TIME) * 0.01; // Adjust the frequency and amplitude as needed
    uv.y += sin(SCREEN_UV.x * 10.0 + TIME) * 0.01;

    // Sample the texture using the modified UV coordinates
    COLOR = texture(screen_texture, uv);
}

Leave a Reply

Your email address will not be published. Required fields are marked *