playMaker

Author Topic: [Solved] Changing Global Shader Variables  (Read 1567 times)

nuFF3

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 74
  • Are we even real?
    • One Month Studio
[Solved] Changing Global Shader Variables
« 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?
« Last Edit: May 27, 2020, 09:45:40 AM by nuFF3 »

nuFF3

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 74
  • Are we even real?
    • One Month Studio
Re: [Solved] Changing Global Shader Variables
« Reply #1 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.

nuFF3

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 74
  • Are we even real?
    • One Month Studio
Re: [Solved] Changing Global Shader Variables
« Reply #2 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.