Search Unity

[SOLVED] 64 Keyword Limit questions

Discussion in 'Shaders' started by n00body, Jun 20, 2014.

  1. cician

    cician

    Joined:
    Dec 10, 2012
    Posts:
    233
    I agree. I think the right way about it is to crate a distinct new feature for design-time keywords. Most use cases I have in mind for shader keywords don't have any benefit of being controlled by global shader state and if that is desired the classic multi-compile could be used.
    Even if switching keywords always triggered a recompile (like in unreal) I think it would be better than the status quo, since the multicompile feature is very tempting for us, but then bites back unpredictably.
     
  2. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    364
    I hope for a solution soon. or increase this 128 to a greater number.
     
  3. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,070
    just count only the ones used in a scene
     
  4. lxpk

    lxpk

    Joined:
    Feb 3, 2009
    Posts:
    43
    I also would like this, a shader keyword audit window would be like WinDirStat (for identifying and deleting the largest unnecessary files in your disk). It would also be a great idea for a myriad of other usability reasons to have a shader preview window that could show all the materials using each shader. Knowing which scenes they were in would be great too. If you could pick a list of scenes as "crucial" (like the ones in build settings that are checked by default) and see which shaders aren't used in those, it would help identify shaders you might have picked up from the asset store without realizing it. A way to turn shaders "off" from Unity loading them without deleting them would make the result less of a swiss cheese situation, letting you see if a material uses a disabled shader by making it cyan instead of magenta for example so you can gauge if you need to re-enable it or not.
     
    Last edited: Jun 22, 2016
  5. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    3,834
    Would love to have something like that as well. I've hit the limit as well and I'm not quite sure how to proceed now.

    Edit: FYI I've deleted TONS of shaders from my project and it seems like it only correctly recounted the shaders after restarting Unity.
     
    Last edited: Jun 27, 2016
  6. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,536
    Status update: for Unity 5.5 we've increased keyword limit to 256 and optimized all the related parts so that there's no performance regressions (in fact performance gains in some cases -- due to optimizations). Currently still haven't decided whether the change is "not risky enough" to put it into 5.4.1 or so...
     
    ilmario, daisySa, radimoto and 4 others like this.
  7. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    3,834
    Awesome! That's great news!
     
    Crossway likes this.
  8. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    371
    Can I ask a stupid question? If I use the same keyword in 2 shaders, does this count as 1 or 2 keywords?

    eg.

    Code (CSharp):
    1. //Shader 1
    2. #pragma multi_compile MY_KEYWORD
    3.  
    4. //Shader 2
    5. #pragma multi_compile MY_KEYWORD
     
  9. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    720
    1 keyword.
     
    flashframe likes this.
  10. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    371
    Thanks!
     
  11. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,001
    Great new, thanks guys :)
     
  12. n00body

    n00body

    Joined:
    Dec 17, 2010
    Posts:
    691
    Primerist, KRGraphics and Martin_H like this.
  13. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    364
  14. n00body

    n00body

    Joined:
    Dec 17, 2010
    Posts:
    691
    @Crossway
    Please post comments/questions related to the tool in its thread. Thank you.
     
  15. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    3,975
    I'm glad you are upping the keyword limit, but tbh, I usually just delete any shaders that will never use.

    The assets in my project:

    HBAO
    Scion
    Alloy (I delete unneeded shaders. Just using Core, Character, Transmission, and SpeedTree shaders)
    MeshBrush (shaders not imported)
    SkyCube (Until Unity 5.5 allows HDR format for Sky boxes at 32FP)
    Amplify Colour/Motion
    UFE

    I should not be hitting any limit on keywords... I'm gonna do another round of cleanup when I get home. This is getting tiresome. I have three high detail level and hitting these limits are a pain.
     
    Tethys likes this.
  16. Emilio-Martinez

    Emilio-Martinez

    Joined:
    Jun 19, 2015
    Posts:
    2
    Would this just affect the way we set keywords, or the inner workings of shaders too? Something about distinguishing Global and Local keywords in the shader doesn't feel right to me. I don't see why a shader should care if the command to NORMALIZE_ALL is just for this material, or was set globally.

    Also, making wild guesses about the implementation, wouldn't my local material keywords brake/change/clear when I change the material's shader?
     
  17. Primerist

    Primerist

    Joined:
    Sep 19, 2016
    Posts:
    5
    Thank you for making this tool N00body, this is exactly what I was looking for. Hopefully I'll have room to add some Alloy shaders now. Looking forward to Unity 5.5 256 keywords but can't upgrade to beta till so many other assets confirmed compatible.
     
  18. cpxnet

    cpxnet

    Joined:
    Mar 22, 2015
    Posts:
    10
    Is it true for IOS Metal?
    I have 6 shaders, and they all share the same 12 keywords.
    On windows or mac everything is OK. but when i run on IOS Metal, the app crashed immediately with
    Code (CSharp):
    1. Message from debugger: Terminated due to memory issue
    According to my test, there can be many objects on screen if they share the same shader,
    but it will crash if 2 or more shader are used simutenously.
     
  19. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,536
    That sounds like a completely different issue to me. Can you file a bug with a repro project? I'd say 99% probability it's not related to keywords at all, but crashes due to "something else".
     
    Martin_H likes this.
  20. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,192
    Just in case anyone is interested here's a new extension tool that takes care of shader keywords at project level.
    It will allow you to disable any keyword per shader with a click, not only at material level but at shader code - so those extra shader variants don't really get in the build.

    Shader Control:
    https://www.assetstore.unity3d.com/#!/content/74817
     
  21. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    522
    And if we're back at this topic anyway; 5.5 will double the limit again, up to 256.
     
    ksam2 likes this.
  22. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,192
    Yes, 256. However that's a reasonable limit for things that you want to include in your build (and worth of waiting for building), not space for more junk into your binary.
     
    ksam2 likes this.