Simple Sway

Simple vertex shader to make things go swish swoosh, with customizable speed, strength, origin and sway direction restriction!

Shader code
shader_type canvas_item;

uniform float speed = 2.0;
uniform float strength = 0.5;
uniform float y_origin = 0.0;
uniform int restrict_dir : hint_range(-1,1) = 0;

void vertex() {
	float x = sin(TIME*speed)*(VERTEX.y-y_origin)*strength+sin(TIME*speed)*strength*8.0;
    VERTEX.x += x*float(restrict_dir==0)+abs(x)*float(-restrict_dir);
}
Tags
simple, sway, vertex
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.

Related shaders

Billboard Sprite3D Sway (Godot 4.0)

2D wind sway

3d Pixel Sway – Godot 4

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments