Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta blog post.
    Dismiss Notice

Bug Global shader keywords don't work at runtime for shader graph shader

Discussion in 'Shader Graph' started by Silly_Rollo, Jun 30, 2021.

  1. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    499
    Running URP in 2020.2.7f1 I have the following shader built with this simple keyword node: upload_2021-6-29_19-15-42.png
    upload_2021-6-29_19-16-1.png
    which toggles a simple dissolve effect.

    In the editor outside of runtime I can toggle it on and off and it works perfectly fine
    Code (CSharp):
    1.  
    2.         [Button]
    3.         private void TurnOnIsoView() {
    4.             Shader.EnableKeyword("_ISOENABLED");
    5.         }
    6.  
    7.         [Button]
    8.         private void TurnOffIsoView() {
    9.             Shader.DisableKeyword("_ISOENABLED");
    10.         }
    11.  
    12.         [Button]
    13.         private void CheckKeyword() {
    14.             Debug.Log(Shader.IsKeywordEnabled("_ISOENABLED"));
    15.         }
    16.  
    the test is correct and all the materials in the scene follow the effect. However, at runtime (still in the editor) I can toggle this and it does absolutely nothing. The debug.log shows it is toggling but nothing is affected. The meshes in question are NOT marked static so there can't be anything involving static batching. Any ideas?
     
unityunity