Pixel Art Wind Sway (MeshInstance3D, Godot 4.0)

Simple shader that creates wind-like movement.

 

Works with MeshInstance3D node.

 

Assets made by:
Cainos: https://cainos.itch.io/pixel-art-top-down-basic 

 

and 

 

Aamatniekss: https://aamatniekss.itch.io/fantasy-knight-free-pixelart-animated-character

Shader code
shader_type spatial;
render_mode cull_disabled, depth_draw_opaque;

uniform sampler2D grass_texture : filter_nearest, source_color;

void vertex(){
	NORMAL = vec3(0.0, 1.0, 0.0);
	VERTEX.x += sin(NODE_POSITION_WORLD.x + TIME * 1.25 + UV.y) * ( 1.0 - UV.y) * 0.2;
	VERTEX.z += cos(NODE_POSITION_WORLD.z + TIME * 0.45 + UV.y) * ( 1.0 - UV.y) * 0.15;
}

void fragment(){
	ALBEDO = texture(grass_texture, UV).rgb;
	ALPHA = texture(grass_texture, UV).a;
}
Live Preview
Tags
animation, grass, movement, 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 Darfine

Related shaders

Comments 3

  1. Arovin

    I am finding the back side of the quad is always darker than the front? Anyway to correct that in the shader? For now I am duplicating the quad and flipping the face.

    0
    1. schuster

      Add this for a backlighting grass texture

       

      uniform vec3 backlight_color : source_color;
      uniform float backlight_amount : hint_range(0, 5);

       

      void fragment(){
         // Enables alpha scissor
         ALPHA_SCISSOR_THRESHOLD = 0.5;
         vec3 backlight = backlight_color * backlight_amount;
         BACKLIGHT = backlight;
      }

      0