Mane Function 2022-05-10 18:46:12 +03:00 committed by mob-sakai
parent f59d147fe0
commit 50c41f29cc
1 changed files with 9 additions and 4 deletions

View File

@ -7,6 +7,11 @@ float4x4 _GameVP;
float4x4 _GameTVP; float4x4 _GameTVP;
half4 _MaskInteraction; half4 _MaskInteraction;
float CustomStep(float a, float x)
{
return x >= a;
}
fixed Approximately(float4x4 a, float4x4 b) fixed Approximately(float4x4 a, float4x4 b)
{ {
float4x4 d = abs(a - b); float4x4 d = abs(a - b);
@ -30,16 +35,16 @@ float SoftMaskInternal(float4 clipPos)
float4 cpos = mul(_GameTVP, mul(UNITY_MATRIX_M, wpos)); float4 cpos = mul(_GameTVP, mul(UNITY_MATRIX_M, wpos));
view = lerp(view, cpos.xy / cpos.w * 0.5 + 0.5, isSceneView); view = lerp(view, cpos.xy / cpos.w * 0.5 + 0.5, isSceneView);
#if UNITY_UV_STARTS_AT_TOP #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 #endif
#elif UNITY_UV_STARTS_AT_TOP #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 #endif
fixed4 mask = tex2D(_SoftMaskTex, view); fixed4 mask = tex2D(_SoftMaskTex, view);
half4 alpha = saturate(lerp(fixed4(1, 1, 1, 1), lerp(mask, 1 - mask, _MaskInteraction - 1), _MaskInteraction)); half4 alpha = saturate(lerp(fixed4(1, 1, 1, 1), lerp(mask, 1 - mask, _MaskInteraction - 1), _MaskInteraction));
#if SOFTMASK_EDITOR #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 #endif
return alpha.x * alpha.y * alpha.z * alpha.w; return alpha.x * alpha.y * alpha.z * alpha.w;