Search Unity

How unity statistic global keyword? Maximum number (256) of shader in unity 2018.

Discussion in 'Shaders' started by caffreyzzp_unity, Jun 15, 2021.

  1. caffreyzzp_unity

    caffreyzzp_unity

    Joined:
    Aug 7, 2019
    Posts:
    5
    Hey guys !

    [ Maximum number (256) of shader ].

    My project have so much shader keyword that engine always show this log, and it cause some shader not be complied.

    Could some one explain how the way that unity engine statistic those keyword ?

    Is that Even same keyword in different shader will be count mutli keyword or just one ?

    for example
    Example 1:
    Shader A has keyword __keywordA
    Shader B has keyword __keywordB

    Example 2:
    ShaderPass A has keyword __keywordA
    ShaderPass B has keyword __keywordB

    Example 3:
    SubShader A has keyword __keywordA
    SubShader B has keyword __keywordB

    Question1: Does Engine count it one or two ?
    Question2: How many unity always will be complied buitld-in keyword ?

    I know unity 2019 have local_keyword feather, Unfortunately , my project stuck at 2018 can't upgrade engine.
     
    Last edited: Jun 15, 2021
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,014
    Two global keywords with the same name count as one, even if they come from different shaders.
     
    caffreyzzp_unity likes this.
  3. caffreyzzp_unity

    caffreyzzp_unity

    Joined:
    Aug 7, 2019
    Posts:
    5
  4. caffreyzzp_unity

    caffreyzzp_unity

    Joined:
    Aug 7, 2019
    Posts:
    5
    Here is the result that i found.

    1.Unity 2018 maybe have 80 Keyword build-in in the Engine side, found it by make a new empty project, remove all include shader. and make 256 keyword shader to complie and found out the result.
    2.Keyword in material and shader will be counted in global keyword.
    3.so if you project have 256 max shader keyword probem . scan your project material and shader, reduce the keyword to about 150 .it should be safe.