How to set shader parameter in C#?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Svampen

In GDScript it’s 'node.material.set_shader_param("parameter", value)' so i figured it’s Node.Material.SetShaderParam("parameter",value) in C# but VSCode complains that ‘Material’ lacks a definition for ‘SetShaderParam’ and i can’t find anything in the documentation.

:bust_in_silhouette: Reply From: mateusak
(Material as ShaderMaterial).SetShaderParam("parameter", value)

Little late though.

:bust_in_silhouette: Reply From: MazingTech

Here is the Godot 4 version:

var direction = 1;
var material = GetNode(“Icon”).Material;
((ShaderMaterial)material).SetShaderParameter(“direction”, direction);