Search Unity

Feature Request Shadergraph shader variants

Discussion in 'Shader Graph' started by Japa, Apr 29, 2019.

  1. Japa

    Japa

    Joined:
    May 4, 2013
    Posts:
    33
    My current project, which I'd like to port over to LDRP, makes very heavy use of shader features to turns parts of the shader on and off.

    Having shader features and multi-compiling in shader graphs would be very helpful.
     
    khalvr, Jes28 and ph_ like this.
  2. Horus_Sungod42

    Horus_Sungod42

    Joined:
    Oct 30, 2014
    Posts:
    67
    One of the Unity employees mentioned that static switches, which disable bits of the shader, are eventually be implemented.

    I don't know if that answers the question :)
     
  3. opengl2009

    opengl2009

    Joined:
    Apr 22, 2019
    Posts:
    1
    I am facing the same problem too, hope that there will be a solution in Unity2019.X
     
  4. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    435
    Any news about this?
     
  5. Jes28

    Jes28

    Joined:
    Sep 3, 2012
    Posts:
    468
    Bump
     
  6. alexandral_unity

    alexandral_unity

    Unity Technologies

    Joined:
    Jun 18, 2018
    Posts:
    110
    Being able to add keywords for multi compiles etc. is landed in master branch on our repository, and should be available soon for 2019.3.
     
  7. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    2,237
    Just to make sure I understand what this means, I'll be able to define Keywords in a shader graph shader, which will only be executed if EnableKeyword() is called on the material? Just curious what the UI for this will look like. Is it implemented as a branch, where the keyword being enabled or not is the condition?
     
  8. Can-Baycay

    Can-Baycay

    Joined:
    Dec 14, 2010
    Posts:
    16
  9. alexandral_unity

    alexandral_unity

    Unity Technologies

    Joined:
    Jun 18, 2018
    Posts:
    110
    No, we're not planning on backporting this feature to previous versions.
     
  10. Levi-Burton

    Levi-Burton

    Joined:
    Jul 9, 2012
    Posts:
    7
    Is there anywhere you can point me to so that I can play around with this feature? I would like to be able to do something like this this in a custom function node (or whatever, I can adapt):

    Code (csharp):
    1. #if defined(HEX_MAP_EDIT_MODE)
    2. data.x = 1;
    3. #endif
    4. output = data;
    5.  
    And turn it on/off from C#:

    Code (CSharp):
    1. Shader.EnableKeyword("HEX_MAP_EDIT_MODE");
    2. Shader.DisableKeyword("HEX_MAP_EDIT_MODE");
     
  11. Levi-Burton

    Levi-Burton

    Joined:
    Jul 9, 2012
    Posts:
    7
    Nevermind, Just updated to 2019.3.0b6 and now I can create Keywords on my blackboard and it works -- sweet!

    Capture.PNG
     
  12. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    2,237
    And how do you make use of it? Just as an input to a branch node, like any other boolean value? I assume there must be some behind-the-scenes magic that removes the code from the other branch or something, the way you could with #if in a coded shader.
     
  13. julian-moschuering

    julian-moschuering

    Joined:
    Apr 15, 2014
    Posts:
    387
    You just drag the keyword in and link the the different inputs. Code not affecting the output is automatically removed by the shader compiler.
     
    Levi-Burton and dgoyette like this.
unityunity