Skip to content

Commit 24e911c

Browse files
author
Pierre GAC
committed
Added more pull requests
1 parent 501a84a commit 24e911c

File tree

4 files changed

+322
-290
lines changed

4 files changed

+322
-290
lines changed

PostProcessing/Runtime/Effects/ScreenSpaceReflections.cs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,19 @@ public sealed class ScreenSpaceReflections : PostProcessEffectSettings
9797
[Range(0f, 1f), Tooltip("Fades reflections close to the screen edges.")]
9898
public FloatParameter vignette = new FloatParameter { value = 0.5f };
9999

100+
/// <summary>
101+
/// Enables the use of motion vectors to slightly improve visual quality.
102+
/// </summary>
103+
[Tooltip("Enables the use of motion vectors to slightly improve visual quality.")]
104+
public BoolParameter useMotionVectors = new BoolParameter { value = false };
105+
106+
100107
/// <inheritdoc />
101108
public override bool IsEnabledAndSupported(PostProcessRenderContext context)
102109
{
103110
return enabled
104111
&& context.camera.actualRenderingPath == RenderingPath.DeferredShading
105-
&& SystemInfo.supportsMotionVectors
112+
&& (!useMotionVectors || SystemInfo.supportsMotionVectors)
106113
&& SystemInfo.supportsComputeShaders
107114
&& SystemInfo.copyTextureSupport > CopyTextureSupport.None
108115
&& context.resources.shaders.screenSpaceReflections
@@ -148,7 +155,14 @@ enum Pass
148155

149156
public override DepthTextureMode GetCameraFlags()
150157
{
151-
return DepthTextureMode.Depth | DepthTextureMode.MotionVectors;
158+
if (settings.useMotionVectors.value)
159+
{
160+
return DepthTextureMode.Depth | DepthTextureMode.MotionVectors;
161+
}
162+
else
163+
{
164+
return DepthTextureMode.Depth;
165+
}
152166
}
153167

154168
internal void CheckRT(ref RenderTexture rt, int width, int height, FilterMode filterMode, bool useMipMap)
@@ -207,6 +221,16 @@ public override void Render(PostProcessRenderContext context)
207221

208222
var noiseTex = context.resources.blueNoise256[0];
209223
var sheet = context.propertySheets.Get(context.resources.shaders.screenSpaceReflections);
224+
225+
if (settings.useMotionVectors.value)
226+
{
227+
sheet.EnableKeyword("_UseMotionVectors");
228+
}
229+
else
230+
{
231+
sheet.DisableKeyword("_UseMotionVectors");
232+
}
233+
210234
sheet.properties.SetTexture(ShaderIDs.Noise, noiseTex);
211235

212236
var screenSpaceProjectionMatrix = new Matrix4x4();

PostProcessing/Runtime/PostProcessLayer.cs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ public enum Antialiasing
120120
[SerializeField]
121121
PostProcessResources m_Resources;
122122

123-
// Some juggling needed to track down reference to the resource asset when loaded from asset
124-
// bundle (guid conflict)
125-
PostProcessResources m_OldResources;
126-
127123
// UI states
128124
#if UNITY_2017_1_OR_NEWER
129125
[UnityEngine.Scripting.Preserve]
@@ -425,13 +421,10 @@ void OnPreCull()
425421
// when ResetProjectionMatrix() is called and will break transparent rendering if TAA
426422
// is switched off and the FOV or any other camera property changes.
427423

428-
if (m_CurrentContext.IsTemporalAntialiasingActive())
429-
{
430424
#if UNITY_2018_2_OR_NEWER
431425
if (!m_Camera.usePhysicalProperties)
432426
#endif
433427
m_Camera.ResetProjectionMatrix();
434-
}
435428
m_Camera.nonJitteredProjectionMatrix = m_Camera.projectionMatrix;
436429

437430
#if ENABLE_VR
@@ -605,7 +598,15 @@ void BuildCommandBuffers()
605598
if (RequiresInitialBlit(m_Camera, context) || forceNanKillPass)
606599
{
607600
tempRt = m_TargetPool.Get();
608-
context.GetScreenSpaceTemporaryRT(m_LegacyCmdBuffer, tempRt, 0, sourceFormat, RenderTextureReadWrite.sRGB);
601+
// https://github.com/Unity-Technologies/PostProcessing/issues/844
602+
if (!context.stereoActive)
603+
{
604+
context.GetScreenSpaceTemporaryRT(m_LegacyCmdBuffer, tempRt, 0, sourceFormat, RenderTextureReadWrite.sRGB);
605+
}
606+
else
607+
{
608+
context.GetScreenSpaceTemporaryRT(m_LegacyCmdBuffer, tempRt, 0, sourceFormat, RenderTextureReadWrite.sRGB, FilterMode.Bilinear, context.width * 2, context.height);
609+
}
609610
m_LegacyCmdBuffer.BuiltinBlit(cameraTarget, tempRt, RuntimeUtilities.copyStdMaterial, stopNaNPropagation ? 1 : 0);
610611
if (!m_NaNKilled)
611612
m_NaNKilled = stopNaNPropagation;
@@ -811,13 +812,7 @@ public bool HasActiveEffects(PostProcessEvent evt, PostProcessRenderContext cont
811812

812813
void SetupContext(PostProcessRenderContext context)
813814
{
814-
// Juggling required when a scene with post processing is loaded from an asset bundle
815-
// See #1148230
816-
if (m_OldResources != m_Resources)
817-
{
818-
RuntimeUtilities.UpdateResources(m_Resources);
819-
m_OldResources = m_Resources;
820-
}
815+
RuntimeUtilities.UpdateResources(m_Resources);
821816

822817
m_IsRenderingInSceneView = context.camera.cameraType == CameraType.SceneView;
823818
context.isSceneView = m_IsRenderingInSceneView;

0 commit comments

Comments
 (0)