โ† All examples

godot shaders

Procedural 2D grass field with wind

Fill a rectangle with layers of grass blades drawn procedurally: each blade has its own height, width, lean and colour, bends with travelling wind, and back layers are darker for depth.

Recorded render of Procedural 2D grass field with wind

What this component contains

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

How it works

Shader type
canvas_item
Parameters
front_color (vec4 = 0.42, 0.72, 0.25, 1), back_color (vec4 = 0.12, 0.32, 0.12, 1), tip_color (vec4 = 0.8, 0.85, 0.45, 1), blades (float = 60), blade_height (float = 0.55), wind_strength (float = 0.06), wind_speed (float = 1.4), layers (int = 3)
Use it on
A ColorRect (or any CanvasItem) sized to the area to fill; UVs span 0 to 1 across it.
Result
A strip of layered green grass blades with light tips swaying in front of a blue sky.
Renderers
compatibility: compiled and rendered, forward plus: not verified, mobile: not verified
Placement
res://baltor/godot_shaders/grass_field_2d/

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

Blades are flat colour without lighting. Very strong wind bends blades beyond the neighbour search and clips them. Cost is layers times three blade tests per pixel.