parent
b0edc97d46
commit
91b77885bc
|
@ -55,6 +55,8 @@ namespace Coffee.UISoftMask
|
||||||
private static int s_GameVPId;
|
private static int s_GameVPId;
|
||||||
private static int s_GameTVPId;
|
private static int s_GameTVPId;
|
||||||
private static int s_Alpha;
|
private static int s_Alpha;
|
||||||
|
private static int s_PreviousWidth;
|
||||||
|
private static int s_PreviousHeight;
|
||||||
private MaterialPropertyBlock _mpb;
|
private MaterialPropertyBlock _mpb;
|
||||||
private CommandBuffer _cb;
|
private CommandBuffer _cb;
|
||||||
private Material _material;
|
private Material _material;
|
||||||
|
@ -544,6 +546,16 @@ namespace Coffee.UISoftMask
|
||||||
Profiler.EndSample();
|
Profiler.EndSample();
|
||||||
|
|
||||||
Profiler.EndSample();
|
Profiler.EndSample();
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
var w = s_PreviousWidth;
|
||||||
|
var h = s_PreviousHeight;
|
||||||
|
GetDesamplingSize(DesamplingRate.None, out s_PreviousWidth, out s_PreviousHeight);
|
||||||
|
if (w != s_PreviousWidth || h != s_PreviousHeight)
|
||||||
|
{
|
||||||
|
Canvas.ForceUpdateCanvases();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -7,6 +7,17 @@ float4x4 _GameVP;
|
||||||
float4x4 _GameTVP;
|
float4x4 _GameTVP;
|
||||||
half4 _MaskInteraction;
|
half4 _MaskInteraction;
|
||||||
|
|
||||||
|
fixed Approximately(float4x4 a, float4x4 b)
|
||||||
|
{
|
||||||
|
float4x4 d = abs(a - b);
|
||||||
|
return step(
|
||||||
|
max(d._m00,max(d._m01,max(d._m02,max(d._m03,
|
||||||
|
max(d._m10,max(d._m11,max(d._m12,max(d._m13,
|
||||||
|
max(d._m20,max(d._m21,max(d._m22,max(d._m23,
|
||||||
|
max(d._m30,max(d._m31,max(d._m32,d._m33))))))))))))))),
|
||||||
|
0.5);
|
||||||
|
}
|
||||||
|
|
||||||
#if SOFTMASK_EDITOR
|
#if SOFTMASK_EDITOR
|
||||||
float SoftMaskInternal(float4 clipPos, float4 wpos)
|
float SoftMaskInternal(float4 clipPos, float4 wpos)
|
||||||
#else
|
#else
|
||||||
|
@ -15,7 +26,7 @@ float SoftMaskInternal(float4 clipPos)
|
||||||
{
|
{
|
||||||
half2 view = clipPos.xy/_ScreenParams.xy;
|
half2 view = clipPos.xy/_ScreenParams.xy;
|
||||||
#if SOFTMASK_EDITOR
|
#if SOFTMASK_EDITOR
|
||||||
fixed isSceneView = any(UNITY_MATRIX_VP - _GameVP);
|
fixed isSceneView = 1 - Approximately(UNITY_MATRIX_VP, _GameVP);
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue