I want this for my MaskMaps in ShaderGraph: There are different Texture Types, that don't help with that: Though the "Use Tiling and Offset" checkbox will create the well known GUI part: I cannot do the Remapping on my own, there is a "Remap" Node, but you can't convert to property and expose that. You can create Float sliders, but no min-max sliders so you need 2 Sliders (min + max) per Attribute (metallic, smoothness, AO) The Lit Shader simply defines 6 floats, but the GUI handles it elegantly, Code (CSharp): _MetallicRemapMin("MetallicRemapMin", Float) = 0.0 _MetallicRemapMax("MetallicRemapMax", Float) = 1.0 _SmoothnessRemapMin("SmoothnessRemapMin", Float) = 0.0 _SmoothnessRemapMax("SmoothnessRemapMax", Float) = 1.0 _AORemapMin("AORemapMin", Float) = 0.0 _AORemapMax("AORemapMax", Float) = 1.0 which is because the LIT shader uses CustomEditor "Rendering.HighDefinition.LitGUI". But even creating "_SmoothnessRemapMin" and "_SmoothnessRemapMax" as floats does not help, no matter if exposed or not. The DualSliders do not appear Is there a way? Or do you think this would be a nice suggestion? I need RangeSliders, or the Texture Mode "MaskMap" with a checkbox "Use Remap Sliders" to enable the gui for that.
That worked. The UI is quite clean now, but the amount of code required was high. I'd still welcome a checkbox to handle the creation of these sliders like the "use tiling and offset". For my triplanar Shader, I needed 3 Textures, with each 3 remap sliders. MyShaderGui.cs Code (CSharp): using System.Collections.Generic; using UnityEngine; using UnityEditor; using System.Linq; public class MyShaderGui : ShaderGUI { override public void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties) { Material targetMat = materialEditor.target as Material; Vector2 _TopMetallicRemap = targetMat.GetVector("_TopMetallicRemap"); Vector2 _TopSmoothnessRemap = targetMat.GetVector("_TopSmoothnessRemap"); Vector2 _TopOcclusionRemap = targetMat.GetVector("_TopOcclusionRemap"); Vector2 _SidesMetallicRemap = targetMat.GetVector("_SidesMetallicRemap"); Vector2 _SidesSmoothnessRemap = targetMat.GetVector("_SidesSmoothnessRemap"); Vector2 _SidesOcclusionRemap = targetMat.GetVector("_SidesOcclusionRemap"); Vector2 _ExtraMetallicRemap = targetMat.GetVector("_ExtraMetallicRemap"); Vector2 _ExtraSmoothnessRemap = targetMat.GetVector("_ExtraSmoothnessRemap"); Vector2 _ExtraOcclusionRemap = targetMat.GetVector("_ExtraOcclusionRemap"); string[] sliderProps = { "_TopMetallicRemap", "_TopSmoothnessRemap", "_TopOcclusionRemap", "_SidesMetallicRemap", "_SidesSmoothnessRemap", "_SidesOcclusionRemap", "_ExtraMetallicRemap", "_ExtraSmoothnessRemap", "_ExtraOcclusionRemap",}; EditorGUI.BeginChangeCheck(); foreach (MaterialProperty property in properties) { if(!property.flags.HasFlag(MaterialProperty.PropFlags.HideInInspector) && !sliderProps.Contains(property.name)) { materialEditor.ShaderProperty(property, property.displayName); if (property.name == "_Top_MaskMap") { EditorGUILayout.MinMaxSlider("Top_MetallicRemap", ref _TopMetallicRemap.x, ref _TopMetallicRemap.y, 0f, 1f); EditorGUILayout.MinMaxSlider("Top_SmoothnessRemap", ref _TopSmoothnessRemap.x, ref _TopSmoothnessRemap.y, 0f, 1f); EditorGUILayout.MinMaxSlider("Top_OcclusionRemap", ref _TopOcclusionRemap.x, ref _TopOcclusionRemap.y, 0f, 1f); } if (property.name == "_Sides_MaskMap") { EditorGUILayout.MinMaxSlider("Sides_MetallicRemap", ref _SidesMetallicRemap.x, ref _SidesMetallicRemap.y, 0f, 1f); EditorGUILayout.MinMaxSlider("Sides_SmoothnessRemap", ref _SidesSmoothnessRemap.x, ref _SidesSmoothnessRemap.y, 0f, 1f); EditorGUILayout.MinMaxSlider("Sides_OcclusionRemap", ref _SidesOcclusionRemap.x, ref _SidesOcclusionRemap.y, 0f, 1f); } if (property.name == "_Extra_MaskMap") { EditorGUILayout.MinMaxSlider("Extra_MetallicRemap", ref _ExtraMetallicRemap.x, ref _ExtraMetallicRemap.y, 0f, 1f); EditorGUILayout.MinMaxSlider("Extra_SmoothnessRemap", ref _ExtraSmoothnessRemap.x, ref _ExtraSmoothnessRemap.y, 0f, 1f); EditorGUILayout.MinMaxSlider("Extra_OcclusionRemap", ref _ExtraOcclusionRemap.x, ref _ExtraOcclusionRemap.y, 0f, 1f); } } } // if (EditorGUI.EndChangeCheck()) { targetMat.SetVector("_TopMetallicRemap", _TopMetallicRemap); targetMat.SetVector("_TopSmoothnessRemap", _TopSmoothnessRemap); targetMat.SetVector("_TopOcclusionRemap", _TopOcclusionRemap); targetMat.SetVector("_SidesMetallicRemap", _SidesMetallicRemap); targetMat.SetVector("_SidesSmoothnessRemap", _SidesSmoothnessRemap); targetMat.SetVector("_SidesOcclusionRemap", _SidesOcclusionRemap); targetMat.SetVector("_ExtraMetallicRemap", _ExtraMetallicRemap); targetMat.SetVector("_ExtraSmoothnessRemap", _ExtraSmoothnessRemap); targetMat.SetVector("_ExtraOcclusionRemap", _ExtraOcclusionRemap); EditorUtility.SetDirty(targetMat); } } } And then you need some variables in the blackboard: I had to make these "Exposed" - otherwise Unity would throw errors when trying to get the Vectors from the material, so I added the "sliderProps" array to exclude them from rendering in the GUI, because I draw them as MinMaxSliders anyway. And of course you need to set the "Custom Inspector GUI" Name in ShaderGraph:
GitHub - needle-tools/shadergraph-markdown: Markdown-like syntax for ShaderGraph properties, to make better material inspectors I think this will help you.