diff --git a/Editor/Settings/DebugXSettings.cs b/Editor/Settings/DebugXSettings.cs index ab7c85e..fb44f77 100644 --- a/Editor/Settings/DebugXSettings.cs +++ b/Editor/Settings/DebugXSettings.cs @@ -55,6 +55,15 @@ namespace DCFApixels.DebugXCore.Internal color.a = EditorGUILayout.Slider(DebugX.GlobalColor.a, 0, 1); DebugX.GlobalColor = color; + + DebugX.GlobalGreaterPassAlpha = EditorGUILayout.FloatField("GreaterPassAlpha", DebugX.GlobalGreaterPassAlpha); + EditorGUI.BeginChangeCheck(); + tmpValue = EditorGUILayout.Slider(DebugX.GlobalGreaterPassAlpha, 0, 2); + if (EditorGUI.EndChangeCheck()) + { + DebugX.GlobalGreaterPassAlpha = tmpValue; + } + if (GUILayout.Button("Reset")) { DebugX.ResetGlobals(); diff --git a/Runtime/Consts.cs b/Runtime/Consts.cs index 5b0d381..758435d 100644 --- a/Runtime/Consts.cs +++ b/Runtime/Consts.cs @@ -23,9 +23,11 @@ namespace DCFApixels private const string GLOBAL_TIME_SCALE_PREF_NAME = "DCFApixels.DebugX.TimeScale"; private const string GLOBAL_DOT_SIZE_PREF_NAME = "DCFApixels.DebugX.DotSize"; private const string GLOBAL_COLOR_PREF_NAME = "DCFApixels.DebugX.Color"; + private const string GLOBAL_GREATER_PASS_ALPHA_PREF_NAME = "DCFApixels.DebugX.GreaterPassAlpha"; private readonly static int GlobalDotSizePropertyID = Shader.PropertyToID("_DebugX_GlobalDotSize"); private readonly static int GlobalColorPropertyID = Shader.PropertyToID("_DebugX_GlobalColor"); + private readonly static int GlobalGreaterPassAlphaPropertyID = Shader.PropertyToID("_DebugX_GlobalGreaterPassAlpha"); internal readonly static int ColorPropertyID = Shader.PropertyToID("_Color"); diff --git a/Runtime/DebugX.globals.cs b/Runtime/DebugX.globals.cs index 7895df2..b1854fb 100644 --- a/Runtime/DebugX.globals.cs +++ b/Runtime/DebugX.globals.cs @@ -49,6 +49,21 @@ namespace DCFApixels var record = *(int*)&c32; #if UNITY_EDITOR EditorPrefs.SetInt(GLOBAL_COLOR_PREF_NAME, record); +#endif + } + } + private static float _globalGreaterPassAlphaCache; + public static float GlobalGreaterPassAlpha + { + get { return _globalGreaterPassAlphaCache; } + set + { + if (_globalGreaterPassAlphaCache == value) { return; } + _globalGreaterPassAlphaCache = value; + Shader.SetGlobalFloat(nameID: GlobalGreaterPassAlphaPropertyID, _globalGreaterPassAlphaCache); + +#if UNITY_EDITOR + EditorPrefs.SetFloat(GLOBAL_GREATER_PASS_ALPHA_PREF_NAME, _globalGreaterPassAlphaCache); #endif } } @@ -58,22 +73,27 @@ namespace DCFApixels EditorPrefs.DeleteKey(GLOBAL_TIME_SCALE_PREF_NAME); EditorPrefs.DeleteKey(GLOBAL_DOT_SIZE_PREF_NAME); EditorPrefs.DeleteKey(GLOBAL_COLOR_PREF_NAME); + EditorPrefs.DeleteKey(GLOBAL_GREATER_PASS_ALPHA_PREF_NAME); #endif - _dotSizeCache = default; _timeScaleCache = default; + _dotSizeCache = default; _globalColorCache = default; + _globalGreaterPassAlphaCache = default; InitGlobals(); } private static void InitGlobals() { - GlobalTimeScale = 1; - GlobalDotSize = 1; - GlobalColor = Color.white; #if UNITY_EDITOR GlobalTimeScale = EditorPrefs.GetFloat(GLOBAL_TIME_SCALE_PREF_NAME, 1f); GlobalDotSize = EditorPrefs.GetFloat(GLOBAL_DOT_SIZE_PREF_NAME, 1f); var colorCode = EditorPrefs.GetInt(GLOBAL_COLOR_PREF_NAME, -1); GlobalColor = (Color)(*(Color32*)&colorCode); + GlobalGreaterPassAlpha = EditorPrefs.GetFloat(GLOBAL_GREATER_PASS_ALPHA_PREF_NAME, 0.1f); +#else + GlobalTimeScale = 1; + GlobalDotSize = 1; + GlobalColor = Color.white; + GlobalGreaterPassAlpha = 0.1f; #endif } } diff --git a/Runtime/Shaders/Handles.shader b/Runtime/Shaders/Handles.shader index 0aa52b4..886af56 100644 --- a/Runtime/Shaders/Handles.shader +++ b/Runtime/Shaders/Handles.shader @@ -67,7 +67,7 @@ Shader "DCFApixels/DebugX/Handles" }; float4 _DebugX_GlobalColor; - + float _DebugX_GlobalGreaterPassAlpha; v2f vert (appdata_t v) { @@ -123,7 +123,8 @@ Shader "DCFApixels/DebugX/Handles" CGPROGRAM half4 frag (v2f i) : SV_Target { - return i.color * half4(1, 1, 1, 0.1); + //return i.color * half4(1, 1, 1, 0.1); + return i.color * half4(1, 1, 1, _DebugX_GlobalGreaterPassAlpha); } ENDCG } diff --git a/Runtime/Shaders/HandlesWire.shader b/Runtime/Shaders/HandlesWire.shader index c1655dc..cb95dc5 100644 --- a/Runtime/Shaders/HandlesWire.shader +++ b/Runtime/Shaders/HandlesWire.shader @@ -74,7 +74,7 @@ Shader "DCFApixels/DebugX/Handles Wire" }; float4 _DebugX_GlobalColor; - + float _DebugX_GlobalGreaterPassAlpha; v2g vert (appdata_t v) { @@ -154,7 +154,8 @@ Shader "DCFApixels/DebugX/Handles Wire" CGPROGRAM half4 frag (g2f i) : SV_Target { - return i.color * half4(1, 1, 1, 0.1); + //return i.color * half4(1, 1, 1, 0.1); + return i.color * half4(1, 1, 1, _DebugX_GlobalGreaterPassAlpha); } ENDCG }