โ† All examples

godot shaders

Waving flag with a pinned edge

Animate a flag on a subdivided quad: travelling waves grow away from the pole edge, a droop adds weight, analytic derivatives rebuild the normals, and the face shows procedural stripes and a disc or an assigned texture.

Recorded render of Waving flag with a pinned edge

What this component contains

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

How it works

Shader type
spatial
Render modes
cull_disabled
Parameters
flag_texture (sampler2D), stripe_a (vec4 = 0.1, 0.25, 0.6, 1), stripe_b (vec4 = 0.95, 0.95, 0.92, 1), emblem_color (vec4 = 0.9, 0.7, 0.15, 1), stripes (int = 5), amplitude (float = 0.12), wavelength (float = 0.9), speed (float = 3) and 2 more
Use it on
A QuadMesh (or plane) with enough subdivisions along U; the pole side must be at U = 0., Optional: a flag image for `flag_texture`.
Result
A striped flag with a gold disc rippling in waves that start at the pole.
Renderers
compatibility: compiled and rendered, forward plus: not verified, mobile: not verified
Placement
res://baltor/godot_shaders/flag_wave_cloth/

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

Not a cloth simulation: no gravity response to orientation, no wind direction and no collision. Normals come from the UV-space function, assuming an unscaled quad, so strongly non-uniform scale skews lighting. Shadows follow the moving shape.