access Uniforms from the gd script ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MrMonk
:warning: Old Version Published before Godot 3 was released.

Hi there,
From the docs:

A variable can be declared as uniform. In this case, its value will come from outside the shader (it will be the responsibility of the material or whatever using the shader to provide it).

How can I access a variable declared as uniform in a shader script from inside the GD script ?
thanks,

:bust_in_silhouette: Reply From: GlaDOSik

This code gets a camera position and push it to shader. To get it, you can use get_shader_param.
var cameraPosition = get_node("actor/yaw/camera").get_global_transform().origin; get_node("crystalClearShader").get_mesh().surface_get_material(0).set_shader_param("CameraPosition", cameraPosition)

you rock, I’m in 2D and this worked for me:
get_material().set_shader_param(“variable”, value).
Now I can assign values for the shader from inside the gd script

MrMonk | 2016-05-08 18:41