Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: nuFF3 on May 27, 2020, 09:32:14 AM

Title: [Solved] Changing Global Shader Variables
Post by: nuFF3 on May 27, 2020, 09:32:14 AM
I have multiple materials using the same shader, and I need to feed them all a single value.
The variable I need to change is a "global" shader variable.
If I use 'Set Material Float', it will only change that materials variable, but not the rest of them.
There is a thing called 'Shader.SetGlobalFloat' in scripting, but there's no such action for Playmaker.
It would be tedious to have many of the 'Set Material Float' for each material.
How then can I change the shaders variable globally through Playmaker?
Title: Re: [Solved] Changing Global Shader Variables
Post by: nuFF3 on May 27, 2020, 09:51:48 AM
Never mind, I solved it myself.
I essentially made my own version of the 'Set Material Float' actionscript.
I changed every line that had 'renderer.material.SetFloat', with 'Shader.SetGlobalFloat' and it worked automatically.
Now when I have the global shader variable set to a value, it changes across all the materials.
Title: Re: [Solved] Changing Global Shader Variables
Post by: nuFF3 on May 27, 2020, 10:45:21 AM
I also made three versions of it.
For; Float, Color and Vector4.
Feel free to grab them in the attachment below.