Search Unity

Keyword Reporting and Removal tools [FREE]

Discussion in 'Shaders' started by n00body, Jul 14, 2016.

  1. n00body

    n00body

    Joined:
    Dec 17, 2010
    Posts:
    691
    Okay, so I saw a need in the community for shader keyword Reporting and Removal tools, so here they are. They're kinda barebones, but ideally you won't have to use them more than once:
    https://www.dropbox.com/s/yavnugc6plt43gj/KeywordTools.unitypackage?dl=0

    Let me know if these helped or not. Thanks.

    Update 6:
    Changed "Reporter" to add a section for shaders that list their associated materials.

    Update 5:
    Fixed an issue where the Obliterater was having argument out of range exceptions.

    Update 4:
    Fixed Material -> Keyword lists to be sorted alphabetically.

    Update 3:
    Fixed issue where empty keyword strings appeared in reports.

    Update 2:
    Added counts for each section in the keyword reports.
    Improved performance slightly.

    Update 1:
    Changed the Reporter tool to have much more readable reports with keywords that can be directly copy-pasted to the Obliterater.
     
    Last edited: Jul 13, 2017
  2. n00body

    n00body

    Joined:
    Dec 17, 2010
    Posts:
    691
    Posted my first package update within a few hours of putting up this thread. :p

    I also wanted to share an annoying realization I had from using the tool on my Alloy project. Apparently Unity's "[KeywordEnum()]" tag sets keywords for all its options, even if you only have a shader feature that responds to the second or third one. So it is more keyword efficient to use a "[Toggle()]" if you only want one keyword from the control.
     
  3. n00body

    n00body

    Joined:
    Dec 17, 2010
    Posts:
    691
    So I figured out why Unity sometime reports that you've gone over the keyword limit in a given scene, but then works fine in the same scene after closing and reopening the editor. The report said that when changing scenes, the editor seems to hold onto references to some of the materials from the previous scene. Said materials' keywords can then easily push you over the limit. >_<
     
    Last edited: Jul 15, 2016
  4. kebrus

    kebrus

    Joined:
    Oct 10, 2011
    Posts:
    414
    That is actually pretty cool. Thx for sharing

    Maybe you could also put the total amount of materials or keyword in each "k->m" / "m->k" entry, but that is something that seems easy to edit.
     
  5. n00body

    n00body

    Joined:
    Dec 17, 2010
    Posts:
    691
    @Kerbus
    Done. Feel free to grab latest. ;)
     
    Carterryan1990 likes this.
  6. Killersan

    Killersan

    Joined:
    May 27, 2014
    Posts:
    76
    Hello guys,

    I used that tool which n00body made, because I reached the limit 128 keywords and I have to admit that I'm a little confused. In report of the tool I have information that I'm using 33 keywords, but while I'm making a build I got error that I reached 128 keywords and I got 4 of such errors, so according to that I used 132 keywords, any clue what can cause such misinformation ?
     
  7. n00body

    n00body

    Joined:
    Dec 17, 2010
    Posts:
    691
    @Killersan
    Honestly, I'm not sure. I've known Unity to sometimes keep references to materials from prior scenes when switching between scenes. Otherwise, I just don't know.
     
  8. n00body

    n00body

    Joined:
    Dec 17, 2010
    Posts:
    691
    Update 6:
    Changed "Reporter" to add a section for shaders that list their associated materials.
     
  9. Exbleative

    Exbleative

    Joined:
    Jan 26, 2014
    Posts:
    200
    Thanks for the tool, I'm only getting 20ish keywords listed as used, and still going over the 128 limit. Obviously there's still lots of shaders and keywords being used in stuff like Scion and other screen space type plugins. Some seem to be listed by your reporter, most aren't.

    In my error report, it lists keywords used in the Project. When I copy a keyword from this and search in VS project wide, it'll show up in a shader I'm using, but whose features aren't enabled, so I don't know why they'd be in that error report as being used.

    I've even tried deleting my Library/shadercache folder, and went through every material in my entire project in Debug mode, deleting any keywords that weren't being used. No difference.

    Really still very confused how and when keywords are "used", or whether these multi_compile things use up keywords, or if only the selected variants do, etc. Wish someone would write a guide on all this stuff because it seems like such a common problem.
     
  10. n00body

    n00body

    Joined:
    Dec 17, 2010
    Posts:
    691
    @Exbleative
    Keywords are associated with materials. Materials hold onto keywords, even when you change shaders. So if you have a really old material, it can have lots of keywords associated with it.

    In the past, I've also noticed that some really old materials go over the limit, even if they don't appear to have enough keywords. Have you tried regenerating your materials from scratch?
     
  11. Exbleative

    Exbleative

    Joined:
    Jan 26, 2014
    Posts:
    200
    Thanks but I'm pretty sure I've done this already, unless I missed a step somewhere. I filtered my project by material and in debug mode Inspector I selected every material, deleted its keywords, moved a slider to 'regenerate' them, repeat. I did notice this remove some but obviously not enough. Is that what you mean by regenerating them?

    Surely keywords are also associated with screen space shaders as well? So if I have 20 in my scene (as reported by your tool) and 109 screen space shader keywords I'll go over that 128 limit, right?
     
  12. n00body

    n00body

    Joined:
    Dec 17, 2010
    Posts:
    691
    No I meant making brand new materials and setting them from scratch. Yes, screen space effects do use keywords. The whole damn thing is a cryptic system that has been a huge pain to track.
     
    Tethys and Exbleative like this.
  13. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    659

    Haha, well said! We have felt this pain for months on end now but with Unity 5.5 there is a light at the end of the tunnel. Thanks for taking your time to help explain this cryptic system and your ideas on how to get around the limits. :) Still trying to sort this while waiting for that 5.5 to go from Beta to full release. ;)
     
  14. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    313
    Hi there, it appears this tool is no longer hosted, would it be possible to reupload it? Cheers!
     
  15. n00body

    n00body

    Joined:
    Dec 17, 2010
    Posts:
    691
    @Karearea
    Sorry about the delayed response. Try the new link.
     
  16. RKeown3D

    RKeown3D

    Joined:
    Oct 14, 2014
    Posts:
    147
    Very nice utility!!!