Search Unity

Showcase ShaderGraph Markdown — Make shiny inspectors for your ShaderGraph materials

Discussion in 'Shader Graph' started by fherbst, Jan 4, 2021.

  1. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    802
    I'm happy to announce the immediate availability of a new @NeedleTools package:

    ShaderGraph Markdown
    Shiny inspectors for ShaderGraphs, the easy way ✨

    Get on the Asset Store • Non-commercial version on OpenUPM Follow on Twitter
    00_Overview.png

    It uses a markdown-inspired syntax for properties, and turns them into a nice and clean material UI.
    You can make foldouts, notes, links, conditional properties, custom drawers and more!

    01_ShaderGUI.gif

    Conditional Properties are also supported:

    02_ConditionalProperties.gif 05_BlackboardConditions.png

    Supported versions:
    • Unity 2019.4—2021.1
    • SRP 7.5—12.x.
      No support for SRP 7.3 and earlier as it wasn't possible to specify custom Shader GUIs for ShaderGraph shaders there.
    • HDRP support also includes the custom additional material drawers that HDRP sets for specific surface types.

    I hope its useful, happy shader-making everyone! ✨
    Felix
     
    Last edited: May 10, 2021
  2. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    That looks great.

    Is it posible to do an material ui for this HDRP Lit Shadergraph clone
    https://github.com/RemyUnity/SG-HDRP-Lit/tree/keywords

    who looks the same like the HDRP Lit Standard UI ? This would be great because every HDRP Lit could be auto converted to the Shadergraph version and could be easily extended.
     
  3. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    802
    If you want identical UI behaviour to HDRP/Lit, it's actually easier to just use the ShaderGUI of that directly, which is
    Rendering.HighDefinition.LitGUI
    . Only thing needed for that to work is having the right properties in the shader, how you connect them (and thus which features to implement) is then up to you.

    I auto-added all properties that HDRP/Lit has to Remy's HDRP-ShaderGraph project and enabled that LitGUI if you want to take a look:
    https://github.com/needle-tools/SG-HDRP-Lit/tree/keywords

    That being said, I'll take a closer look at some of the additional features that this particular UI uses and add it to the backlog for ShaderGraph Markdown, for example
    • a custom drawer that specifies a texture and a float or color to be drawn on one line
    • the ability to indent fields to visually group them better
    • a way to show hints/errors based on conditional properties
    • a way to display a float as an enum ([Enum] attribute isn't supported in ShaderGraph right now)
    Thanks for the feedback!
     
    Last edited: Jan 8, 2021
    florianBrn likes this.
  4. Passeridae

    Passeridae

    Joined:
    Jun 16, 2019
    Posts:
    395
    Whoa, been waiting for something like this for a while! Huge thanks!
    I'll try this magic tool next week:)
     
    fherbst likes this.
  5. Passeridae

    Passeridae

    Joined:
    Jun 16, 2019
    Posts:
    395
    It would be super-useful to have this kind of texture map input and sliders:



    This is a screenshot from a default HDRP Lit Shader. You've posted a way to create an exact same layout for shader graph in a message above, yes, but it would be extra cool to have both this kind of look and your notes, foldouts, etc.

    - A small field for a texture input aligned to the left side (btw, amplify can do this kind of thing)
    - A slider on the same line as the texture input (like the normal map) - it saves a lot of space.
    - A remapping slider option

    But what you've done so far is already really great, I'm adding this to all of my shaders.
    Thanks!
     
    Last edited: Jan 16, 2021
    NotaNaN, florianBrn and fherbst like this.
  6. Passeridae

    Passeridae

    Joined:
    Jun 16, 2019
    Posts:
    395
    Btw can't make keywords and condition work with HDRP 10
    No matter what I do, the inspector shows only the default "A, B, C" options (which I've renamed long time ago) which do nothing.
     
  7. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    802
    @passeridaepc regarding the keywords, that's a known bug in ShaderGraph with keywords. It's super annoying (and not a ShaderGraph Markdown issue).
    EDIT: I think it always corrects itself if you reimport any script (thus causing a Domain Reload / refreshing everything). Just reported a bug for this to Unity.

    The remap sliders are a nice idea for a custom drawer, I'll see what I can do! The "small texture + color or slider" is also already on the backlog :) Thanks for the feedback!
     
    Last edited: Jan 16, 2021
  8. Passeridae

    Passeridae

    Joined:
    Jun 16, 2019
    Posts:
    395
    For me it doesn't show the correct entry naming from the begging. Looks like an HDRP bug. No matter what markdown I use it's supposed to show at least the correct naming in the inspector, instead of "A, B, C", anyway, right?
     
  9. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    802
  10. florianBrn

    florianBrn

    Joined:
    Jul 31, 2019
    Posts:
    53
    That looks awesome!

    Sadly I'm having an error when installing version 0.4.4 from the .unitypackage, using Unity 2019.4.11f1 with HDRP/ShaderGraph 7.3.1:
    Library\PackageCache\com.needle.shadergraph-markdown@0.4.4-exp\Editor\Internal\ShaderGraph\MarkdownSGExtensions.cs(123,81): error CS0234: The type or namespace name 'ICanChangeShaderGUI' does not exist in the namespace 'UnityEditor.Graphing' (are you missing an assembly reference?)
     
  11. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    802
    @florianBrn thanks for reporting - looks like that slipped through testing (or Unity made a breaking change between 7.3.1 and 7.5, which is the most recent 7.x version). I'll take a look.

    By the way, you can also join our support discord at https://discord.gg/CFZDp4b if you want! Feedback is always appreciated :)

    EDIT: @florianBrn turns out in HDRP/URP 7.3.2 it wasn't possible to even set a custom Shader GUI for ShaderGraph shaders — this in turn means I can't really support ShaderGraph Markdown there (as the whole point is to have a custom gui that "looks nice"). Sorry, wasn't aware of this! I would recommend you update to 7.5 in PackMan, there's no support for 7.3 from Unity anymore anyways.

    I'll update the docs to make the 7.5 requirement more clear!
     
    Last edited: Jan 20, 2021
    florianBrn likes this.
  12. florianBrn

    florianBrn

    Joined:
    Jul 31, 2019
    Posts:
    53
    Updated to 7.5.1, works fine now. Thanks!
     
    fherbst likes this.
  13. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    265
    @fherbst great addon! Mainly using it because of the gradient support. Curious if you've heard of an issue where the mappedGradients dictionary goes null? It then shows a null ref exception within the inspector (but not console log).

    Pretty often clicking Apply also doesn't seem to update the texture preview of the gradient within the inspector, and I've gotten it into states where the gradient no longer updates.

    I had to start naming my gradient texture property as _RampTexture (same property that GradientGeneratorDrawer uses as texturePropertyName when the Apply button is clicked), because without doing this it got into a state where no gradients would get updated. Is that intended? I was debugging it and didn't see texturePropertyName ever change so I had to start making sure that I just used _RampTexture as the property name
     
  14. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    802
    Hi @XRA , sorry I missed your post! The gradient code was mostly provided as an example, and I haven't heard of others having these issues so far - would you be able to list some repro steps for it, e.g. at which point do the gradients disappear/not update anymore?

    Regarding the
    _RampTexture
    name, the intended use is:
    • generate a GradientDrawer scriptable object (via Create/ShaderGraph Markdown/Gradient Generator Drawer)
    • name it as you wish (e.g.
      MyNewGradientDrawer
      ) and set the texture property name as desired, e.g.
      _MyTexture
    • reference the drawer via
      !DRAWER MyNewGradientDrawer
    This way, you can have different gradient properties with different names, just make a new ScriptableObject for them. If you don't have any, then an implicit one is generated which always has that default name of
    _RampTexture
    .

    I was also thinking about making an update to the GradientDrawer that allows specifying a texture name as parameter (so the above would become
    !DRAWER GradientDrawer _MyTexture
    ) - that might also make usage easier.
     
  15. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    802
    Shader Graph Markdown is now also available from the Asset Store for commercial use :)
    Includes a lot of bugfixes and improvements, especially to custom drawers, inlined properties, and much more!
     
  16. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    621
    Thanks for this really nice asset, just tried it out for the first time. Definitely helps making material/shader inspectors much more pleasant to work with!
    A minor suggestion though: The tiling and offset inlining is a cool idea, but it seems to work only for properties that are named _TilingOffset. Unless I'm mistaken, this means there can only be a single Vector4 property in a shader where this can be done. Instead, it would be great if the property name was not required to be a direct match, but instead simply have the name end with TilingOffset.
    Also, would it be possible to make the inspector not draw 'superfluous' components for e.g. Vector2 and Vector3 properties? Those can be pretty confusing/clutter up the interface.
     
  17. lmgiorni

    lmgiorni

    Joined:
    Mar 14, 2014
    Posts:
    7
    Hi, could it be possible to specify the warp mode of the gradient texture as to set it to Clamp for example?
    And what about resolution size?
    Thanks in advance.
     
  18. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    802
    Hi! You can already do that on the generated texture asset - only the bytes will be overwritten, not custom modes that you specify there. As per the resolution, I recently added a fix for the texture size not being big enough / not smooth enough by defaulting it to to uncompressed.

    Let me know if that helps, and thanks for the feedback!