How to change GradientTexture1D offsets when using a shader?
Asked Answered
G

4

0

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.

Grantee answered 20/8, 2023 at 13:9 Comment(0)
F
0

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 answered 20/8, 2023 at 16:3 Comment(0)
F
0

get_shader_parameter should work. If it doesn't then you made a mistake somewhere.

Fabrication answered 20/8, 2023 at 13:56 Comment(0)
G
0

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 :/

Grantee answered 20/8, 2023 at 14:33 Comment(0)
F
0

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 answered 20/8, 2023 at 16:3 Comment(0)
G
0

Fabrication
Oh thank you, that does work! I used the Godot get path form the right click.

Grantee answered 20/8, 2023 at 16:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.