+- **Exclude from Temporal Upscaling and Anti Aliasing** |
+
+
+Indicates whether the render pipeline excludes this surface from any temporal upscalers (TU) and temporal anti-aliasing (AA). This is useful when the surface looks blurry when TAA or any Temporal Upscaler is enabled and especially useful for animated textures (such as video player in a surface).
+This setting only works for Transparent surfaces due to the fact that there are no more stencil bits open.
+
+ |
+
diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDMetadata.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDMetadata.cs
index 4b7f806f99a..ca58840e38f 100644
--- a/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDMetadata.cs
+++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDMetadata.cs
@@ -26,6 +26,9 @@ sealed class HDMetadata : ScriptableObject
[SerializeField]
bool m_HasVertexModificationInMotionVector;
+ [SerializeField]
+ bool m_IsVFXCompatible;
+
public ShaderID shaderID
{
get => m_ShaderID;
@@ -67,5 +70,11 @@ public bool hasVertexModificationInMotionVector
get => m_HasVertexModificationInMotionVector;
set => m_HasVertexModificationInMotionVector = value;
}
+
+ public bool isVFXCompatible
+ {
+ get => m_IsVFXCompatible;
+ set => m_IsVFXCompatible = value;
+ }
}
}
diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubShaderUtilities.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubShaderUtilities.cs
index 321dd410069..80520d3512d 100644
--- a/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubShaderUtilities.cs
+++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubShaderUtilities.cs
@@ -119,11 +119,24 @@ public static void AddStencilShaderProperties(PropertyCollector collector, Syste
collector.AddToggleProperty(kEnableBlendModePreserveSpecularLighting, false, HLSLDeclaration.UnityPerMaterial);
}
+ bool excludeFromTUAndAA = systemData?.excludeFromTUAndAA ?? false;
+ collector.AddToggleProperty(kExcludeFromTUAndAA, excludeFromTUAndAA);
+
// Configure render state
- BaseLitAPI.ComputeStencilProperties(receivesLighting, forwardOnly, ssrStencil, splitLighting, out int stencilRef, out int stencilWriteMask,
- out int stencilRefDepth, out int stencilWriteMaskDepth, out int stencilRefGBuffer, out int stencilWriteMaskGBuffer,
- out int stencilRefMV, out int stencilWriteMaskMV
- );
+ BaseLitAPI.ComputeStencilProperties(
+ receivesLighting,
+ forwardOnly,
+ ssrStencil,
+ splitLighting,
+ excludeFromTUAndAA,
+ out int stencilRef,
+ out int stencilWriteMask,
+ out int stencilRefDepth,
+ out int stencilWriteMaskDepth,
+ out int stencilRefGBuffer,
+ out int stencilWriteMaskGBuffer,
+ out int stencilRefMV,
+ out int stencilWriteMaskMV);
// All these properties values will be patched with the material keyword update
collector.AddIntProperty("_StencilRef", stencilRef);
diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubTarget.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubTarget.cs
index 52c2f70121c..df7b046c5c0 100644
--- a/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubTarget.cs
+++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubTarget.cs
@@ -77,6 +77,7 @@ public virtual ScriptableObject GetMetadataObject(GraphDataReadOnly graph)
hdMetadata.migrateFromOldCrossPipelineSG = m_MigrateFromOldCrossPipelineSG;
hdMetadata.hdSubTargetVersion = systemData.version;
hdMetadata.hasVertexModificationInMotionVector = systemData.customVelocity || systemData.tessellation || graph.AnyVertexAnimationActive();
+ hdMetadata.isVFXCompatible = graph.IsVFXCompatible();
return hdMetadata;
}
diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceOptionPropertyBlock.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceOptionPropertyBlock.cs
index 4cced457955..0db4ecc3fe4 100644
--- a/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceOptionPropertyBlock.cs
+++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceOptionPropertyBlock.cs
@@ -128,6 +128,7 @@ protected override void CreatePropertyGUI()
}
AddProperty(customVelocityText, () => systemData.customVelocity, (newValue) => systemData.customVelocity = newValue);
+ AddProperty(excludeFromTUAndAAText, () => systemData.excludeFromTUAndAA, (newValue) => systemData.excludeFromTUAndAA = newValue);
AddProperty(tessellationEnableText, () => systemData.tessellation, (newValue) => systemData.tessellation = newValue);
if (systemData.tessellation)
diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/TargetData/SystemData.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/TargetData/SystemData.cs
index 49d585bc2d8..29515619e31 100644
--- a/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/TargetData/SystemData.cs
+++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/TargetData/SystemData.cs
@@ -90,6 +90,14 @@ public bool alphaTest
set => m_AlphaTest = value;
}
+ [SerializeField]
+ bool m_ExcludeFromTUAndAA = false;
+ public bool excludeFromTUAndAA
+ {
+ get => m_ExcludeFromTUAndAA;
+ set => m_ExcludeFromTUAndAA = value;
+ }
+
[SerializeField, Obsolete("Keep for migration")]
internal bool m_TransparentDepthPrepass;
diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/SurfaceOptionUIBlock.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/SurfaceOptionUIBlock.cs
index 50167de4928..627481cf58a 100644
--- a/Packages/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/SurfaceOptionUIBlock.cs
+++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/SurfaceOptionUIBlock.cs
@@ -135,6 +135,8 @@ internal static class Styles
public static GUIContent specularAAScreenSpaceVarianceText = new GUIContent("Screen space variance", "Controls the strength of the Specular AA reduction. Higher values give a more blurry result and less aliasing.");
public static GUIContent specularAAThresholdText = new GUIContent("Threshold", "Controls the effect of Specular AA reduction. A values of 0 does not apply reduction, higher values allow higher reduction.");
+ public static GUIContent excludeFromTUAndAAText = new GUIContent("Exclude From Temporal Upscalers and Anti Aliasing", "When enabled, the current material wont be temporaly sampled during TAA and will have reduced ghosting on upscalers.");
+
// SSR
public static GUIContent receivesSSRText = new GUIContent("Receive SSR", "When enabled, this Material can receive screen space reflections.");
public static GUIContent receivesSSRTransparentText = new GUIContent("Receive SSR Transparent", "When enabled, this Material can receive screen space reflections. This will force a transparent depth prepass on the object if HDRP supports it.");
@@ -182,6 +184,7 @@ enum DisplacementModeLitTessellation { None = DisplacementMode.None, Tessellatio
MaterialProperty specularAAThreshold = null;
const string kSpecularAAThreshold = "_SpecularAAThreshold";
MaterialProperty transmissionEnable = null;
+ MaterialProperty excludeFromTUAndAA = null;
// Per pixel displacement params
MaterialProperty ppdMinSamples = null;
@@ -311,6 +314,7 @@ public override void LoadMaterialProperties()
blendMode = FindProperty(kBlendMode);
transmissionEnable = FindProperty(kTransmissionEnable);
+ excludeFromTUAndAA = FindProperty(kExcludeFromTUAndAA);
if ((m_Features & Features.DoubleSidedNormalMode) != 0)
{
@@ -768,6 +772,9 @@ protected void DrawLitSurfaceOptions()
materialEditor.ShaderProperty(receivesSSR, Styles.receivesSSRText);
}
+ if (excludeFromTUAndAA != null && BaseLitAPI.CompatibleWithExcludeFromTUAndAA(surfaceTypeValue, renderQueue))
+ materialEditor.ShaderProperty(excludeFromTUAndAA, Styles.excludeFromTUAndAAText);
+
if (enableGeometricSpecularAA != null)
{
materialEditor.ShaderProperty(enableGeometricSpecularAA, Styles.enableGeometricSpecularAAText);
diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Material/Water/ShaderGraph/WaterSubTarget.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Material/Water/ShaderGraph/WaterSubTarget.cs
index 28457802702..8a5fcde5cf9 100644
--- a/Packages/com.unity.render-pipelines.high-definition/Editor/Material/Water/ShaderGraph/WaterSubTarget.cs
+++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Material/Water/ShaderGraph/WaterSubTarget.cs
@@ -420,7 +420,7 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera
stencilRefWaterVar.displayName = "Stencil Water Ref GBuffer";
stencilRefWaterVar.hidden = true;
stencilRefWaterVar.floatType = FloatType.Default;
- stencilRefWaterVar.value = (int)StencilUsage.WaterSurface;
+ stencilRefWaterVar.value = (int)(StencilUsage.WaterSurface | StencilUsage.ExcludeFromTUAndAA);
stencilRefWaterVar.overrideHLSLDeclaration = true;
stencilRefWaterVar.hlslDeclarationOverride = HLSLDeclaration.Global;
stencilRefWaterVar.generatePropertyBlock = false;
@@ -431,7 +431,7 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera
stencilWriteMaskWaterVar.displayName = "Stencil Water Write Mask GBuffer";
stencilWriteMaskWaterVar.hidden = true;
stencilWriteMaskWaterVar.floatType = FloatType.Default;
- stencilWriteMaskWaterVar.value = (int)StencilUsage.WaterSurface;
+ stencilWriteMaskWaterVar.value = (int)(StencilUsage.WaterSurface | StencilUsage.ExcludeFromTUAndAA);
stencilWriteMaskWaterVar.overrideHLSLDeclaration = true;
stencilWriteMaskWaterVar.hlslDeclarationOverride = HLSLDeclaration.Global;
stencilWriteMaskWaterVar.generatePropertyBlock = false;
diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/VFXGraph/Outputs/VFXAbstractDistortionOutput.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/VFXGraph/Outputs/VFXAbstractDistortionOutput.cs
index 8a67834da89..22e9b33607d 100644
--- a/Packages/com.unity.render-pipelines.high-definition/Editor/VFXGraph/Outputs/VFXAbstractDistortionOutput.cs
+++ b/Packages/com.unity.render-pipelines.high-definition/Editor/VFXGraph/Outputs/VFXAbstractDistortionOutput.cs
@@ -41,7 +41,7 @@ protected override IEnumerable