Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Brinux |
I would love to know how to access/change a visual shader material’s uniform parameters from within a GD script.
Scenario: I create a visual shader material for a given mesh, and I want to tweak the material from my GD script for a given game event.
I assume I go to
$sphere.mesh.surface_get_material(0). #....something goes here
… and after that I have no idea how to access the “shader_param/AlphaKnob” or whatever other uniform variable I’ve put in there. I can easily change in in the editor, I just can’t figure out how to access it from code (script).
Can someone give me the syntax, or better, an example of how I would get at this uniform variable?
Thanks in advance
Specific example: I have a visual shader with a ScalarUniform connected to the Alpha output. I named it “AlphaKnob”. AlphaKnob is now exposed in the editor, and I can change it in the editor and that works great.
Now I want to change “AlphaKnob” from within a GDscript.
The “float over” text says it’s called “shader_param/AlphaKnob”.
What am I typing into my GDscript to change the value of AlphaKnob to 0.5, or anything else ?