โ† All examples

godot shaders

Wind sway for 2D plants and banners

Sway 2D foliage in the wind by shearing the sprite's top while its base stays planted, with a gust wave that travels across the scene and a phase taken from each node's position so neighbours move out of step.

Recorded render of Wind sway for 2D plants and banners

What this component contains

  • ATTRIBUTION.md
  • LICENSE
  • README.md
  • component.json
  • demo.tscn
  • inspect_shader.py
  • material.tres
  • preview.png
  • sprite_wind_sway.gdshader
  • test_package.py
  • verification/native.json

How it works

Shader type
canvas_item
Parameters
strength (float = 14), speed (float = 1.6), gust_strength (float = 10), gust_wavelength (float = 600), gust_speed (float = 220), stiffness (float = 1.5), base_v (float = 1)
Use it on
Sprites whose planted edge is at the bottom (or set `base_v`).
Result
Four plant sprites leaning and swaying at different phases above the ground.
Renderers
compatibility: compiled and rendered, forward plus: not verified, mobile: not verified
Placement
res://baltor/godot_shaders/sprite_wind_sway/

Recorded checks

godot 4.7.2.stable.official.ed1daf0bf

  • contract_static
  • engine_run
  • engine_log_clean
  • shader_in_scene
  • capture_written
  • render_not_uniform
  • shader_changes_pixels

Limits to consider

A Sprite2D has four vertices, so it shears rather than curves; use a subdivided Polygon2D or MeshInstance2D for a curved bend. Large shears push the sprite beyond its bounding rectangle used for culling.