fix #41; Doesn't work with Screen-Space Overlay
parent
a89aad0f88
commit
bd6f85965e
|
@ -467,7 +467,7 @@ namespace Coffee.UIExtensions
|
|||
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
|
||||
{
|
||||
|
|
|
@ -215,10 +215,11 @@ namespace Coffee.UIExtensions
|
|||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue