Search Unity

Feedback Out of date keywords in Materials would break SRP batch

Discussion in 'General Graphics' started by jayatubi, May 25, 2020.

  1. jayatubi

    jayatubi

    Joined:
    Dec 9, 2013
    Posts:
    143
    Suppose such case:

    1. There is a keyword `_ENABLE_SOME_FEATURE` in a shader;
    2. Create two materials from this shader and toggle the keyword on one of the materials;
    3. Remove the keyword from shader that would make the an out of date keyword remain in the previous material.
    4. Attemp to render these two materials with SRP batch on;

    After that in the frame debugger you would see these two materials were not able to SRP batch with a reason: materials have different keywords.

    5. Open the material by a text editor locate the out of date keyword and remove it manually then render them again;

    Now this time you could see them are successfully SRP batched.

    Can the SRP batcher auto ignores the invalid keywords? For now I have to create a script myself to check hundreds of materials once a shader was changed to remove the invalid keywords.
     
    funkisooo and SeXianSheng001 like this.
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,025
  3. jayatubi

    jayatubi

    Joined:
    Dec 9, 2013
    Posts:
    143
    However, in the frame debugger you could see the actual working keywords were same which means unity could determine that somehow I think.
     
  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,025
    This is "what it ended up using" and not "what was the input". It's complicated :)
    We have keyword system improvements in future plans.
     
  5. jayatubi

    jayatubi

    Joined:
    Dec 9, 2013
    Posts:
    143
    That's cool.
     
  6. funkisooo

    funkisooo

    Joined:
    Mar 4, 2019
    Posts:
    1
    I found that still breaks the SRPbatch in 2020.3.38f1.
    Is there any solutions?
    ..or maybe a script that i can check all my materials?
     
    Nick_Apoc likes this.