From dedd847fd0c5faa5094a08293600cbb8aa4b6456 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Tue, 8 Sep 2020 11:23:54 +0900 Subject: [PATCH] feat: option to disable softening completely close #98 --- Packages/SoftMaskForUGUI/Scripts/SoftMask.cs | 2 +- Packages/SoftMaskForUGUI/Shaders/Resources/SoftMask.shader | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Packages/SoftMaskForUGUI/Scripts/SoftMask.cs b/Packages/SoftMaskForUGUI/Scripts/SoftMask.cs index cc3d15e..efb769a 100644 --- a/Packages/SoftMaskForUGUI/Scripts/SoftMask.cs +++ b/Packages/SoftMaskForUGUI/Scripts/SoftMask.cs @@ -72,7 +72,7 @@ public enum DesamplingRate [SerializeField, Tooltip("The desampling rate for soft mask buffer.")] private DesamplingRate m_DesamplingRate = DesamplingRate.x1; - [SerializeField, Range(0.01f, 1), Tooltip("The value used by the soft mask to select the area of influence defined over the soft mask's graphic.")] + [SerializeField, Range(0, 1), Tooltip("The value used by the soft mask to select the area of influence defined over the soft mask's graphic.")] private float m_Softness = 1; [SerializeField, Range(0f, 1f), Tooltip("The transparency of the whole masked graphic.")] diff --git a/Packages/SoftMaskForUGUI/Shaders/Resources/SoftMask.shader b/Packages/SoftMaskForUGUI/Shaders/Resources/SoftMask.shader index f5e7850..42e5de2 100644 --- a/Packages/SoftMaskForUGUI/Shaders/Resources/SoftMask.shader +++ b/Packages/SoftMaskForUGUI/Shaders/Resources/SoftMask.shader @@ -23,7 +23,8 @@ Shader "Hidden/SoftMask" { fixed4 frag (v2f_img i) : SV_Target { - return saturate(tex2D(_MainTex, i.uv).a/_Softness) * _Alpha; + half softness = max(_Softness, 0.0001f); + return saturate(tex2D(_MainTex, i.uv).a/softness) * _Alpha; } ENDCG }