Topdown wind shader

Topdown windy plants shader

Then used OpenSimplexNoise to provide the wind to the plants

Twitter Post

Shader code
shader_type canvas_item;
render_mode blend_mix;

// Wind settings.
uniform vec2 wind = vec2(0, 0);

uniform float heightOffset : hint_range(0.0, 1.0);

void vertex() {
	vec4 pos = WORLD_MATRIX * vec4(0.0, 0.0, 0.0, 1.0);
	VERTEX.x += wind.x * max(0.0, (1.0-UV.y) - heightOffset);
	VERTEX.y += wind.y * max(0.0, (1.0-UV.y) - heightOffset);
}
Tags
2d, topdown, wind
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 ReallyOkeyFruit

Texture Masking

Rotating Quadrant

Related shaders

TopDown Game 2D Cloud shader

2D Topdown Shadow that goes out of bounds

Tilemap Wind shader

Subscribe
Notify of
guest

4 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Apprentice
1 year ago

I changed it to version 4.0 and made it sway left and right

shader_type canvas_item;
render_mode blend_mix;


// Wind settings.
uniform vec2 wind = vec2(0, 0);


uniform float heightOffset : hint_range(-0.5, 0.5) = 0.0;


void vertex() {
	vec4 pos = CANVAS_MATRIX * vec4(0.0, 0.0, 0.0, 1.0);
	VERTEX.y += wind.y * max(0.0, (1.0-UV.y) - abs(heightOffset));
	VERTEX.x += wind.x * max(0.0, (1.0-UV.y) - abs(heightOffset)) * heightOffset;
	
}
kalshen
kalshen
1 year ago
Reply to  Apprentice

zhangxuetu niu

Torguen
Torguen
1 year ago

No idea how it works, no explanation at all.

alex_requiend
alex_requiend
9 months ago
Reply to  Torguen

animate the “shader parameters” values in an AnimationPlayer, “Wind” is the direction of the wind and how strong the movement will be, and “HeightOffset” is the movement itself that you will animate.