Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Resolved Equivelent of Unreal's StaticBool?

Discussion in 'Shader Graph' started by MissEmbyr, Jun 1, 2020.

  1. MissEmbyr

    MissEmbyr

    Joined:
    Nov 8, 2016
    Posts:
    13
    In Unreal's material editor (shader editor) there is the ability to define a StaticBool parameter that allows you to set a per-"material instance" (what unity calls materials) boolean that you can branch on without any performance impact as it's compile-time.

    Is there any way we can do this with shader graph so that we can switch on and off features per-material without having to create a new shader soley for that purpose?
     
  2. florianBrn

    florianBrn

    Joined:
    Jul 31, 2019
    Posts:
    53
    Check out Boolean Keywords. You can create one from the Graph's Blackboard (+ sign -> Keyword -> Boolean).
    Then just use it this way:



    You can change its value in real-time from the inspector later (from code too). SG also makes so there isn't any performance impact by automatically removing uneeded shader code at compiling.
     
    MissEmbyr likes this.
  3. MissEmbyr

    MissEmbyr

    Joined:
    Nov 8, 2016
    Posts:
    13
    That's exactly what I was looking for thanks!
     
    florianBrn likes this.