#how to get and change a shader parameter in gd script?

1 messages · Page 1 of 1 (latest)

river perch
#

i've been trying to implement real time lip sync into my project but i'm a lil stuck at this point, i have it set up so the face changes uv in the material so i can set the face to what i want and a mic setup to read volume but the problem now is that i don't actually know how to set up the shader parameter in the script. i've tried using a get_shader_parameter but when running the project godot says it's not a real thing?
also i just realised it should be set_shader_parameter but that still gives the same error

deft pelican
#

I wonder if there's something off with the way it initializes it.
Have you tried using @export and assigning the material that way?

river perch
#

i havent tried that i'll give it a go now

deft pelican
#

The way it's saying "base string" kinda implies it's trying to use the function on that piece of text

river perch
#

tried the export, same error

so i need to change the text to something else maybe?

deft pelican
#

What I mean is uh

river perch
#

sorry i'm pretty new to coding

deft pelican
#

Did you try @export var face: Material

river perch
#

oh, no i'll try that now

deft pelican
#

It should give you a button in inspector and you can use it to get a search box for the material

#

I'm sure there's a valid way to do it with a file path, too, though. Like maybe with preload.

river perch
#

i got it set up and the error goes away but it's not updating the uv

deft pelican
#

Yeah you are calling face.get_shader_parameter but you aren't saving it anywhere.

#

Or doing anything with it

river perch
#

i've swapped it to set instead

#

but nothing changes

#

oh wait it's how i wrote index x is why it wasnt changing

#

thank you for the help!

deft pelican
#

Oh and also the export way is just what I'm used to since I used to use Unity and it didn't really use paths much.

I think @onready var face: Material = "your path" might work if you want it as a string.
Pros and cons. Export shouldn't break when files are renamed/moved, but it sometimes acts wonky when copypasting etc.

Either way yeah glad it's working now!