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

Commit 5b946b2

Browse files
committed
Fixes to support versions back to 2017.1
1 parent 4c16597 commit 5b946b2

File tree

5 files changed

+30
-5
lines changed

5 files changed

+30
-5
lines changed

PostProcessing/Runtime/Effects/MotionBlur.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,20 @@ public override DepthTextureMode GetCameraFlags()
6060

6161
private void CreateTemporaryRT(PostProcessRenderContext context, int nameID, int width, int height, RenderTextureFormat RTFormat)
6262
{
63+
var cmd = context.command;
64+
#if UNITY_2017_2_OR_NEWER
6365
var rtDesc = context.GetDescriptor(0, RTFormat, RenderTextureReadWrite.Linear);
6466
rtDesc.width = width;
6567
rtDesc.height = height;
66-
var cmd = context.command;
6768
#if UNITY_2019_1_OR_NEWER
6869
cmd.GetTemporaryRT(nameID, rtDesc, FilterMode.Point);
69-
#else
70+
#elif UNITY_2017_3_OR_NEWER
7071
cmd.GetTemporaryRT(nameID, rtDesc.width, rtDesc.height, rtDesc.depthBufferBits, FilterMode.Point, rtDesc.colorFormat, RenderTextureReadWrite.Linear, rtDesc.msaaSamples, rtDesc.enableRandomWrite, rtDesc.memoryless, context.camera.allowDynamicResolution);
72+
#else
73+
cmd.GetTemporaryRT(nameID, rtDesc.width, rtDesc.height, rtDesc.depthBufferBits, FilterMode.Point, rtDesc.colorFormat, RenderTextureReadWrite.Linear, rtDesc.msaaSamples, rtDesc.enableRandomWrite, rtDesc.memoryless);
74+
#endif
75+
#else
76+
cmd.GetTemporaryRT(nameID, width, height, 0, FilterMode.Point, RTFormat, RenderTextureReadWrite.Linear);
7177
#endif
7278
}
7379

PostProcessing/Runtime/Effects/MultiScaleVO.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,13 @@ Vector3 GetSizeArray(MipLevel mip)
147147
public void GenerateAOMap(CommandBuffer cmd, Camera camera, RenderTargetIdentifier destination, RenderTargetIdentifier? depthMap, bool invert, bool isMSAA)
148148
{
149149
// Base size
150+
#if UNITY_2017_3_OR_NEWER
150151
m_ScaledWidths[0] = camera.scaledPixelWidth * (RuntimeUtilities.isSinglePassStereoEnabled ? 2 : 1);
151152
m_ScaledHeights[0] = camera.scaledPixelHeight;
153+
#else
154+
m_ScaledWidths[0] = camera.pixelWidth * (RuntimeUtilities.isSinglePassStereoEnabled ? 2 : 1);
155+
m_ScaledHeights[0] = camera.pixelHeight;
156+
#endif
152157

153158
// L1 -> L6 sizes
154159
for (int i = 1; i < 7; i++)
@@ -452,8 +457,11 @@ void PreparePropertySheet(PostProcessRenderContext context)
452457

453458
void CheckAOTexture(PostProcessRenderContext context)
454459
{
455-
if (m_AmbientOnlyAO == null || !m_AmbientOnlyAO.IsCreated() || m_AmbientOnlyAO.width != context.width || m_AmbientOnlyAO.height != context.height ||
456-
m_AmbientOnlyAO.useDynamicScale != context.camera.allowDynamicResolution)
460+
bool AOUpdateNeeded = m_AmbientOnlyAO == null || !m_AmbientOnlyAO.IsCreated() || m_AmbientOnlyAO.width != context.width || m_AmbientOnlyAO.height != context.height;
461+
#if UNITY_2017_3_OR_NEWER
462+
AOUpdateNeeded = AOUpdateNeeded || m_AmbientOnlyAO.useDynamicScale != context.camera.allowDynamicResolution;
463+
#endif
464+
if (AOUpdateNeeded)
457465
{
458466
RuntimeUtilities.Destroy(m_AmbientOnlyAO);
459467

@@ -462,7 +470,9 @@ void CheckAOTexture(PostProcessRenderContext context)
462470
hideFlags = HideFlags.DontSave,
463471
filterMode = FilterMode.Point,
464472
enableRandomWrite = true,
473+
#if UNITY_2017_3_OR_NEWER
465474
useDynamicScale = context.camera.allowDynamicResolution
475+
#endif
466476
};
467477
m_AmbientOnlyAO.Create();
468478
}

PostProcessing/Runtime/Effects/SubpixelMorphologicalAntialiasing.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,13 @@ internal void Render(PostProcessRenderContext context)
6363
var cmd = context.command;
6464
cmd.BeginSample("SubpixelMorphologicalAntialiasing");
6565

66+
#if UNITY_2017_3_OR_NEWER
6667
cmd.GetTemporaryRT(ShaderIDs.SMAA_Flip, context.width, context.height, 0, FilterMode.Bilinear, context.sourceFormat, RenderTextureReadWrite.Linear, 1, false, RenderTextureMemoryless.None, context.camera.allowDynamicResolution);
6768
cmd.GetTemporaryRT(ShaderIDs.SMAA_Flop, context.width, context.height, 0, FilterMode.Bilinear, context.sourceFormat, RenderTextureReadWrite.Linear, 1, false, RenderTextureMemoryless.None, context.camera.allowDynamicResolution);
69+
#else
70+
cmd.GetTemporaryRT(ShaderIDs.SMAA_Flip, context.width, context.height, 0, FilterMode.Bilinear, context.sourceFormat, RenderTextureReadWrite.Linear, 1, false);
71+
cmd.GetTemporaryRT(ShaderIDs.SMAA_Flop, context.width, context.height, 0, FilterMode.Bilinear, context.sourceFormat, RenderTextureReadWrite.Linear, 1, false);
72+
#endif
6873

6974
cmd.BlitFullscreenTriangle(context.source, ShaderIDs.SMAA_Flip, sheet, (int)Pass.EdgeDetection + (int)quality, true);
7075
cmd.BlitFullscreenTriangle(ShaderIDs.SMAA_Flip, ShaderIDs.SMAA_Flop, sheet, (int)Pass.BlendWeights + (int)quality);

PostProcessing/Runtime/PostProcessLayer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,12 @@ void InitLegacy()
237237
m_CurrentContext = new PostProcessRenderContext();
238238
}
239239

240+
#if UNITY_2019_1_OR_NEWER
240241
bool DynamicResolutionAllowsFinalBlitToCameraTarget()
241242
{
242243
return (!m_Camera.allowDynamicResolution || (ScalableBufferManager.heightScaleFactor == 1.0 && ScalableBufferManager.widthScaleFactor == 1.0));
243244
}
245+
#endif
244246

245247
#if UNITY_2019_1_OR_NEWER
246248
// We always use a CommandBuffer to blit to the final render target

PostProcessing/Runtime/PostProcessRenderContext.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,10 @@ public void GetScreenSpaceTemporaryRT(CommandBuffer cmd, int nameID,
395395

396396
#if UNITY_2019_1_OR_NEWER
397397
cmd.GetTemporaryRT(nameID, desc, filter);
398-
#else
398+
#elif UNITY_2017_3_OR_NEWER
399399
cmd.GetTemporaryRT(nameID, desc.width, desc.height, desc.depthBufferBits, filter, desc.colorFormat, readWrite, desc.msaaSamples, desc.enableRandomWrite, desc.memoryless, m_Camera.allowDynamicResolution);
400+
#else
401+
cmd.GetTemporaryRT(nameID, desc.width, desc.height, desc.depthBufferBits, filter, desc.colorFormat, readWrite, desc.msaaSamples, desc.enableRandomWrite, desc.memoryless);
400402
#endif
401403
#else
402404
int actualWidth = width;

0 commit comments

Comments
 (0)