#set_shader_parameter not doing anything

1 messages · Page 1 of 1 (latest)

latent pebble
#

I've been fighting with this for two days. Why is set_shader_parameter not doing anything here? This is the code:

var mat : ShaderMaterial = get_node("ColorRect").material
for i in range(options.size()):
print("Set shader parameter " + options.keys()[i] + " to " + str(options.values()[i]))
mat.set_shader_parameter(options.keys()[i], float(options.values()[i]))
#

The code is definitely running:

#

You can see the options dictionary updates, but the shader parameters dont:

pine wadi
#

I tried it with a simple shader and it seems to be working.

pine wadi
latent pebble
#

Definitely not, I'm just using what you see and the shader code is standard uniform floats

pine wadi
latent pebble
#

That's me adding a new shader to the shader stack, that part is working fine, otherwise it wouldn't have an options dictionary to copy over to the shader scene script

#

As far as I'm aware it's the set shader parameter call that isn't working, or the inputs that I'm giving it

#

But as you can see from me being able to to print the key without casting to a string, that one is the right format, and the names are the same, and there's no reason the float shouldn't be working

#

I even tried casting it to a float to make sure

pine wadi
latent pebble
#

all scripts shown are tool scripts

#

@pine wadi for when you're able to take a look

pine wadi
kindred kraken
#

I think it might be an issue that you set the parameters pretty much instantly after the color_rect was readied. If the RenderingServer is not running synchronously the shader instance might not be done yet. Try calling update_material deferred or even in the next frame.

latent pebble
#

I solved this! I was capitalising the uniform names when I shouldn't have been. I assumed I should as thats how they appeared in the editor, but this was wrong. Stupid mistake to make honestly. I should have shown the shader code as well and it would have been caught quickly