From e053bc6300be842f8d220c1c7f1aad001969870e Mon Sep 17 00:00:00 2001 From: Mane Function Date: Tue, 10 May 2022 18:46:12 +0300 Subject: [PATCH] Applied a workaround to fix a Microsoft HLSL compiler issue https://fogbugz.unity3d.com/default.asp?934464_sjh4cs4ok77ne0cj&_ga=2.124069071.432066521.1640792064-45545210.1640792064 --- Shaders/SoftMask.cginc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Shaders/SoftMask.cginc b/Shaders/SoftMask.cginc index 69facfc..1e8385d 100644 --- a/Shaders/SoftMask.cginc +++ b/Shaders/SoftMask.cginc @@ -7,6 +7,11 @@ float4x4 _GameVP; float4x4 _GameTVP; half4 _MaskInteraction; +float CustomStep(float a, float x) +{ + return x >= a; +} + fixed Approximately(float4x4 a, float4x4 b) { float4x4 d = abs(a - b); @@ -30,16 +35,16 @@ float SoftMaskInternal(float4 clipPos) float4 cpos = mul(_GameTVP, mul(UNITY_MATRIX_M, wpos)); view = lerp(view, cpos.xy / cpos.w * 0.5 + 0.5, isSceneView); #if UNITY_UV_STARTS_AT_TOP - view.y = lerp(view.y, 1 - view.y, step(0, _ProjectionParams.x)); + view.y = lerp(view.y, 1 - view.y, CustomStep(0, _ProjectionParams.x)); #endif #elif UNITY_UV_STARTS_AT_TOP - view.y = lerp(view.y, 1 - view.y, step(0, _ProjectionParams.x)); + view.y = lerp(view.y, 1 - view.y, CustomStep(0, _ProjectionParams.x)); #endif fixed4 mask = tex2D(_SoftMaskTex, view); half4 alpha = saturate(lerp(fixed4(1, 1, 1, 1), lerp(mask, 1 - mask, _MaskInteraction - 1), _MaskInteraction)); #if SOFTMASK_EDITOR - alpha *= step(0, view.x) * step(view.x, 1) * step(0, view.y) * step(view.y, 1); + alpha *= CustomStep(0, view.x) * CustomStep(view.x, 1) * CustomStep(0, view.y) * CustomStep(view.y, 1); #endif return alpha.x * alpha.y * alpha.z * alpha.w; @@ -53,4 +58,4 @@ float SoftMaskInternal(float4 clipPos) #define SoftMask(clipPos, worldPosition) SoftMaskInternal(clipPos) #endif -#endif // UI_SOFTMASK_INCLUDED +#endif // UI_SOFTMASK_INCLUDED \ No newline at end of file