Topdown windy plants

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

Rotating Quadrant

Texture Masking

Subscribe
Notify of
guest

3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Apprentice
Apprentice
5 months 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
3 months ago
Reply to  Apprentice

zhangxuetu niu

Torguen
Torguen
5 months ago

No idea how it works, no explanation at all.