Godot 4 GPUParticle3D: How to set parameter by GDscript

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


I try to set my GPUParticle3D shader parameter by this GDscript code

self.process_material.set_shader_parameter( "node_position", self.global_transform.origin )

set_shader_parameter() seams not to exist anymore in Godot 4, like in Godot 3.

How to set shader parameters in Godot 4 from GDscript?



set_shader_parameter does still exist in Godot 4. See the Docs.

What’s the specific problem here?

jgodfrey | 2023-04-14 21:15

I get an error “Invalid call. Nonexistent function 'set_shader_parameter' in base 'ParticleProcessMaterial'”.

MikeMikeMike | 2023-04-15 08:37

What’s been assigned to process_material? set_shader_parameter ist a ShaderMaterial method. Worth checking the material type.

spaceyjase | 2023-04-15 10:09

The process_material is set to ParticleProcessMaterial.

MikeMikeMike | 2023-04-15 11:47

:bust_in_silhouette: Reply From: MikeMikeMike

Now I understand, I can set the proces_material properties directly, without set_shader_parameter, like:

process_material.spread = 60.0


1 Like

I also meet the problem. Besides the method mentioned above of assigning values directly using parameter names like this:

material.param_name = value

you can also do it like this:

material.set("shader_param/param_name", value)

This method is closer to “set_shader_parameter”. When I try to assign a value of type Color to a variable of type uniform vec4, the first method fails, but the second one works.