shader_type canvas_item;

uniform float frequency : hint_range(0.0, 60.0) = 1.0;
uniform float motion_rot : hint_range(-3.141592653589793, 3.141592653589793) = 0.0;
uniform float displacement_x = 0.0;
uniform float displacement_y = 64.0;
uniform sampler2D displacement;

void fragment() {
    vec2 d = vec2(displacement_x, displacement_y) * (2.0 * texture(displacement, fract(UV - frequency * TIME * vec2(cos(motion_rot), sin(motion_rot)))).rg - 1.0);
    COLOR = texture(TEXTURE, UV + d * TEXTURE_PIXEL_SIZE);
}
