GDScriptBeta
Materials and shaders
Animate a material to change every node that uses it. Use an instance uniform when each node needs its own shader value.
Examples use the global Tweens class in a node script, with targets inside the scene tree. mesh is a MeshInstance3D using the materials shown.
Choose an owner
Section titled “Choose an owner”A material isn’t in the scene tree, so its tweens take an owner as the third argument. A node ends playback when it leaves the tree; the tree keeps it running until shutdown:
var smooth := Tweens.material_roughness(0.2, 1.0)Tweens.play(material, smooth, mesh) # Ends when mesh leaves the tree.Tweens.play(material, smooth, get_tree()) # Ends when the tree shuts down.The tween keeps animating this material, even if the mesh switches to another one.
Material properties
Section titled “Material properties”The material catalog covers albedo, roughness, emission, UVs, and more on BaseMaterial3D. Every node using a material shows its tweens, so to animate one node alone, duplicate the material once during setup:
var unique: StandardMaterial3D = shared.duplicate()mesh.material_override = uniqueTweens.play(unique, Tweens.material_albedo_color(Color.RED, 1.0), mesh)Shader uniforms
Section titled “Shader uniforms”For a shader declaring uniform float dissolve = 0.25;:
Tweens.play(shader_material, Tweens.shader_parameter(&"dissolve", 1.0, 0.5), mesh)This changes the uniform for every node using the material. Names are case-sensitive, and the endpoint’s type must match the uniform: 1.0 for a float, 1 for an int, Color for a color, and the matching vector type for a vector.
Instance uniforms
Section titled “Instance uniforms”For a shader declaring instance uniform float pulse = 0.25;:
mesh.create_tween().tween_method( func(value: float) -> void: mesh.set_instance_shader_parameter(&"pulse", value), 0.25, 1.0, 0.5)Tweens.play(mesh, Tweens.instance_shader_parameter(&"pulse", 1.0, 0.5))Only this node’s value changes, even when it shares the material. The tween starts from the current value or the shader’s default, where Godot’s version needs it written out.
tweens.gd is made with math & ferrets, copyright © 2026 its contributors.
Godot logo by Andrea Calabró, licensed under CC BY 4.0.
"Easy, the Ferret" illustrations drawn by foxy_maria.
tweens.gd is released under the MIT License.
Godot is licensed under the MIT License.
tweens.gd is not affiliated with or endorsed by the Godot Foundation.