Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit 26979e4

Browse files
committed
No need to kill NaNs if the source is not a floating point format
1 parent f69425a commit 26979e4

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

PostProcessing/Runtime/PostProcessLayer.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,10 @@ void OnPreRender()
309309
void BuildCommandBuffers()
310310
{
311311
var context = m_CurrentContext;
312-
var sourceFormat = m_Camera.allowHDR ? RuntimeUtilities.defaultHDRRenderTextureFormat : RenderTextureFormat.Default;
312+
var sourceFormat = m_Camera.allowHDR ? RuntimeUtilities.defaultHDRRenderTextureFormat : RenderTextureFormat.Default;
313+
314+
if (!RuntimeUtilities.isFloatingPointFormat(sourceFormat))
315+
m_NaNKilled = true;
313316

314317
context.Reset();
315318
context.camera = m_Camera;
@@ -425,7 +428,8 @@ void BuildCommandBuffers()
425428
int tempRt = m_TargetPool.Get();
426429
context.GetScreenSpaceTemporaryRT(m_LegacyCmdBuffer, tempRt, 0, sourceFormat, RenderTextureReadWrite.sRGB);
427430
m_LegacyCmdBuffer.Blit(cameraTarget, tempRt, RuntimeUtilities.copyStdMaterial, stopNaNPropagation ? 1 : 0);
428-
m_NaNKilled = stopNaNPropagation;
431+
if (!m_NaNKilled)
432+
m_NaNKilled = stopNaNPropagation;
429433

430434
context.command = m_LegacyCmdBuffer;
431435
context.source = tempRt;

PostProcessing/Runtime/Utils/RuntimeUtilities.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,14 @@ public static RenderTextureFormat defaultHDRRenderTextureFormat
305305
}
306306
}
307307

308+
public static bool isFloatingPointFormat(RenderTextureFormat format)
309+
{
310+
return format == RenderTextureFormat.DefaultHDR || format == RenderTextureFormat.ARGBHalf || format == RenderTextureFormat.ARGBFloat ||
311+
format == RenderTextureFormat.RGFloat || format == RenderTextureFormat.RGHalf ||
312+
format == RenderTextureFormat.RFloat || format == RenderTextureFormat.RHalf ||
313+
format == RenderTextureFormat.RGB111110Float;
314+
}
315+
308316
public static void Destroy(UnityObject obj)
309317
{
310318
if (obj != null)

0 commit comments

Comments
 (0)