From b130613654d974d21724ad01f2615e1ce6447a7a Mon Sep 17 00:00:00 2001 From: ArthurD Date: Thu, 16 Mar 2023 18:37:41 -0700 Subject: [PATCH] Adds support to allow the 'rounded corners' image to BE a mask itself, so that a mask itself can be rounded (via the mask's source image). --- UiRoundedCorners/IndependentRoundedCorners.shader | 5 +++++ UiRoundedCorners/RoundedCorners.shader | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/UiRoundedCorners/IndependentRoundedCorners.shader b/UiRoundedCorners/IndependentRoundedCorners.shader index 2db567d..0884cd2 100644 --- a/UiRoundedCorners/IndependentRoundedCorners.shader +++ b/UiRoundedCorners/IndependentRoundedCorners.shader @@ -78,6 +78,11 @@ } float alpha = CalcAlphaForIndependentCorners(i.uv, _halfSize.xy, _rect2props, _r); + + #ifdef UNITY_UI_ALPHACLIP + clip(alpha - 0.001); + #endif + return mixAlpha(tex2D(_MainTex, i.uv), i.color, alpha); } diff --git a/UiRoundedCorners/RoundedCorners.shader b/UiRoundedCorners/RoundedCorners.shader index 7a0ff1b..3465c68 100644 --- a/UiRoundedCorners/RoundedCorners.shader +++ b/UiRoundedCorners/RoundedCorners.shader @@ -74,6 +74,11 @@ Shader "UI/RoundedCorners/RoundedCorners" { } float alpha = CalcAlpha(i.uv, _WidthHeightRadius.xy, _WidthHeightRadius.z); + + #ifdef UNITY_UI_ALPHACLIP + clip(alpha - 0.001); + #endif + return mixAlpha(tex2D(_MainTex, i.uv), i.color, alpha); }