Skip to content

Commit 825cbc2

Browse files
committed
added warning for mobiles (should be for platforms that actually have load/store actions but we dont expose it for now) when using Postprocessing layer on camera with non-fullscreen viewport, as we are tweaking load/store actions freely, expecting that we render to fullscreen
1 parent 208f63d commit 825cbc2

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

PostProcessing/Runtime/PostProcessLayer.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,11 +383,26 @@ void OnPreCull()
383383
if (m_Camera == null || m_CurrentContext == null)
384384
InitLegacy();
385385

386+
// Postprocessing does tweak load/store actions when it uses render targets.
387+
// But when using builtin render pipeline, Camera will silently apply viewport when setting render target,
388+
// meaning that Postprocessing might think that it is rendering to fullscreen RT
389+
// and use LoadAction.DontCare freely, which will ruin the RT if we are using viewport.
390+
// It should actually check for having tiled architecture but this is not exposed to script,
391+
// so we are checking for mobile as a good substitute
392+
if(Application.isMobilePlatform)
393+
{
394+
Rect r = m_Camera.rect;
395+
if(Mathf.Abs(r.x) > 1e-6f || Mathf.Abs(r.y) > 1e-6f || Mathf.Abs(1.0f - r.width) > 1e-6f || Mathf.Abs(1.0f - r.height) > 1e-6f)
396+
{
397+
Debug.LogWarning("When used with builtin render pipeline, Postprocessing package expects to be used on a fullscreen Camera.\nPlease note that using Camera viewport may result in visual artefacts or some things not working.", m_Camera);
398+
}
399+
}
400+
386401
// Resets the projection matrix from previous frame in case TAA was enabled.
387402
// We also need to force reset the non-jittered projection matrix here as it's not done
388403
// when ResetProjectionMatrix() is called and will break transparent rendering if TAA
389404
// is switched off and the FOV or any other camera property changes.
390-
405+
391406
#if UNITY_2018_2_OR_NEWER
392407
if (!m_Camera.usePhysicalProperties)
393408
#endif

0 commit comments

Comments
 (0)