โ† All examples

godot shaders

Per-instance variation for MultiMesh crowds

Give thousands of MultiMesh instances individual looks and motion from INSTANCE_ID alone: hue and brightness variation, random height scale, and a bobbing wave with its own phase per instance.

Recorded render of Per-instance variation for MultiMesh crowds

What this component contains

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

How it works

Shader type
spatial
Parameters
base_color (vec4 = 0.25, 0.6, 0.85, 1), hue_variation (float = 0.35), brightness_variation (float = 0.3), height_variation (float = 0.8), bob_height (float = 0.12), bob_speed (float = 2), roughness (float = 0.6)
Use it on
A MultiMeshInstance3D; meshes should have their base near object y = -0.25 (or edit `base` in the shader).
Result
A field of blue, teal and violet boxes of different heights bobbing out of step.
Renderers
compatibility: compiled and rendered, forward plus: not verified, mobile: not verified
Placement
res://baltor/godot_shaders/multimesh_instance_variation/

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

Variation is tied to the instance index, so reordering instances changes their looks. INSTANCE_ID is 0 for a plain MeshInstance3D, so all copies look the same there. Normals are not adjusted for the height stretch (fine for boxes and columns).