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. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Question Maximum number (256) of shader global keywords exceeded

Discussion in 'Editor & General Support' started by no00ob, Apr 19, 2020.

  1. no00ob

    no00ob

    Joined:
    Dec 13, 2017
    Posts:
    62
    Hello!

    I'm running into issues with store imported assets and shader keywords. I know what this error means and why it happens, because I supposedly have too many shaders/keywords. What I don't understand is why am I running into this issue right now, I only have three major assets which even include shaders in my project at the writing of this, which are Nature Manufacturers Forest Environment, Mountain Trees and Advanced Foliage pack 2.0. This problem started happening after I tried importing the "Forest Environment" asset. One additional thing is that I downloaded a third-party tool to get rid of unused shaders and keywords in project, It showed that I only supposedly have 90 keywords (In which case how am I running into the limit of 256?) and that I had 2000 unused ones somehow? So I did the cleaning but then most of my materials got corrupted, so I restored a backup and now I'm back at the beginning it still shows I would have 90 keywords even though unity keeps spamming the error that theres more than 256. Also my Unity version is 2019.3.0b1.
     
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    9,609
    Why? Not sure about the rest, but being in an early beta definitely does not help.
     
  3. no00ob

    no00ob

    Joined:
    Dec 13, 2017
    Posts:
    62
    Because projects always break when updating and it takes like weeks to get them working again. The reason why this version in particular is because it fixed one bug I used to have way back and getting rid of that bug was necessary for me to be able to work on the game. Though updating the project now wouldn't probably hurt.
     
  4. no00ob

    no00ob

    Joined:
    Dec 13, 2017
    Posts:
    62
    After updating to the latest Unity version of 2019.3.12f1 it doesn't spam the error messages into the console anymore but there still comes an error whenever shaders get reloaded. The third-party tool still shows that I'd have 80 shaders and 100 unique keywords also 700 unused keywords but if I try to use it to remove them same thing happens as before where all of my materials get corrupted. This stupid issue caused by unity's dumb limitation of 256 shader keywords has now caused my project to be once again halted completely...
     
  5. ibbybn

    ibbybn

    Joined:
    Jan 6, 2017
    Posts:
    193
    Just open the "corrupted" materials with your fav. text editor and delete all the keywords after m_ShaderKeywords:
    They should work again.
    That line is basically what that third party tool is trying to edit but fails for some reason.
     
    no00ob likes this.
  6. no00ob

    no00ob

    Joined:
    Dec 13, 2017
    Posts:
    62
    So it is that simple? I was on the verge of trying that yesterday but decided not to just in-case that'd break something even further. So if that's all there is to it then thank you for your help.
     
  7. lsgheero

    lsgheero

    Joined:
    Mar 24, 2013
    Posts:
    59
    Did this work?
     
  8. lsgheero

    lsgheero

    Joined:
    Mar 24, 2013
    Posts:
    59
    I tried this after using the same tool you used, didnt work still had broken shaders in unity, actually the shaders didnt list any keyboards after m_shaderkeywords: Any help on this issue is greatly appreciated.
     
unityunity