diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMask.cs b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMask.cs index f67c37c..4e79616 100644 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMask.cs +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMask.cs @@ -467,7 +467,7 @@ void UpdateMaskTexture() var cam = c.worldCamera ?? Camera.main; if (c && c.renderMode != RenderMode.ScreenSpaceOverlay && cam) { - _cb.SetViewProjectionMatrices(cam.worldToCameraMatrix, cam.projectionMatrix); + _cb.SetViewProjectionMatrices(cam.worldToCameraMatrix, GL.GetGPUProjectionMatrix(cam.projectionMatrix, true)); } else { diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMaskable.cs b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMaskable.cs index d709b1e..05bfc8a 100644 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMaskable.cs +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMaskable.cs @@ -215,10 +215,11 @@ static void UpdateSceneViewMatrixForShader() } else { + var scale = c.transform.localScale.x; + var size = (c.transform as RectTransform).sizeDelta; var pos = c.transform.localPosition; - var pv = Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, new Vector3(1 / pos.x, 1 / pos.y, -2 / 2000f)); - mat.SetMatrix(s_GameVPId, pv); - mat.SetMatrix(s_GameTVPId, pv * Matrix4x4.Translate(-pos)); + mat.SetMatrix(s_GameVPId, Matrix4x4.TRS(new Vector3(0, 0, 0.5f), Quaternion.identity, new Vector3(2 / size.x, 2 / size.y, 0.0005f * scale))); + mat.SetMatrix(s_GameTVPId, Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, new Vector3(1 / pos.x, 1 / pos.y, -2/2000f)) * Matrix4x4.Translate(-pos)); } } } diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/SoftMask.cginc b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/SoftMask.cginc index 5e98c61..0928e15 100644 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/SoftMask.cginc +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/SoftMask.cginc @@ -36,9 +36,10 @@ float SoftMaskInternal(float4 clipPos) fixed isSceneView = 1 - Approximately(UNITY_MATRIX_VP, _GameVP); float4 cpos = mul(_GameTVP, mul(UNITY_MATRIX_M, wpos)); view = lerp(view, cpos.xy / cpos.w * 0.5 + 0.5, isSceneView); - #endif - - #if UNITY_UV_STARTS_AT_TOP && !defined(SHADER_API_D3D11) && !defined(SHADER_API_D3D11_9X) && !defined(SHADER_API_D3D9) + #if UNITY_UV_STARTS_AT_TOP + view.y = lerp(view.y, 1 - view.y, step(0, _ProjectionParams.x)); + #endif + #elif UNITY_UV_STARTS_AT_TOP view.y = 1.0 - view.y; #endif