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);
}
Live Preview
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

Related shaders

Comments 4

  1. 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;
    	
    }
    
    2
    1. 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.

      1