Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Temporarily override all shader on a specific layer with another shader?

Discussion in 'Shaders' started by Airmouse, Nov 8, 2019.

  1. Airmouse

    Airmouse

    Joined:
    Jan 12, 2019
    Posts:
    37
    I use Unity "Standard" shaders for my characters and scene on the "default" layer.
    And on the "UI" layer I also use the "Standard" shaders for things like controllers mesh and interface elements.

    But what I am trying to achieve is find a way that by toggling a boolean then all "Standard" shaders on the default layer will instead render using a custom "Standard_Override" shader that I have modified.

    For example:
    During normal gameplay the "Standard" shaders are rendered.
    But when the player steps on a teleport pad then suddenly the "Standard_Override_Teleport" shaders are rendered instead.

    -or-

    During normal gameplay the "Standard" shaders are rendered.
    But if cutscene begins playing then suddenly the "Standard_Override_Toon" shaders are rendered instead.

    Hopefully those two examples are clear as to why I would like to achieve this, and why I need to override specific shaders at specific times.

    I think I could simply write a loop to search for all Renderers on the specified layer, then just replace those shaders manually. But I was hoping someone might know of a more efficient way to tell Unity to just use an Override shader instead of the standard ones?