How to modify a shader's parameters in runtime?

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

I have a shader and I want it to get more extreme with the players speed. How would I edit this shader’s parameters in runtime?

:bust_in_silhouette: Reply From: kidscancode

You need to get a reference to the material. If it’s a CanvasItem (2D) you can get it with material. If it’s a MeshInstance, you can use its GeometryInstance.material_override or Mesh.surface_get_material or PrimitiveMesh.material. I’ve linked to the class docs if you need details.

After that it depends on what kind of material it is:

For example, if you have a boolean parameter, grayscale, to turn on and off grayscale:

attunemm | 2023-06-30 20:38