Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Maximum number (256) of shader global keywords exceeded, keyword will be ignored and black materials

Discussion in 'General Graphics' started by dienat, Jan 4, 2020.

  1. dienat

    dienat

    Joined:
    May 27, 2016
    Posts:
    417
    I use 2019.2 and Standard rendering, and there is still a max of 256 global keywords, that means if you import a lot of different assets from the Unity asset store you will get this error making game not work properly. When is this going to be solved?
    At the moment the problem i am having is that certain shaders, Uber shaders from asset store, are rendered black in the build (in editor work fine) and i am not sure if this max global keywords could be the culprit. I tried uber shaders in an empty project and they work fine.
     
    yubo123 likes this.
  2. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,281
    We have local keywords now too, but it requires the shaders to be updated.

    Eg shader_feature becomes shader_feature_local, then it doesn’t count towards the global limit anymore.
     
    ImpossibleRobert and dienat like this.
  3. dienat

    dienat

    Joined:
    May 27, 2016
    Posts:
    417
    So i just have to change that in the shader? But to enable or disable keywords shouldnt work as are meant to global shaders, so i understand you must change the C# code also to change Shader.EnableKeyword to material.EnableKeyword?
     
  4. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,281
    Hopefully the google doc linked here can provide more info: https://forum.unity.com/threads/shader-keyword-limit.545491/#post-3832954

    Sorry it’s not in the proper docs.. not sure why that is :(
     
    darkAbacus247 likes this.
  5. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,281
  6. DavidSWu

    DavidSWu

    Joined:
    Jun 20, 2016
    Posts:
    183
    It is unfortunate that the included shaders do not use local keywords.
    It would be nice if they did.
     
    bok likes this.
  7. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,281
    We have been trying to update some included shaders to use the local keywords - are there any shaders in particular you have seen that you think should be using them?
     
  8. DavidSWu

    DavidSWu

    Joined:
    Jun 20, 2016
    Posts:
    183
    Simple Lit and friends
     
    bok and ImpossibleRobert like this.
  9. GameDevDustin

    GameDevDustin

    Joined:
    Jul 17, 2015
    Posts:
    16
    Trying to deal w/ this in 2019.4LT / HDRP has been ridiculous.
     
  10. E_T_

    E_T_

    Joined:
    May 14, 2018
    Posts:
    19
    Layered Lit Shaders. This problem has been absolutely KILLING productivity on my project. Please Unity. FIX this issue ASAP.
     
  11. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,983
    richardkettlewell likes this.
  12. ScorphiusMultiplayer

    ScorphiusMultiplayer

    Joined:
    Nov 10, 2018
    Posts:
    66
    Oh please remove this limit. You tempt us with your "Sales" and I cannot even use more than 8 packages.
    (Vegetation engine, Vegetation Studio, Lux Waters, Infinity PBR models, UMA and a few other freebies)
    FIX this ASAP!!!
     
    DeadCastles, Havie and fertel like this.
  13. DarkGate

    DarkGate

    Joined:
    Jan 26, 2016
    Posts:
    33
    x2plore, RakNet and d1favero like this.
  14. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,288
    Indeed, now in Unity 2020 i get multiple users of my assets report the error message, this is just not working anymore, is like a big bug.

    Please do something about it, same thing in Unity 2019.4.5f1 worked fine and in 2020.2 has the exceeded shader keyword issue, seems like an exponential increase in global keywords from Unity side, which is terrible if happen and we have to change everything.
     
    d1favero likes this.
  15. Tymianek

    Tymianek

    Joined:
    May 16, 2015
    Posts:
    97
    For a quick fix empty Library/ShaderCashe. (not guaranteed to work, but it worked in a couple of my projects)

    Edit: The shader keyword limit was increased to 384, so if you are getting this error, consider upgrading Unity. (2021.1.0b2+, 2020.2.3f1+, 2019.4.19f1+)

    Edit2: The shader keyword limit was removed in 2021.2.0a16+
     
    Last edited: May 13, 2021
    MagiJedi, Tarya and GKotlidas like this.
  16. GKotlidas

    GKotlidas

    Joined:
    Jul 28, 2012
    Posts:
    12
    +1 Also worked for me !!
     
    Tymianek likes this.
  17. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,126
    Lol, i'm seeing 384 keywords exceeded now . I don't think they really fixed the root issue here.
     
  18. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,288
    darkAbacus247 and keithsoulasa like this.
  19. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,126
    Thank God. I found a work around ( forcing unity to reimport all is a nasty brute force method), but it was very annoying to find .
     
    nasos_333 likes this.
  20. Havie

    Havie

    Joined:
    Oct 12, 2019
    Posts:
    89
    So what was your workaround? Not seeing any brute force mentions in that link ?

    I imported an asset onto a test branch, and it triggered this issue. I have since reverted the changes, and gone back to my main branch. However I still get this error when trying to build now..... even though the files are gone? I also deleted the Library/ShaderCache folder... didnt seem to help..?

    EDIT: on 2019.4.0 LTS
     
    Last edited: Apr 16, 2022
  21. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,126
    You have to reimport everything, you can either delete your library folder and reopen your project, or right click and select re import all.
     
  22. Havie

    Havie

    Joined:
    Oct 12, 2019
    Posts:
    89
    ahh yes my issue was that I wasnt closing the project in between deleting everything.. so it somehow wasnt refreshing properly.
    Thank you