- Home /
Static Boolean on Shadergraph?
Is there a way to change a boolean in all materials that use a specific shader from the shader graph? For example I have a toon shader with a bool "isNight" and when you turn that bool on the colors change to night colors. But I have many different materials that use this toon shader. Is there any way to enable the boolean to all of them without having to search all the materials on the scene and enable them manually? Or maybe the shader could access a static bool of a script instead of having it's own bool. Any recommendations on how to achieve this result are welcome ^^
Answer by andrew-lukasik · Sep 04, 2021 at 10:48 PM
https://docs.unity3d.com/Packages/com.unity.shadergraph@7.1/manual/Keywords.html
(...) You can use Keywords to create different variants for your Shader Graph. Depending on the settings for a Keyword and settings in the Editor, the build pipeline might strip these variants.
Scope Sets the scope at which to define the Keyword.
Global Keywords: Defines Keyword for the entire project (...)
This but global scope: Then:
In Shader Graph, you first define a Keyword on the Blackboard, and then use a Keyword Node to create a branch in the graph.
Use these branches to for create two graph pathways for both night and day.
Oh that's awesome! Didn't know what I could use keywords for! I will dive into them right now! Thank you so much!!!!