wibbly wobbly

make a plane go wibble wobble

Shader code
shader_type spatial;

uniform sampler2D tex : source_color, hint_default_white;
uniform float wave_amplitude : hint_range(0.0, 1.0) = 0.1;
uniform float wave_frequency : hint_range(0.0, 20.0) = 10.0;
uniform float wave_speed : hint_range(0.0, 10.0) = 1.0;
uniform bool vertical_wobble = true;

void fragment() {
    vec2 uv = UV;
    float wave = sin((vertical_wobble ? uv.x : uv.y) * wave_frequency + TIME * wave_speed) * wave_amplitude;

    if (vertical_wobble) {
        uv.y += wave;
    } else {
        uv.x += wave;
    }

    // Clamp the UVs to prevent texture wrapping
    uv = clamp(uv, vec2(0.0), vec2(1.0));
    vec4 tex_color = texture(tex, uv);
    ALBEDO = tex_color.rgb;
    ALPHA = tex_color.a;
}
Tags
plane, wibble, wobble
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from babylon

Toon glass

Yakuza-style radial drag shader

Related shaders

3D Wobbly Effect

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments