I have a shader that uses a GradientTexture1D and I want to update the offset points of the gradient to affect the shader. But I cannot seem to figure out how to access these points in GDScript. I know there is a set_offset method (https://docs.godotengine.org/en/stable/classes/class_gradient.html#class-gradient-method-set-offset) but I don't understand how I get access to the Texture itself. I tried stuff like get_shader_parameter but nothing seems to work.
Ah, there is your problem. get_shader_parameter takes the name of the uniform as a parameter. Not sure where you did get the 'shader_parameter' prefix from.
get_shader_parameter should work. If it doesn't then you made a mistake somewhere.
Fabrication I tried:
print(material.get_shader_parameter('shader_parameter'))
I got that from right clicking on the texture and then "Copy value" but this only returns <null>.
I also tried:
print(material.get_shader_parameter('shader_parameter/color_ramp_texture'))
(color_ramp_texture is the name of the uniform variable in the shader)
And it gets me the same result.
Not really sure what I did wrong :/
Ah, there is your problem. get_shader_parameter takes the name of the uniform as a parameter. Not sure where you did get the 'shader_parameter' prefix from.
Fabrication
Oh thank you, that does work! I used the Godot get path form the right click.
© 2022 - 2024 — McMap. All rights reserved.