How to change material parameters dynamically in HAXE script?

Hi, any suggestion on how to change material parameters dynamically in HAXE script?
I was trying to change the color of one material gradually for some event. I didn’t find any example about this.

Modifying the Fact of a mix shader in your script.

hi Didier

Thanks! but how to access the mix shader and its Fact in the script?

By default the shader compiler bakes everything into the shader when possible for speed. We need something like this: https://github.com/armory3d/armory/issues/451. Looking into it!

2 Likes

@Milo
I use the TextureCoordinate node with an Empty object. When you move this Empty, for example its position x represents the value of Fact you need to control…

So if you attach this translation to an Event, then you are able to change the color of one material gradually for this Event.

Remember that you can use this too Not reliable SetMaterial node ... maybe the solution

You can share your experiences then with others here too Best switch colors method

@lubos
I see, I will try to do some workaround first.

@Didier
Thanks! I tried to setup the nodes according to your method, but when I move the Cube, the color is not changing…is there some special setup required?

@Milo I don’t remember of special setup.
Maybe first test/validate if coords well retreived ?