diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5007_PathTracing_Materials_SG_Lit.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5007_PathTracing_Materials_SG_Lit.png
index 3ab8e3d69dc..2f222184692 100644
--- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5007_PathTracing_Materials_SG_Lit.png
+++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5007_PathTracing_Materials_SG_Lit.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:c5b765dace74f6bdd1005f95800e3f7680f3c8c3b6f50936da14f2c5d41f146d
-size 509269
+oid sha256:111ddeed9399678e4d5816f4a49ff792d79b121b9e6abe7f17e47c37e3e8c0d1
+size 512669
diff --git a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs
index 0d05b85aff6..6cd96a853f2 100644
--- a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs
+++ b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs
@@ -54,7 +54,6 @@ class RenderGraphDebugParams
public bool tagResourceNamesWithRG;
public bool clearRenderTargetsAtCreation;
public bool clearRenderTargetsAtRelease;
- public bool unbindGlobalTextures;
public bool logFrameInformation;
public bool logResources;
@@ -64,7 +63,6 @@ public void RegisterDebug()
list.Add(new DebugUI.BoolField { displayName = "Tag Resources with RG", getter = () => tagResourceNamesWithRG, setter = value => tagResourceNamesWithRG = value });
list.Add(new DebugUI.BoolField { displayName = "Clear Render Targets at creation", getter = () => clearRenderTargetsAtCreation, setter = value => clearRenderTargetsAtCreation = value });
list.Add(new DebugUI.BoolField { displayName = "Clear Render Targets at release", getter = () => clearRenderTargetsAtRelease, setter = value => clearRenderTargetsAtRelease = value });
- list.Add(new DebugUI.BoolField { displayName = "Unbind Global Textures", getter = () => unbindGlobalTextures, setter = value => unbindGlobalTextures = value });
list.Add(new DebugUI.Button { displayName = "Log Frame Information", action = () => logFrameInformation = true });
list.Add(new DebugUI.Button { displayName = "Log Resources", action = () => logResources = true });
@@ -267,11 +265,10 @@ public void PurgeUnusedResources()
/// Any pass writing to an imported texture will be considered having side effects and can't be automatically pruned.
///
/// External RTHandle that needs to be imported.
- /// Optional property that allows you to specify a Shader property name to use for automatic resource binding.
/// A new TextureHandle.
- public TextureHandle ImportTexture(RTHandle rt, int shaderProperty = 0)
+ public TextureHandle ImportTexture(RTHandle rt)
{
- return m_Resources.ImportTexture(rt, shaderProperty);
+ return m_Resources.ImportTexture(rt);
}
///
@@ -288,22 +285,20 @@ public TextureHandle ImportBackbuffer(RenderTargetIdentifier rt)
/// Create a new Render Graph Texture resource.
///
/// Texture descriptor.
- /// Optional property that allows you to specify a Shader property name to use for automatic resource binding.
/// A new TextureHandle.
- public TextureHandle CreateTexture(in TextureDesc desc, int shaderProperty = 0)
+ public TextureHandle CreateTexture(in TextureDesc desc)
{
- return m_Resources.CreateTexture(desc, shaderProperty);
+ return m_Resources.CreateTexture(desc);
}
///
/// Create a new Render Graph Texture resource using the descriptor from another texture.
///
/// Texture from which the descriptor should be used.
- /// Optional property that allows you to specify a Shader property name to use for automatic resource binding.
/// A new TextureHandle.
- public TextureHandle CreateTexture(TextureHandle texture, int shaderProperty = 0)
+ public TextureHandle CreateTexture(TextureHandle texture)
{
- return m_Resources.CreateTexture(m_Resources.GetTextureResourceDesc(texture.handle), shaderProperty);
+ return m_Resources.CreateTexture(m_Resources.GetTextureResourceDesc(texture.handle));
}
///
@@ -899,10 +894,6 @@ void PreRenderPassExecute(in CompiledPassInfo passInfo, RenderGraphContext rgCon
// TODO RENDERGRAPH merge clear and setup here if possible
RenderGraphPass pass = passInfo.pass;
- // TODO RENDERGRAPH remove this when we do away with auto global texture setup
- // (can't put it in the profiling scope otherwise it might be executed on compute queue which is not possible for global sets)
- m_Resources.PreRenderPassSetGlobalTextures(rgContext, pass.resourceReadLists[(int)RenderGraphResourceType.Texture]);
-
foreach (var texture in passInfo.resourceCreateList[(int)RenderGraphResourceType.Texture])
m_Resources.CreateAndClearTexture(rgContext, texture);
@@ -944,9 +935,6 @@ void PostRenderPassExecute(CommandBuffer mainCmd, ref CompiledPassInfo passInfo,
rgContext.cmd = mainCmd; // Restore the main command buffer.
}
- if (m_DebugParameters.unbindGlobalTextures)
- m_Resources.PostRenderPassUnbindGlobalTextures(rgContext, pass.resourceReadLists[(int)RenderGraphResourceType.Texture]);
-
m_RenderGraphPool.ReleaseAllTempAlloc();
foreach (var texture in passInfo.resourceReleaseList[(int)RenderGraphResourceType.Texture])
diff --git a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphBuilder.cs b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphBuilder.cs
index 4b93e5392ac..0633c1a92cd 100644
--- a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphBuilder.cs
+++ b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphBuilder.cs
@@ -73,7 +73,7 @@ public TextureHandle WriteTexture(in TextureHandle input)
/// A new transient TextureHandle.
public TextureHandle CreateTransientTexture(in TextureDesc desc)
{
- var result = m_Resources.CreateTexture(desc, 0, m_RenderPass.index);
+ var result = m_Resources.CreateTexture(desc, m_RenderPass.index);
m_RenderPass.AddTransientResource(result.handle);
return result;
}
@@ -87,7 +87,7 @@ public TextureHandle CreateTransientTexture(in TextureDesc desc)
public TextureHandle CreateTransientTexture(in TextureHandle texture)
{
var desc = m_Resources.GetTextureResourceDesc(texture.handle);
- var result = m_Resources.CreateTexture(desc, 0, m_RenderPass.index);
+ var result = m_Resources.CreateTexture(desc, m_RenderPass.index);
m_RenderPass.AddTransientResource(result.handle);
return result;
}
diff --git a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs
index 8847f3825d3..2de34972e8a 100644
--- a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs
+++ b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs
@@ -33,7 +33,6 @@ class IRenderGraphResource
{
public bool imported;
public int cachedHash;
- public int shaderProperty;
public int transientPassIndex;
public bool wasReleased;
@@ -41,7 +40,6 @@ public virtual void Reset()
{
imported = false;
cachedHash = -1;
- shaderProperty = 0;
transientPassIndex = -1;
wasReleased = false;
}
@@ -209,12 +207,11 @@ internal int GetResourceTransientIndex(in ResourceHandle res)
}
// Texture Creation/Import APIs are internal because creation should only go through RenderGraph
- internal TextureHandle ImportTexture(RTHandle rt, int shaderProperty = 0)
+ internal TextureHandle ImportTexture(RTHandle rt)
{
int newHandle = AddNewResource(m_Resources[(int)RenderGraphResourceType.Texture], out TextureResource texResource);
texResource.resource = rt;
texResource.imported = true;
- texResource.shaderProperty = shaderProperty;
return new TextureHandle(newHandle);
}
@@ -246,13 +243,12 @@ internal TextureHandle ImportBackbuffer(RenderTargetIdentifier rt)
return result;
}
- internal TextureHandle CreateTexture(in TextureDesc desc, int shaderProperty = 0, int transientPassIndex = -1)
+ internal TextureHandle CreateTexture(in TextureDesc desc, int transientPassIndex = -1)
{
ValidateTextureDesc(desc);
int newHandle = AddNewResource(m_Resources[(int)RenderGraphResourceType.Texture], out TextureResource texResource);
texResource.desc = desc;
- texResource.shaderProperty = shaderProperty;
texResource.transientPassIndex = transientPassIndex;
return new TextureHandle(newHandle);
}
@@ -408,32 +404,6 @@ internal void CreateComputeBuffer(RenderGraphContext rgContext, int index)
}
}
- void SetGlobalTextures(RenderGraphContext rgContext, List textures, bool bindDummyTexture)
- {
- foreach (var resource in textures)
- {
- var resourceDesc = GetTextureResource(resource);
- if (resourceDesc.shaderProperty != 0)
- {
- if (resourceDesc.resource != null)
- {
- rgContext.cmd.SetGlobalTexture(resourceDesc.shaderProperty, bindDummyTexture ? TextureXR.GetMagentaTexture() : resourceDesc.resource);
- }
- }
- }
- }
-
-
- internal void PreRenderPassSetGlobalTextures(RenderGraphContext rgContext, List textures)
- {
- SetGlobalTextures(rgContext, textures, false);
- }
-
- internal void PostRenderPassUnbindGlobalTextures(RenderGraphContext rgContext, List textures)
- {
- SetGlobalTextures(rgContext, textures, true);
- }
-
internal void ReleaseTexture(RenderGraphContext rgContext, int index)
{
var resource = m_Resources[(int)RenderGraphResourceType.Texture][index] as TextureResource;
diff --git a/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl
index 5eb72f7f7ad..dcac7653d09 100644
--- a/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl
+++ b/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl
@@ -177,7 +177,7 @@ real3 UnpackNormalAG(real4 packedNormal, real scale = 1.0)
{
real3 normal;
normal.xy = packedNormal.ag * 2.0 - 1.0;
- normal.z = sqrt(1.0 - saturate(dot(normal.xy, normal.xy)));
+ normal.z = max(1.0e-16, sqrt(1.0 - saturate(dot(normal.xy, normal.xy))));
// must scale after reconstruction of normal.z which also
// mirrors UnpackNormalRGB(). This does imply normal is not returned
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index 3d491d4abcc..f65a221d12d 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -159,6 +159,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added an option to extend the camera culling for skinned mesh animation in ray tracing effects (1258547).
- Added decal layer system similar to light layer. Mesh will receive a decal when both decal layer mask matches.
- Added shader graph nodes for rendering a complex eye shader.
+- Added more controls to contact shadows and increased quality in some parts.
+- Added a physically based option in DoF volume.
### Fixed
- Fix when rescale probe all direction below zero (1219246)
@@ -726,6 +728,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed robustness issue with GetOddNegativeScale() in ray tracing, which was impacting normal mapping (1261160).
- Fixed regression where moving face of the probe gizmo was not moving its position anymore.
- Fixed XR single-pass macros in tessellation shaders.
+- Fixed path-traced subsurface scattering mixing with diffuse and specular BRDFs (1250601).
+- Fixed custom pass re-ordering issues.
+- Improved robustness of normal mapping when scale is 0, and mapping is extreme (normals in or below the tangent plane).
### Changed
- Improve MIP selection for decals on Transparents
@@ -886,6 +891,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- PBR Sky now doesn't go black when going below sea level, but it instead freezes calculation as if on the horizon.
- Fixed an issue with quality setting foldouts not opening when clicking on them (1253088).
- Shutter speed can now be changed by dragging the mouse over the UI label (case 1245007).
+- Remove the 'Point Cube Size' for cookie, use the Cubemap size directly.
## [7.1.1] - 2019-09-05
diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Override-Cloud-Layer.md b/com.unity.render-pipelines.high-definition/Documentation~/Override-Cloud-Layer.md
index da9ca42aa1a..a49e92dfa5b 100644
--- a/com.unity.render-pipelines.high-definition/Documentation~/Override-Cloud-Layer.md
+++ b/com.unity.render-pipelines.high-definition/Documentation~/Override-Cloud-Layer.md
@@ -26,8 +26,8 @@ This example Cloud Map is a read-only **CustomRenderTexture**. This means that,
## Customizing the Cloud Map
-The Cloud Map is a 2D texture in LatLong layout (sometimes called Cylindrical or Equirectangular) that contains cloud color in the RGB channel and cloud coverage in the alpha channel.
-If **Upper Hemisphere Only** is checked, the map is interpreted as being the upper half of a LatLong texture.
+The Cloud Map is a 2D texture in LatLong layout (sometimes called Cylindrical or Equirectangular) that contains cloud opacity in the red channel.
+If **Upper Hemisphere Only** is checked, the map is interpreted as being the upper half of a LatLong texture. It means that it will only conver the sky above the horizon.
diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Override-Contact-Shadows.md b/com.unity.render-pipelines.high-definition/Documentation~/Override-Contact-Shadows.md
index 00de0cfcf4f..5e140337cec 100644
--- a/com.unity.render-pipelines.high-definition/Documentation~/Override-Contact-Shadows.md
+++ b/com.unity.render-pipelines.high-definition/Documentation~/Override-Contact-Shadows.md
@@ -31,6 +31,8 @@ Only one Light can cast Contact Shadows at a time. This means that, if you have
| __Fade Out Distance__ | The distance, in meters, over which HDRP fades Contact Shadows out when at the __Max Distance__. |
| __Sample Count__ | Use the slider to set the number of samples HDRP uses for ray casting. Increasing this increases quality at the cost of performance. |
| __Opacity__ | Use the slider to set the opacity of the Contact Shadows. Lower values result in softer, less prominent shadows. |
+| **Ray Bias** | Controls the bias applied to the screen space ray cast to get contact shadows. Higher values can reduce self shadowing, however too high values might lead to peter-panning that can be especially undesirable with contact shadows. |
+| **Thickness** | Controls the thickness of the objects found along the ray, essentially thickening the contact shadows. It can be used to fill holes in the shadows, however might also lead to overly wide shadows. |
## Details
diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Post-Processing-Depth-of-Field.md b/com.unity.render-pipelines.high-definition/Documentation~/Post-Processing-Depth-of-Field.md
index 447004a2a5b..dccf270021f 100644
--- a/com.unity.render-pipelines.high-definition/Documentation~/Post-Processing-Depth-of-Field.md
+++ b/com.unity.render-pipelines.high-definition/Documentation~/Post-Processing-Depth-of-Field.md
@@ -45,6 +45,7 @@ Depth Of Field includes [more options](More-Options.html) that you must manually
| -------------------------- | ------------------------------------------------------------ |
| **Resolution** | Use the drop-down to set the resolution at which HDRP processes the depth of field effect. If you target consoles that use a very high resolution (for example, 4k), select **Quarter,** because it is less resource intensive.
• **Quarter**: Uses quarter the screen resolution.
• **Half**: Uses half the screen resolution.
This property only appears when you enable [more options](More-Options.html). |
| **High Quality Filtering** | Enable the checkbox to make HDRP use bicubic filtering instead of bilinear filtering. This increases the resource intensity of the Depth Of Field effect, but results in smoother visuals.
This property only appears when you enable [more options](More-Options.html). |
+| **Physically Based** | Enable the checkbox to make HDRP use a more accurate but slower physically-based technique for the computation of Deph-of-Field. It is highly recommended to enable [Temporal anti-aliasing (TAA)](Anti-Aliasing) at the same time, for improved quality and performance.|
diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md
index 2202e578df3..32e7a1051c5 100644
--- a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md
+++ b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md
@@ -40,6 +40,8 @@ In the 2D Atlas Size drop-down, select a larger cookie resolution.
From Unity 2020.2, the texture format of the color buffer in the HDRP Asset also applies to [Planar Reflection Probes](Planar-Reflection-Probe.md). Previously, Planar Reflection Probes always used a float16 rendertarget.
+From Unity 2020.2, the light layer properties have move from the HDRP settings to the HDRP Default setting Panel.
+
## Shadows
From Unity 2020.2, it is no longer necessary to change the [HDRP Config package](HDRP-Config-Package.md) to set the [shadow filtering quality](HDRP-Asset.md#FilteringQualities) for deferred rendering. Instead, you can now change the filtering quality directly on the [HDRP Asset](HDRP-Asset.md#FilteringQualities). Note if you previously had not set the shadow filtering quality to **Medium** on the HDRP Asset, the automatic project upgrade process changes the shadow quality which means you may need to manually change it back to its original value.
@@ -48,6 +50,8 @@ HDRP now stores OnEnable and OnDemand shadows in a separate atlas and more API i
The shader function `SampleShadow_PCSS` now requires you to pass in an additional float2 parameter which contains the shadow atlas resolution in x and the inverse of the atlas resolution in y.
+Ray bias and thickness parameters have been added to contact shadows. These might lead to small changes to the visual impact of contact shadows with the default parameters. Please consider tuning those values to fit the needs of your project.
+
## Shader config file
From Unity 2020.2, due to the change of the shadow map, HDRP moved the HDShadowFilteringQuality enum to HDShadowManager.cs. HDRP also removed ShaderConfig.s_DeferredShadowFiltering and ShaderOptions.DeferredShadowFiltering from the source code because they have no effect anymore.
diff --git a/com.unity.render-pipelines.high-definition/Documentation~/whats-new-10-0.md b/com.unity.render-pipelines.high-definition/Documentation~/whats-new-10-0.md
index 88eb1a27f10..11004ba38ca 100644
--- a/com.unity.render-pipelines.high-definition/Documentation~/whats-new-10-0.md
+++ b/com.unity.render-pipelines.high-definition/Documentation~/whats-new-10-0.md
@@ -247,6 +247,10 @@ You can now control the texture mapping mode for all textures in the [AxF Shader
For more information about this improvement, see [AxF Shader](AxF-Shader.md).
+### Contact Shadows Improvements
+
+More control is given for contact shadows, in particular now a bias can be set to avoid self intersection issues and a new thickness parameter is introduced to fill gaps that can be left by contact shadows.
+
### Exposure
#### Exposure curve mapping
diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/ContactShadowsEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/ContactShadowsEditor.cs
index a97685d796e..0ece2c40546 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/ContactShadowsEditor.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/ContactShadowsEditor.cs
@@ -16,6 +16,8 @@ class ContactShadowsEditor : VolumeComponentWithQualityEditor
SerializedDataParameter m_FadeInDistance;
SerializedDataParameter m_SampleCount;
SerializedDataParameter m_Opacity;
+ SerializedDataParameter m_Bias;
+ SerializedDataParameter m_Thickness;
public override void OnEnable()
{
@@ -32,6 +34,8 @@ public override void OnEnable()
m_FadeInDistance = Unpack(o.Find(x => x.fadeInDistance));
m_SampleCount = Unpack(o.Find(x => x.sampleCount));
m_Opacity = Unpack(o.Find(x => x.opacity));
+ m_Bias = Unpack(o.Find(x => x.rayBias));
+ m_Thickness = Unpack(o.Find(x => x.thicknessScale));
}
public override void OnInspectorGUI()
@@ -49,6 +53,9 @@ public override void OnInspectorGUI()
PropertyField(m_FadeInDistance, EditorGUIUtility.TrTextContent("Fade In Distance", "Sets the distance over which HDRP fades Contact Shadows in when past the Min Distance. Uses meters."));
PropertyField(m_FadeDistance, EditorGUIUtility.TrTextContent("Fade Out Distance", "Sets the distance over which HDRP fades Contact Shadows out when at the Max Distance. Uses meters."));
PropertyField(m_Opacity, EditorGUIUtility.TrTextContent("Opacity", "Controls the opacity of the Contact Shadow."));
+ PropertyField(m_Bias, EditorGUIUtility.TrTextContent("Bias", "Controls the bias applied to the screen space ray cast to get contact shadows."));
+ PropertyField(m_Thickness, EditorGUIUtility.TrTextContent("Thickness", "Controls the thickness of the objects found along the ray, essentially thickening the contact shadows."));
+
base.OnInspectorGUI();
GUI.enabled = useCustomValue;
PropertyField(m_SampleCount, EditorGUIUtility.TrTextContent("Sample Count", "Controls the number of samples HDRP uses for ray casting."));
diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalSubTarget.Migration.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalSubTarget.Migration.cs
index b7699a48739..37bfb6a6986 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalSubTarget.Migration.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalSubTarget.Migration.cs
@@ -20,7 +20,9 @@ public bool TryUpgradeFromMasterNode(IMasterNode1 masterNode, out Dictionary blockMap)
{
+ m_MigrateFromOldSG = true;
+
blockMap = null;
switch(masterNode)
{
@@ -41,8 +43,8 @@ void UpgradePBRMasterNode(PBRMasterNode1 pbrMasterNode, out Dictionary lightingData.specularOcclusionMode, (newValue) => lightingData.specularOcclusionMode = newValue);
AddProperty(Styles.overrideBakedGI, () => lightingData.overrideBakedGI, (newValue) => lightingData.overrideBakedGI = newValue);
}
- AddProperty(Styles.supportLodCrossFade, () => systemData.supportLodCrossFade, (newValue) => systemData.supportLodCrossFade = newValue);
+ AddProperty(Styles.supportLodCrossFade, () => builtinData.supportLodCrossFade, (newValue) => builtinData.supportLodCrossFade = newValue);
AddProperty(addPrecomputedVelocityText, () => builtinData.addPrecomputedVelocity, (newValue) => builtinData.addPrecomputedVelocity = newValue);
}
}
diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubTarget.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubTarget.cs
index b16eea5f1ca..312a4d72236 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubTarget.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubTarget.cs
@@ -18,6 +18,7 @@ abstract class HDSubTarget : SubTarget, IHasMetadata,
{
SystemData m_SystemData;
protected bool m_MigrateFromOldCrossPipelineSG; // Use only for the migration to shader stack architecture
+ protected bool m_MigrateFromOldSG; // Use only for the migration from early shader stack architecture to recent one
// Interface Properties
SystemData IRequiresData.data
@@ -33,12 +34,7 @@ public SystemData systemData
set => m_SystemData = value;
}
- protected virtual int ComputeMaterialNeedsUpdateHash()
- {
- // Alpha test is currently the only property in system data to trigger the material upgrade script.
- int hash = systemData.alphaTest.GetHashCode();
- return hash;
- }
+ protected virtual int ComputeMaterialNeedsUpdateHash() => 0;
public override bool IsActive() => true;
@@ -97,6 +93,15 @@ public override void Setup(ref TargetSetupContext context)
if (migrationSteps.Migrate(this))
OnBeforeSerialize();
+ // Migration hack to have the case where SG doesn't have version yet but is already upgraded to the stack system
+ if (!systemData.firstTimeMigrationExecuted)
+ {
+ // Force the initial migration step
+ MigrateTo(ShaderGraphVersion.FirstTimeMigration);
+ systemData.firstTimeMigrationExecuted = true;
+ OnBeforeSerialize();
+ }
+
foreach (var subShader in EnumerateSubShaders())
{
// patch render type and render queue from pass declaration:
diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/ShaderGraphVersion.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/ShaderGraphVersion.cs
index 1864ea0f241..35e55f3d8d6 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/ShaderGraphVersion.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/ShaderGraphVersion.cs
@@ -9,5 +9,6 @@ namespace UnityEditor.Rendering.HighDefinition.ShaderGraph
public enum ShaderGraphVersion
{
Initial = 0,
+ FirstTimeMigration = Initial,
}
}
diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceOptionPropertyBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceOptionPropertyBlock.cs
index 6070ce58960..b3a8aac07c8 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceOptionPropertyBlock.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceOptionPropertyBlock.cs
@@ -65,8 +65,8 @@ protected override void CreatePropertyGUI()
AddProperty(transparentCullModeText, () => systemData.transparentCullMode, (newValue) => systemData.transparentCullMode = newValue);
AddProperty(transparentSortPriorityText, () => systemData.sortPriority, (newValue) => systemData.sortPriority = HDRenderQueue.ClampsTransparentRangePriority(newValue));
AddProperty(transparentBackfaceEnableText, () => builtinData.backThenFrontRendering, (newValue) => builtinData.backThenFrontRendering = newValue);
- AddProperty(transparentDepthPrepassEnableText, () => systemData.transparentDepthPrepass, (newValue) => systemData.transparentDepthPrepass = newValue);
- AddProperty(transparentDepthPostpassEnableText, () => systemData.transparentDepthPostpass, (newValue) => systemData.transparentDepthPostpass = newValue);
+ AddProperty(transparentDepthPrepassEnableText, () => builtinData.transparentDepthPrepass, (newValue) => builtinData.transparentDepthPrepass = newValue);
+ AddProperty(transparentDepthPostpassEnableText, () => builtinData.transparentDepthPostpass, (newValue) => builtinData.transparentDepthPostpass = newValue);
AddProperty(transparentWritingMotionVecText, () => builtinData.transparentWritesMotionVec, (newValue) => builtinData.transparentWritesMotionVec = newValue);
if (lightingData != null)
diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceSubTarget.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceSubTarget.cs
index d20a3fd2290..d9152711ffd 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceSubTarget.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceSubTarget.cs
@@ -42,6 +42,13 @@ protected override string renderQueue
protected virtual bool supportDistortion => false;
protected override bool supportRaytracing => true;
+ protected override int ComputeMaterialNeedsUpdateHash()
+ {
+ // Alpha test is currently the only property in buitin data to trigger the material upgrade script.
+ int hash = systemData.alphaTest.GetHashCode();
+ return hash;
+ }
+
public override void Setup(ref TargetSetupContext context)
{
context.AddAssetDependencyPath(AssetDatabase.GUIDToAssetPath("f4df7e8f9b8c23648ae50cbca0221e47")); // SurfaceSubTarget.cs
@@ -194,15 +201,15 @@ public override void GetFields(ref TargetFieldContext context)
context.AddField(HDFields.DoAlphaTestShadow, systemData.alphaTest && builtinData.alphaTestShadow && isShadowPass &&
context.pass.validPixelBlocks.Contains(HDBlockFields.SurfaceDescription.AlphaClipThresholdShadow));
// Pre/post pass always use the specific alpha test provided for those pass
- context.AddField(HDFields.DoAlphaTestPrepass, systemData.alphaTest && systemData.transparentDepthPrepass && isTransparentDepthPrepass &&
+ context.AddField(HDFields.DoAlphaTestPrepass, systemData.alphaTest && builtinData.transparentDepthPrepass && isTransparentDepthPrepass &&
context.pass.validPixelBlocks.Contains(HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPrepass));
// Features & Misc
- context.AddField(Fields.LodCrossFade, systemData.supportLodCrossFade);
+ context.AddField(Fields.LodCrossFade, builtinData.supportLodCrossFade);
context.AddField(Fields.AlphaToMask, systemData.alphaTest);
context.AddField(HDFields.TransparentBackFace, builtinData.backThenFrontRendering);
- context.AddField(HDFields.TransparentDepthPrePass, systemData.transparentDepthPrepass);
- context.AddField(HDFields.TransparentDepthPostPass, systemData.transparentDepthPostpass);
+ context.AddField(HDFields.TransparentDepthPrePass, builtinData.transparentDepthPrepass);
+ context.AddField(HDFields.TransparentDepthPostPass, builtinData.transparentDepthPostpass);
context.AddField(HDFields.DepthOffset, builtinData.depthOffset && context.pass.validPixelBlocks.Contains(HDBlockFields.SurfaceDescription.DepthOffset));
@@ -239,8 +246,8 @@ public override void GetActiveBlocks(ref TargetActiveBlockContext context)
context.AddBlock(BlockFields.SurfaceDescription.AlphaClipThreshold, systemData.alphaTest);
// Alpha Test
- context.AddBlock(HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPrepass, systemData.alphaTest && systemData.transparentDepthPrepass);
- context.AddBlock(HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPostpass, systemData.alphaTest && systemData.transparentDepthPostpass);
+ context.AddBlock(HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPrepass, systemData.alphaTest && builtinData.transparentDepthPrepass);
+ context.AddBlock(HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPostpass, systemData.alphaTest && builtinData.transparentDepthPostpass);
context.AddBlock(HDBlockFields.SurfaceDescription.AlphaClipThresholdShadow, systemData.alphaTest && builtinData.alphaTestShadow);
// Misc
@@ -306,7 +313,7 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera
// Common properties for all "surface" master nodes
HDSubShaderUtilities.AddAlphaCutoffShaderProperties(collector, systemData.alphaTest, builtinData.alphaTestShadow);
HDSubShaderUtilities.AddDoubleSidedProperty(collector, systemData.doubleSidedMode);
- HDSubShaderUtilities.AddPrePostPassProperties(collector, systemData.transparentDepthPrepass, systemData.transparentDepthPostpass);
+ HDSubShaderUtilities.AddPrePostPassProperties(collector, builtinData.transparentDepthPrepass, builtinData.transparentDepthPostpass);
// Add all shader properties required by the inspector
HDSubShaderUtilities.AddBlendingStatesShaderProperties(
@@ -343,5 +350,24 @@ public override void ProcessPreviewMaterial(Material material)
LightingShaderGraphGUI.SetupMaterialKeywordsAndPass(material);
}
+
+ internal override void MigrateTo(ShaderGraphVersion version)
+ {
+ base.MigrateTo(version);
+
+ if (version == ShaderGraphVersion.FirstTimeMigration)
+ {
+#pragma warning disable 618
+ // If we come from old master node, nothing to do.
+ // Only perform an action if we are a shader stack
+ if (!m_MigrateFromOldSG)
+ {
+ builtinData.transparentDepthPrepass = systemData.m_TransparentDepthPrepass;
+ builtinData.transparentDepthPostpass = systemData.m_TransparentDepthPostpass;
+ builtinData.supportLodCrossFade = systemData.m_SupportLodCrossFade;
+ }
+#pragma warning restore 618
+ }
+ }
}
}
diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/TargetData/BuiltinData.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/TargetData/BuiltinData.cs
index 9631c205651..d6e530607bd 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/TargetData/BuiltinData.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/TargetData/BuiltinData.cs
@@ -85,5 +85,29 @@ public bool backThenFrontRendering
get => m_BackThenFrontRendering;
set => m_BackThenFrontRendering = value;
}
+
+ [SerializeField]
+ bool m_TransparentDepthPrepass;
+ public bool transparentDepthPrepass
+ {
+ get => m_TransparentDepthPrepass;
+ set => m_TransparentDepthPrepass = value;
+ }
+
+ [SerializeField]
+ bool m_TransparentDepthPostpass;
+ public bool transparentDepthPostpass
+ {
+ get => m_TransparentDepthPostpass;
+ set => m_TransparentDepthPostpass = value;
+ }
+
+ [SerializeField]
+ bool m_SupportLodCrossFade;
+ public bool supportLodCrossFade
+ {
+ get => m_SupportLodCrossFade;
+ set => m_SupportLodCrossFade = value;
+ }
}
}
diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/TargetData/SystemData.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/TargetData/SystemData.cs
index 54d45df996c..6df41be68da 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/TargetData/SystemData.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/TargetData/SystemData.cs
@@ -90,21 +90,14 @@ public bool alphaTest
set => m_AlphaTest = value;
}
- [SerializeField]
- bool m_TransparentDepthPrepass;
- public bool transparentDepthPrepass
- {
- get => m_TransparentDepthPrepass;
- set => m_TransparentDepthPrepass = value;
- }
+ [SerializeField, Obsolete("Keep for migration")]
+ internal bool m_TransparentDepthPrepass;
- [SerializeField]
- bool m_TransparentDepthPostpass;
- public bool transparentDepthPostpass
- {
- get => m_TransparentDepthPostpass;
- set => m_TransparentDepthPostpass = value;
- }
+ [SerializeField, Obsolete("Keep for migration")]
+ internal bool m_TransparentDepthPostpass;
+
+ [SerializeField, Obsolete("Keep for migration")]
+ internal bool m_SupportLodCrossFade;
[SerializeField]
DoubleSidedMode m_DoubleSidedMode;
@@ -114,14 +107,6 @@ public DoubleSidedMode doubleSidedMode
set => m_DoubleSidedMode = value;
}
- [SerializeField]
- bool m_SupportLodCrossFade;
- public bool supportLodCrossFade
- {
- get => m_SupportLodCrossFade;
- set => m_SupportLodCrossFade = value;
- }
-
// TODO: This was on HDUnlitMaster but not used anywhere
// TODO: On HDLit it adds the field `HDFields.DotsInstancing`
// TODO: Should this be added properly to HDUnlit?
@@ -141,6 +126,16 @@ public ShaderGraphVersion version
set => m_Version = value;
}
+ [SerializeField]
+ bool m_FirstTimeMigrationExecuted = false;
+ public bool firstTimeMigrationExecuted
+ {
+ get => m_FirstTimeMigrationExecuted;
+ set => m_FirstTimeMigrationExecuted = value;
+ }
+
+
+ [SerializeField]
internal int inspectorFoldoutMask;
}
diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitSubTarget.Migration.cs b/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitSubTarget.Migration.cs
index e3beab194e2..8a2a368a977 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitSubTarget.Migration.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitSubTarget.Migration.cs
@@ -21,6 +21,8 @@ public bool TryUpgradeFromMasterNode(IMasterNode1 masterNode, out Dictionary m.HasProperty(kDoubleSidedEnable)))
+ materialEditor.DoubleSidedGIField();
+ }
+
+ if ((m_Features & Features.EmissionGI) != 0)
+ DrawEmissionGI();
+
+ if ((m_Features & Features.MotionVector) != 0)
+ DrawMotionVectorToggle();
if ((m_Features & Features.SpecularOcclusion) != 0)
materialEditor.ShaderProperty(specularOcclusionMode, Styles.specularOcclusionModeText);
if ((m_Features & Features.AddPrecomputedVelocity) != 0)
@@ -79,5 +102,47 @@ void DrawAdvancedOptionsGUI()
materialEditor.ShaderProperty(addPrecomputedVelocity, Styles.addPrecomputedVelocityText);
}
}
+
+ void DrawEmissionGI()
+ {
+ EmissionUIBlock.BakedEmissionEnabledProperty(materialEditor);
+ }
+
+ void DrawMotionVectorToggle()
+ {
+ // We have no way to setup motion vector pass to be false by default for a shader graph
+ // So here we workaround it with materialTag system by checking if a tag exist to know if it is
+ // the first time we display this information. And thus setup the MotionVector Pass to false.
+ const string materialTag = "MotionVector";
+
+ string tag = materials[0].GetTag(materialTag, false, "Nothing");
+ if (tag == "Nothing")
+ {
+ materials[0].SetShaderPassEnabled(HDShaderPassNames.s_MotionVectorsStr, false);
+ materials[0].SetOverrideTag(materialTag, "User");
+ }
+
+ //In the case of additional velocity data we will enable the motion vector pass.
+ bool addPrecomputedVelocity = false;
+ if (materials[0].HasProperty(kAddPrecomputedVelocity))
+ {
+ addPrecomputedVelocity = materials[0].GetInt(kAddPrecomputedVelocity) != 0;
+ }
+
+ bool currentMotionVectorState = materials[0].GetShaderPassEnabled(HDShaderPassNames.s_MotionVectorsStr);
+ bool enabled = currentMotionVectorState || addPrecomputedVelocity;
+
+ EditorGUI.BeginChangeCheck();
+
+ using (new EditorGUI.DisabledScope(addPrecomputedVelocity))
+ {
+ enabled = EditorGUILayout.Toggle(Styles.motionVectorForVertexAnimationText, enabled);
+ }
+
+ if (EditorGUI.EndChangeCheck() || currentMotionVectorState != enabled)
+ {
+ materials[0].SetShaderPassEnabled(HDShaderPassNames.s_MotionVectorsStr, enabled);
+ }
+ }
}
}
diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/ShaderGraphUIBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/ShaderGraphUIBlock.cs
index 1fa7e03a3e5..151acd1226e 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/ShaderGraphUIBlock.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/ShaderGraphUIBlock.cs
@@ -15,21 +15,15 @@ class ShaderGraphUIBlock : MaterialUIBlock
public enum Features
{
None = 0,
- MotionVector = 1 << 0,
- EmissionGI = 1 << 1,
DiffusionProfileAsset = 1 << 2,
- EnableInstancing = 1 << 3,
- DoubleSidedGI = 1 << 4,
ShadowMatte = 1 << 5,
- Unlit = MotionVector | EmissionGI | ShadowMatte,
+ Unlit = ShadowMatte,
All = ~0,
}
protected static class Styles
{
public const string header = "Exposed Properties";
- public static readonly GUIContent bakedEmission = new GUIContent("Baked Emission", "");
- public static readonly GUIContent motionVectorForVertexAnimationText = new GUIContent("Motion Vector For Vertex Animation", "When enabled, HDRP will correctly handle velocity for vertex animated object. Only enable if there is vertex animation in the ShaderGraph.");
}
Expandable m_ExpandableBit;
@@ -106,29 +100,9 @@ void DrawShaderGraphGUI()
HDShaderUtils.ResetMaterialKeywords(material);
}
- if (properties.Length > 0)
- EditorGUILayout.Space();
-
if ((m_Features & Features.DiffusionProfileAsset) != 0)
DrawDiffusionProfileUI();
- if ((m_Features & Features.EnableInstancing) != 0)
- materialEditor.EnableInstancingField();
-
- if ((m_Features & Features.DoubleSidedGI) != 0)
- {
- // If the shader graph have a double sided flag, then we don't display this field.
- // The double sided GI value will be synced with the double sided property during the SetupBaseUnlitKeywords()
- if (!materials.All(m => m.HasProperty(kDoubleSidedEnable)))
- materialEditor.DoubleSidedGIField();
- }
-
- if ((m_Features & Features.EmissionGI) != 0)
- DrawEmissionGI();
-
- if ((m_Features & Features.MotionVector) != 0)
- DrawMotionVectorToggle();
-
if ((m_Features & Features.ShadowMatte) != 0 && materials.All(m => m.HasProperty(kShadowMatteFilter)))
DrawShadowMatteToggle();
}
@@ -147,48 +121,6 @@ void PropertiesDefaultGUI(MaterialProperty[] properties)
}
}
- void DrawEmissionGI()
- {
- EmissionUIBlock.BakedEmissionEnabledProperty(materialEditor);
- }
-
- void DrawMotionVectorToggle()
- {
- // We have no way to setup motion vector pass to be false by default for a shader graph
- // So here we workaround it with materialTag system by checking if a tag exist to know if it is
- // the first time we display this information. And thus setup the MotionVector Pass to false.
- const string materialTag = "MotionVector";
-
- string tag = materials[0].GetTag(materialTag, false, "Nothing");
- if (tag == "Nothing")
- {
- materials[0].SetShaderPassEnabled(HDShaderPassNames.s_MotionVectorsStr, false);
- materials[0].SetOverrideTag(materialTag, "User");
- }
-
- //In the case of additional velocity data we will enable the motion vector pass.
- bool addPrecomputedVelocity = false;
- if (materials[0].HasProperty(kAddPrecomputedVelocity))
- {
- addPrecomputedVelocity = materials[0].GetInt(kAddPrecomputedVelocity) != 0;
- }
-
- bool currentMotionVectorState = materials[0].GetShaderPassEnabled(HDShaderPassNames.s_MotionVectorsStr);
- bool enabled = currentMotionVectorState || addPrecomputedVelocity;
-
- EditorGUI.BeginChangeCheck();
-
- using (new EditorGUI.DisabledScope(addPrecomputedVelocity))
- {
- enabled = EditorGUILayout.Toggle(Styles.motionVectorForVertexAnimationText, enabled);
- }
-
- if (EditorGUI.EndChangeCheck() || currentMotionVectorState != enabled)
- {
- materials[0].SetShaderPassEnabled(HDShaderPassNames.s_MotionVectorsStr, enabled);
- }
- }
-
void DrawShadowMatteToggle()
{
uint exponent = 0b10000000; // 0 as exponent
diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitSubTarget.Migration.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitSubTarget.Migration.cs
index c942d29a510..6ca71bc7bb1 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitSubTarget.Migration.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitSubTarget.Migration.cs
@@ -34,6 +34,7 @@ public bool TryUpgradeFromMasterNode(IMasterNode1 masterNode, out Dictionary blockMap)
{
m_MigrateFromOldCrossPipelineSG = true;
+ m_MigrateFromOldSG = true;
// Set data
systemData.surfaceType = (SurfaceType)unlitMasterNode.m_SurfaceType;
@@ -61,6 +62,8 @@ void UpgradeUnlitMasterNode(UnlitMasterNode1 unlitMasterNode, out Dictionary blockMap)
{
+ m_MigrateFromOldSG = true;
+
// Set data
systemData.surfaceType = (SurfaceType)hdUnlitMasterNode.m_SurfaceType;
systemData.blendMode = HDSubShaderUtilities.UpgradeLegacyAlphaModeToBlendMode((int)hdUnlitMasterNode.m_AlphaMode);
diff --git a/com.unity.render-pipelines.high-definition/Editor/PostProcessing/DepthOfFieldEditor.cs b/com.unity.render-pipelines.high-definition/Editor/PostProcessing/DepthOfFieldEditor.cs
index b83769a5e4e..641a2b98665 100644
--- a/com.unity.render-pipelines.high-definition/Editor/PostProcessing/DepthOfFieldEditor.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/PostProcessing/DepthOfFieldEditor.cs
@@ -19,6 +19,9 @@ static partial class Styles
public static GUIContent k_NearFocusEnd = new GUIContent("End", "Sets the distance from the Camera at which the near field does not blur anymore.");
public static GUIContent k_FarFocusEnd = new GUIContent("End", "Sets the distance from the Camera at which the far field blur reaches its maximum blur radius.");
+ public static GUIContent k_PhysicallyBased = new GUIContent("PhysicallyBased", "Uses a more accurate but slower physically based method to compute DoF.");
+
+ public static readonly string InfoBox = "Physically Based DoF currently has a high performance overhead. Enabling TAA is highly recommended when using this option.";
}
SerializedDataParameter m_FocusMode;
@@ -41,6 +44,7 @@ static partial class Styles
// Advanced settings
SerializedDataParameter m_HighQualityFiltering;
SerializedDataParameter m_Resolution;
+ SerializedDataParameter m_PhysicallyBased;
public override bool hasAdvancedMode => true;
@@ -66,6 +70,7 @@ public override void OnEnable()
m_HighQualityFiltering = Unpack(o.Find("m_HighQualityFiltering"));
m_Resolution = Unpack(o.Find("m_Resolution"));
+ m_PhysicallyBased = Unpack(o.Find("m_PhysicallyBased"));
}
public override void OnInspectorGUI()
@@ -132,6 +137,9 @@ public override void OnInspectorGUI()
EditorGUILayout.LabelField("Advanced Tweaks", EditorStyles.miniLabel);
PropertyField(m_Resolution);
PropertyField(m_HighQualityFiltering);
+ PropertyField(m_PhysicallyBased);
+ if(m_PhysicallyBased.value.boolValue == true)
+ EditorGUILayout.HelpBox(Styles.InfoBox, MessageType.Info);
GUI.enabled = true;
}
}
diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/CustomPassVolumeEditor.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/CustomPassVolumeEditor.cs
index 19b8e67f528..12936dae009 100644
--- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/CustomPassVolumeEditor.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/CustomPassVolumeEditor.cs
@@ -103,12 +103,12 @@ void DrawMaterialsGUI()
m_CustomPassMaterialsHash = materialsHash;
}
- Dictionary customPassDrawers = new Dictionary();
- CustomPassDrawer GetCustomPassDrawer(SerializedProperty pass, int listIndex)
+ Dictionary customPassDrawers = new Dictionary();
+ CustomPassDrawer GetCustomPassDrawer(SerializedProperty pass, CustomPass reference, int listIndex)
{
CustomPassDrawer drawer;
- if (customPassDrawers.TryGetValue(pass, out drawer))
+ if (customPassDrawers.TryGetValue(reference, out drawer))
return drawer;
var customPass = m_Volume.customPasses[listIndex];
@@ -132,7 +132,7 @@ CustomPassDrawer GetCustomPassDrawer(SerializedProperty pass, int listIndex)
}
}
- customPassDrawers[pass] = drawer;
+ customPassDrawers[reference] = drawer;
return drawer;
}
@@ -193,8 +193,9 @@ void CreateReorderableList(SerializedProperty passList)
m_CustomPassList.drawElementCallback = (rect, index, active, focused) => {
EditorGUI.BeginChangeCheck();
+ passList.serializedObject.ApplyModifiedProperties();
var customPass = passList.GetArrayElementAtIndex(index);
- var drawer = GetCustomPassDrawer(customPass, index);
+ var drawer = GetCustomPassDrawer(customPass, m_Volume.customPasses[index], index);
if (drawer != null)
drawer.OnGUI(rect, customPass, null);
else
@@ -205,8 +206,9 @@ void CreateReorderableList(SerializedProperty passList)
m_CustomPassList.elementHeightCallback = (index) =>
{
+ passList.serializedObject.ApplyModifiedProperties();
var customPass = passList.GetArrayElementAtIndex(index);
- var drawer = GetCustomPassDrawer(customPass, index);
+ var drawer = GetCustomPassDrawer(customPass, m_Volume.customPasses[index], index);
if (drawer != null)
return drawer.GetPropertyHeight(customPass, null);
else
@@ -223,10 +225,10 @@ void CreateReorderableList(SerializedProperty passList)
continue;
menu.AddItem(new GUIContent(customPassType.Name), false, () => {
- passList.serializedObject.Update();
+ passList.serializedObject.ApplyModifiedProperties();
m_Volume.AddPassOfType(customPassType);
UpdateMaterialEditors();
- passList.serializedObject.ApplyModifiedProperties();
+ passList.serializedObject.Update();
// Notify the prefab that something have changed:
PrefabUtility.RecordPrefabInstancePropertyModifications(target);
});
@@ -235,11 +237,25 @@ void CreateReorderableList(SerializedProperty passList)
};
m_CustomPassList.onRemoveCallback = (list) => {
- passList.serializedObject.Update();
+ passList.serializedObject.ApplyModifiedProperties();
Undo.RegisterCompleteObjectUndo(target, "Remove custom pass");
m_Volume.customPasses.RemoveAt(list.index);
UpdateMaterialEditors();
+ passList.serializedObject.Update();
+ // Notify the prefab that something have changed:
+ PrefabUtility.RecordPrefabInstancePropertyModifications(target);
+ };
+
+ m_CustomPassList.onReorderCallbackWithDetails = (list, oldIndex, newIndex) => {
+ customPassDrawers.Clear();
passList.serializedObject.ApplyModifiedProperties();
+ Undo.RegisterCompleteObjectUndo(target, "Reorder custom pass");
+
+ var t = m_Volume.customPasses[oldIndex];
+ m_Volume.customPasses[oldIndex] = m_Volume.customPasses[newIndex];
+ m_Volume.customPasses[newIndex] = t;
+
+ passList.serializedObject.Update();
// Notify the prefab that something have changed:
PrefabUtility.RecordPrefabInstancePropertyModifications(target);
};
diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs
index 50418520794..fbe26589dc7 100644
--- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs
@@ -57,6 +57,7 @@ public class GeneralSection
public static readonly GUIContent sampleCountQuality = EditorGUIUtility.TrTextContent("Sample Count");
public static readonly GUIContent resolutionQuality = EditorGUIUtility.TrTextContent("Resolution");
public static readonly GUIContent highQualityFiltering = EditorGUIUtility.TrTextContent("High Quality Filtering");
+ public static readonly GUIContent dofPhysicallyBased = EditorGUIUtility.TrTextContent("Physically Based");
public static readonly GUIContent maxSamplesQuality = EditorGUIUtility.TrTextContent("Max Samples");
public static readonly GUIContent SSAOQualitySettingSubTitle = EditorGUIUtility.TrTextContent("Screen Space Ambient Occlusion");
@@ -138,7 +139,10 @@ public class GeneralSection
public static readonly GUIContent cookieSizeContent = EditorGUIUtility.TrTextContent("Cookie Size", "Specifies the maximum size for the individual 2D cookies that HDRP uses for Directional and Spot Lights.");
public static readonly GUIContent cookieTextureArraySizeContent = EditorGUIUtility.TrTextContent("Texture Array Size", "Sets the maximum Texture Array size for the 2D cookies HDRP uses for Directional and Spot Lights. Higher values allow HDRP to use more cookies concurrently on screen.");
+#if UNITY_2020_1_OR_NEWER
+#else
public static readonly GUIContent pointCoockieSizeContent = EditorGUIUtility.TrTextContent("Point Cookie Size", "Specifies the maximum size for the Cube cookies HDRP uses for Point Lights.");
+#endif
public static readonly GUIContent pointCookieTextureArraySizeContent = EditorGUIUtility.TrTextContent("Cubemap Array Size", "Sets the maximum Texture Array size for the Cube cookies HDRP uses for Directional and Spot Lights. Higher values allow HDRP to use more cookies concurrently on screen.");
public static readonly GUIContent maxPlanarReflectionOnScreen = EditorGUIUtility.TrTextContent("Max Planar Reflection On Screen", "Sets the maximum number of the Planar Reflection HDRP can handle on screen at once.");
diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs
index d6cc7c9766b..b9c0361d084 100644
--- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs
@@ -242,7 +242,10 @@ static void Drawer_SectionCookies(SerializedHDRenderPipelineAsset serialized, Ed
if (EditorGUI.EndChangeCheck())
serialized.renderPipelineSettings.lightLoopSettings.cookieAtlasLastValidMip.intValue = Mathf.Clamp(serialized.renderPipelineSettings.lightLoopSettings.cookieAtlasLastValidMip.intValue, 0, Texture2DAtlas.maxMipLevelPadding);
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightLoopSettings.cookieFormat, Styles.cookieAtlasFormatContent);
+#if UNITY_2020_1_OR_NEWER
+#else
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightLoopSettings.pointCookieSize, Styles.pointCoockieSizeContent);
+#endif
EditorGUI.BeginChangeCheck();
}
@@ -596,6 +599,7 @@ static void DrawDepthOfFieldQualitySetting(SerializedHDRenderPipelineAsset seria
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.postProcessQualitySettings.DoFResolution.GetArrayElementAtIndex(tier), Styles.resolutionQuality);
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.postProcessQualitySettings.DoFHighFilteringQuality.GetArrayElementAtIndex(tier), Styles.highQualityFiltering);
+ EditorGUILayout.PropertyField(serialized.renderPipelineSettings.postProcessQualitySettings.DoFPhysicallyBased.GetArrayElementAtIndex(tier), Styles.dofPhysicallyBased);
--EditorGUI.indentLevel;
}
diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedGlobalLightLoopSettings.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedGlobalLightLoopSettings.cs
index 344000baf94..28ac5734030 100644
--- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedGlobalLightLoopSettings.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedGlobalLightLoopSettings.cs
@@ -10,7 +10,10 @@ class SerializedGlobalLightLoopSettings
public SerializedProperty cookieAtlasSize;
public SerializedProperty cookieFormat;
public SerializedProperty cookieAtlasLastValidMip;
+#if UNITY_2020_1_OR_NEWER
+#else
public SerializedProperty pointCookieSize;
+#endif
public SerializedProperty reflectionProbeCacheSize;
public SerializedProperty reflectionCubemapSize;
public SerializedProperty reflectionCacheCompressed;
@@ -32,7 +35,10 @@ public SerializedGlobalLightLoopSettings(SerializedProperty root)
cookieAtlasSize = root.Find((GlobalLightLoopSettings s) => s.cookieAtlasSize);
cookieFormat = root.Find((GlobalLightLoopSettings s) => s.cookieFormat);
cookieAtlasLastValidMip = root.Find((GlobalLightLoopSettings s) => s.cookieAtlasLastValidMip);
+#if UNITY_2020_1_OR_NEWER
+#else
pointCookieSize = root.Find((GlobalLightLoopSettings s) => s.pointCookieSize);
+#endif
reflectionProbeCacheSize = root.Find((GlobalLightLoopSettings s) => s.reflectionProbeCacheSize);
reflectionCubemapSize = root.Find((GlobalLightLoopSettings s) => s.reflectionCubemapSize);
diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedPostProcessingQualitySettings.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedPostProcessingQualitySettings.cs
index 7e6dcc327f8..c6ce192174c 100644
--- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedPostProcessingQualitySettings.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedPostProcessingQualitySettings.cs
@@ -14,6 +14,7 @@ class SerializedPostProcessingQualitySettings
public SerializedProperty FarBlurMaxRadius;
public SerializedProperty DoFResolution;
public SerializedProperty DoFHighFilteringQuality;
+ public SerializedProperty DoFPhysicallyBased;
// Motion Blur
public SerializedProperty MotionBlurSampleCount;
@@ -36,6 +37,7 @@ public SerializedPostProcessingQualitySettings(SerializedProperty root)
FarBlurMaxRadius = root.Find((GlobalPostProcessingQualitySettings s) => s.FarBlurMaxRadius);
DoFResolution = root.Find((GlobalPostProcessingQualitySettings s) => s.DoFResolution);
DoFHighFilteringQuality = root.Find((GlobalPostProcessingQualitySettings s) => s.DoFHighQualityFiltering);
+ DoFPhysicallyBased = root.Find((GlobalPostProcessingQualitySettings s) => s.DoFPhysicallyBased);
// Motion Blur
MotionBlurSampleCount = root.Find((GlobalPostProcessingQualitySettings s) => s.MotionBlurSampleCount);
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/OpaqueAtmosphericScattering.shader b/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/OpaqueAtmosphericScattering.shader
index eb004e6f66f..28dd942da11 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/OpaqueAtmosphericScattering.shader
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/OpaqueAtmosphericScattering.shader
@@ -63,7 +63,6 @@ Shader "Hidden/HDRP/OpaqueAtmosphericScattering"
float2 positionSS = input.positionCS.xy;
float3 V = GetSkyViewDirWS(positionSS);
float depth = LoadCameraDepth(positionSS);
- float3 surfColor = LOAD_TEXTURE2D_X(_ColorTexture, (int2)positionSS).rgb;
float3 volColor, volOpacity;
AtmosphericScatteringCompute(input, V, depth, volColor, volOpacity);
@@ -77,7 +76,6 @@ Shader "Hidden/HDRP/OpaqueAtmosphericScattering"
float2 positionSS = input.positionCS.xy;
float3 V = GetSkyViewDirWS(positionSS);
float depth = LOAD_TEXTURE2D_X_MSAA(_DepthTextureMS, (int2)positionSS, sampleIndex).x;
- float3 surfColor = LOAD_TEXTURE2D_X_MSAA(_ColorTextureMS, (int2)positionSS, sampleIndex).rgb;
float3 volColor, volOpacity;
AtmosphericScatteringCompute(input, V, depth, volColor, volOpacity);
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightCookieManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightCookieManager.cs
index 5832815bcf2..6ec4c4c7bb4 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightCookieManager.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightCookieManager.cs
@@ -36,7 +36,10 @@ class LightCookieManager
// Structure for cookies used by directional and spotlights
PowerOfTwoTextureAtlas m_CookieAtlas;
+#if UNITY_2020_1_OR_NEWER
+#else
int m_CookieCubeResolution;
+#endif
// During the light loop, when reserving space for the cookies (first part of the light loop) the atlas
// can run out of space, in this case, we set to true this flag which will trigger a re-layouting of the
@@ -64,7 +67,10 @@ public LightCookieManager(HDRenderPipelineAsset hdAsset, int maxCacheSize)
m_CookieAtlas = new PowerOfTwoTextureAtlas(cookieAtlasSize, gLightLoopSettings.cookieAtlasLastValidMip, cookieFormat, name: "Cookie Atlas (Punctual Lights)", useMipMap: true);
+#if UNITY_2020_1_OR_NEWER
+#else
m_CookieCubeResolution = (int)gLightLoopSettings.pointCookieSize;
+#endif
}
public void NewFrame()
@@ -303,7 +309,11 @@ public Vector4 FetchAreaCookie(CommandBuffer cmd, Texture cookie, Texture ies)
if (width < k_MinCookieSize || height < k_MinCookieSize)
return Vector4.zero;
- int projectionSize = 2*(int)Mathf.Max((float)m_CookieCubeResolution, Mathf.Max((float)cookie.width, (float)ies.width));
+#if UNITY_2020_1_OR_NEWER
+ int projectionSize = 2 * (int)Mathf.Max((float)cookie.width, (float)ies.width);
+#else
+ int projectionSize = 2 * (int)Mathf.Max((float)m_CookieCubeResolution, Mathf.Max((float)cookie.width, (float)ies.width));
+#endif
if (!m_CookieAtlas.IsCached(out var scaleBias, cookie, ies) && !m_NoMoreSpace)
Debug.LogError($"Area Light cookie texture {cookie} & {ies} can't be fetched without having reserved. You can try to increase the cookie atlas resolution in the HDRP settings.");
@@ -386,7 +396,11 @@ public Vector4 FetchCubeCookie(CommandBuffer cmd, Texture cookie)
Debug.Assert(cookie != null);
Debug.Assert(cookie.dimension == TextureDimension.Cube);
- int projectionSize = 2*(int)Mathf.Max((float)m_CookieCubeResolution, (float)cookie.width);
+#if UNITY_2020_1_OR_NEWER
+ int projectionSize = 2 * cookie.width;
+#else
+ int projectionSize = 2 * (int)Mathf.Max((float)m_CookieCubeResolution, (float)cookie.width);
+#endif
if (projectionSize < k_MinCookieSize)
return Vector4.zero;
@@ -411,7 +425,11 @@ public Vector4 FetchCubeCookie(CommandBuffer cmd, Texture cookie, Texture ies)
Debug.Assert(cookie.dimension == TextureDimension.Cube);
Debug.Assert(ies.dimension == TextureDimension.Cube);
- int projectionSize = 2*(int)Mathf.Max((float)m_CookieCubeResolution, (float)cookie.width);
+#if UNITY_2020_1_OR_NEWER
+ int projectionSize = 2 * cookie.width;
+#else
+ int projectionSize = 2 * (int)Mathf.Max((float)m_CookieCubeResolution, (float)cookie.width);
+#endif
if (projectionSize < k_MinCookieSize)
return Vector4.zero;
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/GlobalLightLoopSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/GlobalLightLoopSettings.cs
index 39522c8fa87..a644fae0248 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/GlobalLightLoopSettings.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/GlobalLightLoopSettings.cs
@@ -141,8 +141,11 @@ public struct GlobalLightLoopSettings
public CookieAtlasResolution cookieAtlasSize;
/// Cookie atlas graphics format.
public CookieAtlasGraphicsFormat cookieFormat;
+#if UNITY_2020_1_OR_NEWER
+#else
/// Cookie atlas resolution for point lights.
public CubeCookieResolution pointCookieSize;
+#endif
/// Last valid mip for cookie atlas.
public int cookieAtlasLastValidMip;
// We keep this property for the migration code (we need to know how many cookies we could have before).
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs
index 7db486cc8a8..6704448b584 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs
@@ -3717,7 +3717,7 @@ struct ContactShadowsParameters
public Vector4 params1;
public Vector4 params2;
- public int sampleCount;
+ public Vector4 params3;
public int numTilesX;
public int numTilesY;
@@ -3762,8 +3762,8 @@ ContactShadowsParameters PrepareContactShadowsParameters(HDCamera hdCamera, floa
float contactShadowFadeIn = Mathf.Clamp(m_ContactShadows.fadeInDistance.value, 1e-6f, contactShadowFadeEnd);
parameters.params1 = new Vector4(m_ContactShadows.length.value, m_ContactShadows.distanceScaleFactor.value, contactShadowFadeEnd, contactShadowOneOverFadeRange);
- parameters.params2 = new Vector4(firstMipOffsetY, contactShadowMinDist, contactShadowFadeIn, 0.0f);
- parameters.sampleCount = m_ContactShadows.sampleCount;
+ parameters.params2 = new Vector4(firstMipOffsetY, contactShadowMinDist, contactShadowFadeIn, m_ContactShadows.rayBias.value * 0.01f);
+ parameters.params3 = new Vector4(m_ContactShadows.sampleCount, m_ContactShadows.thicknessScale.value * 10.0f , 0.0f, 0.0f);
int deferredShadowTileSize = 16; // Must match DeferreDirectionalShadow.compute
parameters.numTilesX = (hdCamera.actualWidth + (deferredShadowTileSize - 1)) / deferredShadowTileSize;
@@ -3786,7 +3786,7 @@ static void RenderContactShadows( in ContactShadowsParameters parameters,
cmd.SetComputeVectorParam(parameters.contactShadowsCS, HDShaderIDs._ContactShadowParamsParameters, parameters.params1);
cmd.SetComputeVectorParam(parameters.contactShadowsCS, HDShaderIDs._ContactShadowParamsParameters2, parameters.params2);
- cmd.SetComputeIntParam(parameters.contactShadowsCS, HDShaderIDs._DirectionalContactShadowSampleCount, parameters.sampleCount);
+ cmd.SetComputeVectorParam(parameters.contactShadowsCS, HDShaderIDs._ContactShadowParamsParameters3, parameters.params3);
cmd.SetComputeBufferParam(parameters.contactShadowsCS, parameters.kernel, HDShaderIDs._DirectionalLightDatas, lightLoopLightData.directionalLightData);
// Send light list to the compute
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.RenderGraph.cs
index 51dc68f4f0f..31a19c957b1 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.RenderGraph.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.RenderGraph.cs
@@ -7,7 +7,7 @@ partial class AmbientOcclusionSystem
{
TextureHandle CreateAmbientOcclusionTexture(RenderGraph renderGraph)
{
- return renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true) { enableRandomWrite = true, colorFormat = GraphicsFormat.R8_UNorm, name = "Ambient Occlusion" }, HDShaderIDs._AmbientOcclusionTexture);
+ return renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true) { enableRandomWrite = true, colorFormat = GraphicsFormat.R8_UNorm, name = "Ambient Occlusion" });
}
public TextureHandle Render(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle depthPyramid, TextureHandle normalBuffer, TextureHandle motionVectors, int frameCount, in HDUtils.PackedMipChainInfo depthMipInfo)
@@ -33,12 +33,12 @@ public TextureHandle Render(RenderGraph renderGraph, HDCamera hdCamera, TextureH
var aoParameters = PrepareRenderAOParameters(hdCamera, historySize * rtScaleForHistory, frameCount, depthMipInfo);
var packedData = RenderAO(renderGraph, aoParameters, depthPyramid, normalBuffer);
- result = DenoiseAO(renderGraph, aoParameters, motionVectors, packedData, currentHistory, outputHistory);
+ result = DenoiseAO(renderGraph, aoParameters, depthPyramid, motionVectors, packedData, currentHistory, outputHistory);
}
}
else
{
- result = renderGraph.ImportTexture(TextureXR.GetBlackTexture(), HDShaderIDs._AmbientOcclusionTexture);
+ result = renderGraph.ImportTexture(TextureXR.GetBlackTexture());
}
return result;
}
@@ -88,6 +88,7 @@ class DenoiseAOPassData
TextureHandle DenoiseAO( RenderGraph renderGraph,
in RenderAOParameters parameters,
+ TextureHandle depthTexture,
TextureHandle motionVectors,
TextureHandle aoPackedData,
TextureHandle currentHistory,
@@ -129,6 +130,7 @@ TextureHandle DenoiseAO( RenderGraph renderGraph,
data.packedDataBlurred,
data.currentHistory,
data.outputHistory,
+ data.motionVectors,
data.denoiseOutput,
ctx.cmd);
});
@@ -137,17 +139,18 @@ TextureHandle DenoiseAO( RenderGraph renderGraph,
return passData.denoiseOutput;
}
- return UpsampleAO(renderGraph, parameters, denoiseOutput);
+ return UpsampleAO(renderGraph, parameters, denoiseOutput, depthTexture);
}
class UpsampleAOPassData
{
public RenderAOParameters parameters;
+ public TextureHandle depthTexture;
public TextureHandle input;
public TextureHandle output;
}
- TextureHandle UpsampleAO(RenderGraph renderGraph, in RenderAOParameters parameters, TextureHandle input)
+ TextureHandle UpsampleAO(RenderGraph renderGraph, in RenderAOParameters parameters, TextureHandle input, TextureHandle depthTexture)
{
using (var builder = renderGraph.AddRenderPass("Upsample GTAO", out var passData, ProfilingSampler.Get(HDProfileId.UpSampleSSAO)))
{
@@ -155,12 +158,13 @@ TextureHandle UpsampleAO(RenderGraph renderGraph, in RenderAOParameters paramete
passData.parameters = parameters;
passData.input = builder.ReadTexture(input);
+ passData.depthTexture = builder.ReadTexture(depthTexture);
passData.output = builder.WriteTexture(CreateAmbientOcclusionTexture(renderGraph));
builder.SetRenderFunc(
(UpsampleAOPassData data, RenderGraphContext ctx) =>
{
- UpsampleAO(data.parameters, data.input, data.output, ctx.cmd);
+ UpsampleAO(data.parameters, data.depthTexture, data.input, data.output, ctx.cmd);
});
return passData.output;
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.cs
index c0f3f1cca03..8e8a6cd763f 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.cs
@@ -299,7 +299,7 @@ internal void InitRaytracing(HDRenderPipeline renderPipeline)
internal bool IsActive(HDCamera camera, AmbientOcclusion settings) => camera.frameSettings.IsEnabled(FrameSettingsField.SSAO) && settings.intensity.value > 0f;
- internal void Render(CommandBuffer cmd, HDCamera camera, ScriptableRenderContext renderContext, RTHandle depthTexture, RTHandle normalBuffer, in ShaderVariablesRaytracing globalRTCB, int frameCount)
+ internal void Render(CommandBuffer cmd, HDCamera camera, ScriptableRenderContext renderContext, RTHandle depthTexture, RTHandle normalBuffer, RTHandle motionVectors, in ShaderVariablesRaytracing globalRTCB, int frameCount)
{
var settings = camera.volumeStack.GetComponent();
@@ -314,7 +314,7 @@ internal void Render(CommandBuffer cmd, HDCamera camera, ScriptableRenderContext
m_RaytracingAmbientOcclusion.RenderAO(camera, cmd, m_AmbientOcclusionTex, globalRTCB, renderContext, frameCount);
else
{
- Dispatch(cmd, camera, depthTexture, normalBuffer, frameCount);
+ Dispatch(cmd, camera, depthTexture, normalBuffer, motionVectors, frameCount);
PostDispatchWork(cmd, camera);
}
}
@@ -516,6 +516,7 @@ static void DenoiseAO( in RenderAOParameters parameters,
RTHandle packedDataBlurredTex,
RTHandle packedHistoryTex,
RTHandle packedHistoryOutputTex,
+ RTHandle motionVectors,
RTHandle aoOutputTex,
CommandBuffer cmd)
{
@@ -560,12 +561,14 @@ static void DenoiseAO( in RenderAOParameters parameters,
cmd.SetComputeTextureParam(blurCS, parameters.denoiseKernelTemporal, HDShaderIDs._AOPackedBlurred, packedDataBlurredTex);
cmd.SetComputeTextureParam(blurCS, parameters.denoiseKernelTemporal, HDShaderIDs._AOPackedHistory, packedHistoryTex);
cmd.SetComputeTextureParam(blurCS, parameters.denoiseKernelTemporal, HDShaderIDs._AOOutputHistory, packedHistoryOutputTex);
+ cmd.SetComputeTextureParam(blurCS, parameters.denoiseKernelTemporal, HDShaderIDs._CameraMotionVectorsTexture, motionVectors);
cmd.SetComputeTextureParam(blurCS, parameters.denoiseKernelTemporal, HDShaderIDs._OcclusionTexture, aoOutputTex);
cmd.DispatchCompute(blurCS, parameters.denoiseKernelTemporal, threadGroupX, threadGroupY, parameters.viewCount);
}
}
static void UpsampleAO( in RenderAOParameters parameters,
+ RTHandle depthTexture,
RTHandle input,
RTHandle output,
CommandBuffer cmd)
@@ -578,6 +581,7 @@ static void UpsampleAO( in RenderAOParameters parameters,
{
cmd.SetComputeTextureParam(parameters.upsampleAndBlurAOCS, parameters.upsampleAndBlurKernel, HDShaderIDs._AOPackedData, input);
cmd.SetComputeTextureParam(parameters.upsampleAndBlurAOCS, parameters.upsampleAndBlurKernel, HDShaderIDs._OcclusionTexture, output);
+ cmd.SetComputeTextureParam(parameters.upsampleAndBlurAOCS, parameters.upsampleAndBlurKernel, HDShaderIDs._CameraDepthTexture, depthTexture);
const int groupSizeX = 8;
const int groupSizeY = 8;
@@ -590,6 +594,7 @@ static void UpsampleAO( in RenderAOParameters parameters,
{
cmd.SetComputeTextureParam(parameters.upsampleAndBlurAOCS, parameters.upsampleAOKernel, HDShaderIDs._AOPackedData, input);
cmd.SetComputeTextureParam(parameters.upsampleAndBlurAOCS, parameters.upsampleAOKernel, HDShaderIDs._OcclusionTexture, output);
+ cmd.SetComputeTextureParam(parameters.upsampleAndBlurAOCS, parameters.upsampleAOKernel, HDShaderIDs._CameraDepthTexture, depthTexture);
const int groupSizeX = 8;
const int groupSizeY = 8;
@@ -599,7 +604,7 @@ static void UpsampleAO( in RenderAOParameters parameters,
}
}
- internal void Dispatch(CommandBuffer cmd, HDCamera camera, RTHandle depthTexture, RTHandle normalBuffer, int frameCount)
+ internal void Dispatch(CommandBuffer cmd, HDCamera camera, RTHandle depthTexture, RTHandle normalBuffer, RTHandle motionVectors, int frameCount)
{
var settings = camera.volumeStack.GetComponent();
if (IsActive(camera, settings))
@@ -625,14 +630,14 @@ internal void Dispatch(CommandBuffer cmd, HDCamera camera, RTHandle depthTexture
using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.DenoiseSSAO)))
{
var output = m_RunningFullRes ? m_AmbientOcclusionTex : m_FinalHalfRes;
- DenoiseAO(aoParameters, m_PackedDataTex, m_PackedDataBlurred, currentHistory, historyOutput, output, cmd);
+ DenoiseAO(aoParameters, m_PackedDataTex, m_PackedDataBlurred, currentHistory, historyOutput, motionVectors, output, cmd);
}
if (!m_RunningFullRes)
{
using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.UpSampleSSAO)))
{
- UpsampleAO(aoParameters, settings.temporalAccumulation.value ? m_FinalHalfRes : m_PackedDataTex, m_AmbientOcclusionTex, cmd);
+ UpsampleAO(aoParameters, depthTexture, settings.temporalAccumulation.value ? m_FinalHalfRes : m_PackedDataTex, m_AmbientOcclusionTex, cmd);
}
}
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.compute b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.compute
index 98ac679de1f..9d4fa8e4904 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.compute
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.compute
@@ -41,6 +41,16 @@ float SampleDepth(float2 UV, bool HalfRes)
return LoadCameraDepth(pixelCoord);
}
+float GetDepthCompareThreshold(float step, float rayStartZ, float rayOrthoZ)
+{
+ return abs(rayOrthoZ - rayStartZ) * _ContactShadowThickness * max(0.07, step);
+}
+
+bool CompareDepth(float depthDiff, float compareThreshold)
+{
+ return abs(compareThreshold - depthDiff) < compareThreshold;
+}
+
bool ScreenSpaceShadowRayCast(float3 positionWS, float3 rayDirWS, float rayLength, uint2 positionSS, out float fade)
{
@@ -50,7 +60,7 @@ bool ScreenSpaceShadowRayCast(float3 positionWS, float3 rayDirWS, float rayLengt
uint taaEnabled = _TaaFrameInfo.w;
float dither = InterleavedGradientNoise(positionSS, (_FrameCount % 8u) * taaEnabled) - ditherBias;
- float3 rayStartWS = positionWS;
+ float3 rayStartWS = positionWS - positionWS * _ContactShadowBias;
float3 rayEndWS = rayStartWS + rayDirWS * rayLength;
float4 rayStartCS = TransformWorldToHClip(rayStartWS);
@@ -68,7 +78,7 @@ bool ScreenSpaceShadowRayCast(float3 positionWS, float3 rayDirWS, float rayLengt
float3 rayDirCS = rayEndCS.xyz - rayStartCS.xyz;
float step = 1.0f / _SampleCount;
- float compareThreshold = abs(rayOrthoViewSpace.z - rayStartCS.z) * max(0.07f, step);
+ float compareThreshold = GetDepthCompareThreshold(step, rayStartCS.z, rayOrthoViewSpace.z);
float occluded = 0.0f;
@@ -107,7 +117,7 @@ bool ScreenSpaceShadowRayCast(float3 positionWS, float3 rayDirWS, float rayLengt
float depthDiff = sampleDepth - sampleAlongRay.z;
- if (depthDiff > 0.0f && depthDiff < compareThreshold && sampleAlongRay.z > 0)
+ if (depthDiff > 0.0f && CompareDepth(depthDiff, compareThreshold) && sampleAlongRay.z > 0)
{
if (tracingHalfRes)
{
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.cs
index f2da6428bbe..fb7ecc2573a 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.cs
@@ -43,8 +43,16 @@ public class ContactShadows : VolumeComponentWithQuality
///
public MinFloatParameter fadeInDistance = new MinFloatParameter(0.0f, 0.0f);
///
- /// Controls the number of samples HDRP takes along each contact shadow ray. Increasing this value can lead to higher quality.
+ /// Controls the bias applied to the screen space ray cast to get contact shadows.
///
+ public ClampedFloatParameter rayBias = new ClampedFloatParameter(0.2f, 0.0f, 1.0f);
+ ///
+ /// Controls the thickness of the objects found along the ray, essentially thickening the contact shadows.
+ ///
+ public ClampedFloatParameter thicknessScale = new ClampedFloatParameter(0.15f, 0.02f, 1.0f);
+
+
+
public int sampleCount
{
get
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.hlsl
index f5f01cb67a9..73949525b49 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.hlsl
@@ -3,6 +3,7 @@ RW_TEXTURE2D_X(uint, _ContactShadowTextureUAV);
CBUFFER_START(DeferredShadowParameters)
float4 _ContactShadowParamsParameters;
float4 _ContactShadowParamsParameters2;
+float4 _ContactShadowParamsParameters3;
int _SampleCount;
CBUFFER_END
@@ -13,3 +14,6 @@ CBUFFER_END
#define _RenderTargetHeight _ContactShadowParamsParameters2.x
#define _ContactShadowMinDistance _ContactShadowParamsParameters2.y
#define _ContactShadowFadeInEnd _ContactShadowParamsParameters2.z
+#define _ContactShadowBias _ContactShadowParamsParameters2.w
+#define _SampleCount (int)_ContactShadowParamsParameters3.x
+#define _ContactShadowThickness _ContactShadowParamsParameters3.y
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.RenderGraph.cs
index c0ae47a28b5..c22bc4b2499 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.RenderGraph.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.RenderGraph.cs
@@ -100,10 +100,10 @@ class RenderShadowsPassData
public ShadowDrawingSettings shadowDrawSettings;
}
- TextureHandle AllocateMomentAtlas(RenderGraph renderGraph, string name, int shaderID = 0)
+ TextureHandle AllocateMomentAtlas(RenderGraph renderGraph, string name)
{
return renderGraph.CreateTexture(new TextureDesc(width / 2, height / 2)
- { colorFormat = GraphicsFormat.R32G32_SFloat, useMipMap = true, autoGenerateMips = false, name = name, enableRandomWrite = true }, shaderID);
+ { colorFormat = GraphicsFormat.R32G32_SFloat, useMipMap = true, autoGenerateMips = false, name = name, enableRandomWrite = true });
}
internal TextureHandle RenderShadows(RenderGraph renderGraph, CullingResults cullResults, in ShaderVariablesGlobal globalCB, FrameSettings frameSettings, string shadowPassName)
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitPathTracing.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitPathTracing.hlsl
index b10668cf278..3ec50c5253f 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitPathTracing.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitPathTracing.hlsl
@@ -118,7 +118,7 @@ bool CreateMaterialData(PathIntersection pathIntersection, BuiltinData builtinDa
// Otherwise, we just compute BSDFs as usual
mtlData.subsurfaceWeightFactor = 1.0 - subsurfaceWeight;
- mtlData.bsdfWeight[0] -= subsurfaceWeight;
+ mtlData.bsdfWeight[0] = max(mtlData.bsdfWeight[0] - subsurfaceWeight, BSDF_WEIGHT_EPSILON);
mtlData.bsdfWeight /= mtlData.subsurfaceWeightFactor;
sample -= subsurfaceWeight;
@@ -147,8 +147,7 @@ bool SampleMaterial(MaterialData mtlData, float3 inputSample, out float3 sampleD
if (!BRDF::SampleLambert(mtlData, inputSample, sampleDir, result.diffValue, result.diffPdf))
return false;
- result.diffValue *= mtlData.bsdfData.ambientOcclusion * mtlData.bsdfData.subsurfaceMask * (1.0 - mtlData.bsdfData.transmittanceMask);
- result.diffPdf *= mtlData.subsurfaceWeightFactor;
+ result.diffValue *= mtlData.bsdfData.ambientOcclusion * (1.0 - mtlData.bsdfData.transmittanceMask);
return true;
}
@@ -175,7 +174,7 @@ bool SampleMaterial(MaterialData mtlData, float3 inputSample, out float3 sampleD
result.specPdf += mtlData.bsdfWeight[1] * pdf;
}
- result.diffValue *= mtlData.bsdfData.ambientOcclusion * (1.0 - mtlData.bsdfData.subsurfaceMask) * (1.0 - mtlData.bsdfData.transmittanceMask) * (1.0 - fresnelClearCoat);
+ result.diffValue *= mtlData.bsdfData.ambientOcclusion * (1.0 - mtlData.bsdfData.transmittanceMask) * (1.0 - fresnelClearCoat);
if (mtlData.bsdfWeight[2] > BSDF_WEIGHT_EPSILON)
{
@@ -196,7 +195,7 @@ bool SampleMaterial(MaterialData mtlData, float3 inputSample, out float3 sampleD
if (mtlData.bsdfWeight[0] > BSDF_WEIGHT_EPSILON)
{
BRDF::EvaluateDiffuse(mtlData, sampleDir, result.diffValue, result.diffPdf);
- result.diffValue *= mtlData.bsdfData.ambientOcclusion * (1.0 - mtlData.bsdfData.subsurfaceMask) * (1.0 - mtlData.bsdfData.transmittanceMask) * (1.0 - fresnelClearCoat);
+ result.diffValue *= mtlData.bsdfData.ambientOcclusion * (1.0 - mtlData.bsdfData.transmittanceMask) * (1.0 - fresnelClearCoat);
result.diffPdf *= mtlData.bsdfWeight[0];
}
@@ -226,7 +225,7 @@ bool SampleMaterial(MaterialData mtlData, float3 inputSample, out float3 sampleD
if (mtlData.bsdfWeight[0] > BSDF_WEIGHT_EPSILON)
{
BRDF::EvaluateDiffuse(mtlData, sampleDir, result.diffValue, result.diffPdf);
- result.diffValue *= mtlData.bsdfData.ambientOcclusion * (1.0 - mtlData.bsdfData.subsurfaceMask) * (1.0 - mtlData.bsdfData.transmittanceMask) * (1.0 - fresnelClearCoat);
+ result.diffValue *= mtlData.bsdfData.ambientOcclusion * (1.0 - mtlData.bsdfData.transmittanceMask) * (1.0 - fresnelClearCoat);
result.diffPdf *= mtlData.bsdfWeight[0];
}
}
@@ -248,8 +247,8 @@ bool SampleMaterial(MaterialData mtlData, float3 inputSample, out float3 sampleD
#endif
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
- result.diffPdf *= mtlData.subsurfaceWeightFactor;
- result.specPdf *= mtlData.subsurfaceWeightFactor;
+ // We compensate for the fact that there is no spec when computing SSS
+ result.specValue /= mtlData.subsurfaceWeightFactor;
#endif
}
else // Below
@@ -295,8 +294,7 @@ void EvaluateMaterial(MaterialData mtlData, float3 sampleDir, out MaterialResult
if (mtlData.isSubsurface)
{
BRDF::EvaluateLambert(mtlData, sampleDir, result.diffValue, result.diffPdf);
- result.diffValue *= mtlData.bsdfData.subsurfaceMask * (1.0 - mtlData.bsdfData.transmittanceMask); // AO purposedly ignored here
- result.diffPdf *= mtlData.subsurfaceWeightFactor;
+ result.diffValue *= 1.0 - mtlData.bsdfData.transmittanceMask; // AO purposedly ignored here
return;
}
@@ -319,7 +317,7 @@ void EvaluateMaterial(MaterialData mtlData, float3 sampleDir, out MaterialResult
if (mtlData.bsdfWeight[0] > BSDF_WEIGHT_EPSILON)
{
BRDF::EvaluateDiffuse(mtlData, sampleDir, result.diffValue, result.diffPdf);
- result.diffValue *= (1.0 - mtlData.bsdfData.transmittanceMask) * (1.0 - mtlData.bsdfData.subsurfaceMask) * (1.0 - fresnelClearCoat); // AO purposedly ignored here
+ result.diffValue *= (1.0 - mtlData.bsdfData.transmittanceMask) * (1.0 - fresnelClearCoat); // AO purposedly ignored here
result.diffPdf *= mtlData.bsdfWeight[0];
}
@@ -331,8 +329,8 @@ void EvaluateMaterial(MaterialData mtlData, float3 sampleDir, out MaterialResult
}
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
- result.diffPdf *= mtlData.subsurfaceWeightFactor;
- result.specPdf *= mtlData.subsurfaceWeightFactor;
+ // We compensate for the fact that there is no spec when computing SSS
+ result.specValue /= mtlData.subsurfaceWeightFactor;
#endif
}
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/DepthOfField.cs b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/DepthOfField.cs
index 5969c50c4de..1961830c0bd 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/DepthOfField.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/DepthOfField.cs
@@ -204,6 +204,23 @@ public bool highQualityFiltering
set { m_HighQualityFiltering.value = value; }
}
+ public bool physicallyBased
+ {
+ get
+ {
+ if (!UsesQualitySettings())
+ {
+ return m_PhysicallyBased.value;
+ }
+ else
+ {
+ int qualityLevel = (int)quality.levelAndOverride.level;
+ return GetPostProcessingQualitySettings().DoFPhysicallyBased[qualityLevel];
+ }
+ }
+ set { m_PhysicallyBased.value = value; }
+ }
+
///
/// Specifies the resolution at which HDRP processes the depth of field effect.
///
@@ -257,6 +274,9 @@ public DepthOfFieldResolution resolution
[SerializeField, FormerlySerializedAs("resolution")]
DepthOfFieldResolutionParameter m_Resolution = new DepthOfFieldResolutionParameter(DepthOfFieldResolution.Half);
+ [SerializeField]
+ BoolParameter m_PhysicallyBased = new BoolParameter(false);
+
///
/// Tells if the effect needs to be rendered or not.
///
diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs
index f95108fcf97..ea923f258af 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs
@@ -601,6 +601,8 @@ void PoolSource(ref RTHandle src, RTHandle dst)
}
}
+ bool postDoFTAAEnabled = false;
+
// If Path tracing is enabled, then DoF is computed in the path tracer by sampling the lens aperure (when using the physical camera mode)
bool isDoFPathTraced = (camera.frameSettings.IsEnabled(FrameSettingsField.RayTracing) &&
camera.volumeStack.GetComponent().enable.value &&
@@ -614,11 +616,32 @@ void PoolSource(ref RTHandle src, RTHandle dst)
using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.DepthOfField)))
{
var destination = m_Pool.Get(Vector2.one, m_ColorFormat);
- DoDepthOfField(cmd, camera, source, destination, taaEnabled);
+ if (!m_DepthOfField.physicallyBased)
+ DoDepthOfField(cmd, camera, source, destination, taaEnabled);
+ else
+ DoPhysicallyBasedDepthOfField(cmd, camera, source, destination, taaEnabled);
PoolSource(ref source, destination);
+
+ // When physically based DoF is enabled, TAA runs two times, first to stabilize the color buffer before DoF and then after DoF to accumulate more aperture samples
+ if (taaEnabled && m_DepthOfField.physicallyBased)
+ {
+ var taaDestination = m_Pool.Get(Vector2.one, m_ColorFormat);
+ bool postDof = true;
+ var taaParams = PrepareTAAParameters(camera, postDof);
+
+ GrabTemporalAntialiasingHistoryTextures(camera, out var prevHistory, out var nextHistory, postDof);
+ DoTemporalAntialiasing(taaParams, cmd, source, taaDestination, motionVecTexture, depthBuffer, depthMipChain, prevHistory, nextHistory, prevMVLen:null, nextMVLen:null);
+ PoolSource(ref source, taaDestination);
+ postDoFTAAEnabled = true;
+ }
}
}
+ if (!postDoFTAAEnabled)
+ {
+ ReleasePostDoFTAAHistoryTextures(camera);
+ }
+
// Motion blur after depth of field for aesthetic reasons (better to see motion
// blurred bokeh rather than out of focus motion blur)
if (m_MotionBlur.IsActive() && m_AnimatedMaterialsEnabled && !camera.resetPostProcessingHistory && m_MotionBlurFS)
@@ -1437,7 +1460,7 @@ struct TemporalAntiAliasingParameters
public Vector4 taaFilterWeights;
}
- TemporalAntiAliasingParameters PrepareTAAParameters(HDCamera camera)
+ TemporalAntiAliasingParameters PrepareTAAParameters(HDCamera camera, bool PostDOF = false)
{
TemporalAntiAliasingParameters parameters = new TemporalAntiAliasingParameters();
@@ -1450,7 +1473,7 @@ TemporalAntiAliasingParameters PrepareTAAParameters(HDCamera camera)
// The anti flicker becomes much more aggressive on higher values
float temporalContrastForMaxAntiFlicker = 0.7f - Mathf.Lerp(0.0f, 0.3f, Mathf.SmoothStep(0.5f, 1.0f, camera.taaAntiFlicker));
- parameters.taaParameters = new Vector4(camera.taaHistorySharpening, Mathf.Lerp(minAntiflicker, maxAntiflicker, camera.taaAntiFlicker), motionRejectionMultiplier, temporalContrastForMaxAntiFlicker);
+ parameters.taaParameters = new Vector4(camera.taaHistorySharpening, PostDOF ? maxAntiflicker : Mathf.Lerp(minAntiflicker, maxAntiflicker, camera.taaAntiFlicker), motionRejectionMultiplier, temporalContrastForMaxAntiFlicker);
// Precompute weights used for the Blackman-Harris filter. TODO: Note that these are slightly wrong as they don't take into account the jitter size. This needs to be fixed at some point.
float crossWeights = Mathf.Exp(-2.29f * 2);
@@ -1489,20 +1512,27 @@ TemporalAntiAliasingParameters PrepareTAAParameters(HDCamera camera)
parameters.temporalAAMaterial.EnableKeyword("ENABLE_MV_REJECTION");
}
- switch (camera.TAAQuality)
+ if (PostDOF)
{
- case HDAdditionalCameraData.TAAQualityLevel.Low:
- parameters.temporalAAMaterial.EnableKeyword("LOW_QUALITY");
- break;
- case HDAdditionalCameraData.TAAQualityLevel.Medium:
- parameters.temporalAAMaterial.EnableKeyword("MEDIUM_QUALITY");
- break;
- case HDAdditionalCameraData.TAAQualityLevel.High:
- parameters.temporalAAMaterial.EnableKeyword("HIGH_QUALITY");
- break;
- default:
- parameters.temporalAAMaterial.EnableKeyword("MEDIUM_QUALITY");
- break;
+ parameters.temporalAAMaterial.EnableKeyword("POST_DOF");
+ }
+ else
+ {
+ switch (camera.TAAQuality)
+ {
+ case HDAdditionalCameraData.TAAQualityLevel.Low:
+ parameters.temporalAAMaterial.EnableKeyword("LOW_QUALITY");
+ break;
+ case HDAdditionalCameraData.TAAQualityLevel.Medium:
+ parameters.temporalAAMaterial.EnableKeyword("MEDIUM_QUALITY");
+ break;
+ case HDAdditionalCameraData.TAAQualityLevel.High:
+ parameters.temporalAAMaterial.EnableKeyword("HIGH_QUALITY");
+ break;
+ default:
+ parameters.temporalAAMaterial.EnableKeyword("MEDIUM_QUALITY");
+ break;
+ }
}
parameters.taaHistoryPropertyBlock = m_TAAHistoryBlitPropertyBlock;
@@ -1538,7 +1568,10 @@ static void DoTemporalAntialiasing(in TemporalAntiAliasingParameters taaParams,
taaParams.taaPropertyBlock.SetTexture(HDShaderIDs._CameraMotionVectorsTexture, motionVecTexture);
taaParams.taaPropertyBlock.SetTexture(HDShaderIDs._InputTexture, source);
taaParams.taaPropertyBlock.SetTexture(HDShaderIDs._InputHistoryTexture, prevHistory);
- taaParams.taaPropertyBlock.SetTexture(HDShaderIDs._InputVelocityMagnitudeHistory, prevMVLen);
+ if (prevMVLen != null)
+ {
+ taaParams.taaPropertyBlock.SetTexture(HDShaderIDs._InputVelocityMagnitudeHistory, prevMVLen);
+ }
taaParams.taaPropertyBlock.SetTexture(HDShaderIDs._DepthTexture, depthMipChain);
@@ -1552,13 +1585,17 @@ static void DoTemporalAntialiasing(in TemporalAntiAliasingParameters taaParams,
CoreUtils.SetRenderTarget(cmd, destination, depthBuffer);
cmd.SetRandomWriteTarget(1, nextHistory);
- cmd.SetRandomWriteTarget(2, nextMVLen);
+ if (nextMVLen != null)
+ {
+ cmd.SetRandomWriteTarget(2, nextMVLen);
+ }
+
cmd.DrawProcedural(Matrix4x4.identity, taaParams.temporalAAMaterial, 0, MeshTopology.Triangles, 3, 1, taaParams.taaPropertyBlock);
cmd.DrawProcedural(Matrix4x4.identity, taaParams.temporalAAMaterial, 1, MeshTopology.Triangles, 3, 1, taaParams.taaPropertyBlock);
cmd.ClearRandomWriteTargets();
}
- void GrabTemporalAntialiasingHistoryTextures(HDCamera camera, out RTHandle previous, out RTHandle next)
+ void GrabTemporalAntialiasingHistoryTextures(HDCamera camera, out RTHandle previous, out RTHandle next, bool postDoF = false)
{
RTHandle Allocator(string id, int frameIndex, RTHandleSystem rtHandleSystem)
{
@@ -1569,9 +1606,12 @@ RTHandle Allocator(string id, int frameIndex, RTHandleSystem rtHandleSystem)
);
}
- next = camera.GetCurrentFrameRT((int)HDCameraFrameHistoryType.TemporalAntialiasing)
- ?? camera.AllocHistoryFrameRT((int)HDCameraFrameHistoryType.TemporalAntialiasing, Allocator, 2);
- previous = camera.GetPreviousFrameRT((int)HDCameraFrameHistoryType.TemporalAntialiasing);
+ int historyType = (int)(postDoF ?
+ HDCameraFrameHistoryType.TemporalAntialiasingPostDoF : HDCameraFrameHistoryType.TemporalAntialiasing);
+
+ next = camera.GetCurrentFrameRT(historyType)
+ ?? camera.AllocHistoryFrameRT(historyType, Allocator, 2);
+ previous = camera.GetPreviousFrameRT(historyType);
}
void GrabVelocityMagnitudeHistoryTextures(HDCamera camera, out RTHandle previous, out RTHandle next)
@@ -1589,6 +1629,15 @@ RTHandle Allocator(string id, int frameIndex, RTHandleSystem rtHandleSystem)
?? camera.AllocHistoryFrameRT((int)HDCameraFrameHistoryType.TAAMotionVectorMagnitude, Allocator, 2);
previous = camera.GetPreviousFrameRT((int)HDCameraFrameHistoryType.TAAMotionVectorMagnitude);
}
+
+ void ReleasePostDoFTAAHistoryTextures(HDCamera camera)
+ {
+ var rt = camera.GetCurrentFrameRT((int)HDCameraFrameHistoryType.TemporalAntialiasingPostDoF);
+ if (rt != null)
+ {
+ camera.ReleaseHistoryFrameRT((int)HDCameraFrameHistoryType.TemporalAntialiasingPostDoF);
+ }
+ }
#endregion
#region Depth Of Field
@@ -1765,21 +1814,8 @@ void DoDepthOfField(CommandBuffer cmd, HDCamera camera, RTHandle source, RTHandl
if (taaEnabled)
{
- GrabCoCHistory(camera, out var prevCoCTex, out var nextCoCTex);
- cocHistoryScale = new Vector2(camera.historyRTHandleProperties.rtHandleScale.z, camera.historyRTHandleProperties.rtHandleScale.w);
-
- cs = m_Resources.shaders.depthOfFieldCoCReprojectCS;
- kernel = cs.FindKernel("KMain");
- cmd.SetComputeVectorParam(cs, HDShaderIDs._Params, new Vector4(camera.resetPostProcessingHistory ? 0f : 0.91f, cocHistoryScale.x, cocHistoryScale.y, 0f));
- cmd.SetComputeTextureParam(cs, kernel, HDShaderIDs._InputCoCTexture, fullresCoC);
- cmd.SetComputeTextureParam(cs, kernel, HDShaderIDs._InputHistoryCoCTexture, prevCoCTex);
- cmd.SetComputeTextureParam(cs, kernel, HDShaderIDs._OutputCoCTexture, nextCoCTex);
- cmd.DispatchCompute(cs, kernel, (camera.actualWidth + 7) / 8, (camera.actualHeight + 7) / 8, camera.viewCount);
-
- // Cleanup the main CoC texture as we don't need it anymore and use the
- // re-projected one instead for the following steps
- m_Pool.Recycle(fullresCoC);
- fullresCoC = nextCoCTex;
+ bool useMips = false;
+ ReprojectCoCHistory(cmd, camera, useMips, ref fullresCoC);
}
m_HDInstance.PushFullScreenDebugTexture(camera, cmd, fullresCoC, FullScreenDebugMode.DepthOfFieldCoc);
@@ -2201,21 +2237,48 @@ void DoDepthOfField(CommandBuffer cmd, HDCamera camera, RTHandle source, RTHandl
m_Pool.Recycle(fullresCoC); // Already cleaned up if TAA is enabled
}
- static void GrabCoCHistory(HDCamera camera, out RTHandle previous, out RTHandle next)
+ static void GrabCoCHistory(HDCamera camera, out RTHandle previous, out RTHandle next, bool useMips = false)
{
RTHandle Allocator(string id, int frameIndex, RTHandleSystem rtHandleSystem)
{
return rtHandleSystem.Alloc(
Vector2.one, TextureXR.slices, DepthBits.None, GraphicsFormat.R16_SFloat,
- dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, name: $"{id} CoC History"
+ dimension: TextureXR.dimension, enableRandomWrite: true, useMipMap:useMips, useDynamicScale: true, name: $"{id} CoC History"
);
}
next = camera.GetCurrentFrameRT((int)HDCameraFrameHistoryType.DepthOfFieldCoC)
?? camera.AllocHistoryFrameRT((int)HDCameraFrameHistoryType.DepthOfFieldCoC, Allocator, 2);
+
+ if (useMips == true && next.rt.mipmapCount == 1)
+ {
+ camera.ReleaseHistoryFrameRT((int)HDCameraFrameHistoryType.DepthOfFieldCoC);
+ next = camera.AllocHistoryFrameRT((int)HDCameraFrameHistoryType.DepthOfFieldCoC, Allocator, 2);
+ }
+
previous = camera.GetPreviousFrameRT((int)HDCameraFrameHistoryType.DepthOfFieldCoC);
}
+ void ReprojectCoCHistory(CommandBuffer cmd, HDCamera camera, bool useMips, ref RTHandle fullresCoC)
+ {
+ GrabCoCHistory(camera, out var prevCoCTex, out var nextCoCTex, useMips);
+ var cocHistoryScale = new Vector2(camera.historyRTHandleProperties.rtHandleScale.z, camera.historyRTHandleProperties.rtHandleScale.w);
+
+ //Note: this reprojection creates some ghosting, we should replace it with something based on the new TAA
+ ComputeShader cs = m_Resources.shaders.depthOfFieldCoCReprojectCS;
+ int kernel = cs.FindKernel("KMain");
+ cmd.SetComputeVectorParam(cs, HDShaderIDs._Params, new Vector4(camera.resetPostProcessingHistory ? 0f : 0.91f, cocHistoryScale.x, cocHistoryScale.y, 0f));
+ cmd.SetComputeTextureParam(cs, kernel, HDShaderIDs._InputCoCTexture, fullresCoC);
+ cmd.SetComputeTextureParam(cs, kernel, HDShaderIDs._InputHistoryCoCTexture, prevCoCTex);
+ cmd.SetComputeTextureParam(cs, kernel, HDShaderIDs._OutputCoCTexture, nextCoCTex);
+ cmd.DispatchCompute(cs, kernel, (camera.actualWidth + 7) / 8, (camera.actualHeight + 7) / 8, camera.viewCount);
+
+ // Cleanup the main CoC texture as we don't need it anymore and use the
+ // re-projected one instead for the following steps
+ m_Pool.Recycle(fullresCoC);
+ fullresCoC = nextCoCTex;
+ }
+
#endregion
#region Depth Of Field (Physically based)
@@ -2229,7 +2292,7 @@ void DoPhysicallyBasedDepthOfField(CommandBuffer cmd, HDCamera camera, RTHandle
// Map the old "max radius" parameters to a bigger range, so we can work on more challenging scenes
float maxRadius = Mathf.Max(m_DepthOfField.farMaxBlur, m_DepthOfField.nearMaxBlur);
- float cocLimit = Mathf.Clamp(2 * maxRadius, 1, 32);
+ float cocLimit = Mathf.Clamp(4 * maxRadius, 1, 32);
ComputeShader cs;
int kernel;
@@ -2271,11 +2334,18 @@ void DoPhysicallyBasedDepthOfField(CommandBuffer cmd, HDCamera camera, RTHandle
float nearStart = Mathf.Min(m_DepthOfField.nearFocusStart.value, nearEnd - 1e-5f);
float farStart = Mathf.Max(m_DepthOfField.farFocusStart.value, nearEnd);
float farEnd = Mathf.Max(m_DepthOfField.farFocusEnd.value, farStart + 1e-5f);
- cmd.SetComputeVectorParam(cs, HDShaderIDs._Params, new Vector4(nearStart, nearEnd, farStart, farEnd));
+ cmd.SetComputeVectorParam(cs, HDShaderIDs._Params, new Vector4(farStart, nearEnd, 1.0f / (farEnd - farStart), 1.0f / (nearStart - nearEnd)));
+ cmd.SetComputeVectorParam(cs, HDShaderIDs._Params2, new Vector4(m_DepthOfField.nearMaxBlur, m_DepthOfField.farMaxBlur, 0, 0));
}
cmd.SetComputeTextureParam(cs, kernel, HDShaderIDs._OutputTexture, fullresCoC);
cmd.DispatchCompute(cs, kernel, (camera.actualWidth + 7) / 8, (camera.actualHeight + 7) / 8, camera.viewCount);
+
+ if (taaEnabled)
+ {
+ bool useMips = true;
+ ReprojectCoCHistory(cmd, camera, useMips, ref fullresCoC);
+ }
}
using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.DepthOfFieldPyramid)))
@@ -2313,7 +2383,8 @@ void DoPhysicallyBasedDepthOfField(CommandBuffer cmd, HDCamera camera, RTHandle
cmd.DispatchCompute(cs, kernel, (camera.actualWidth + 7) / 8, (camera.actualHeight + 7) / 8, camera.viewCount);
}
- m_Pool.Recycle(fullresCoC);
+ if (!taaEnabled)
+ m_Pool.Recycle(fullresCoC);
}
#endregion
diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DoFCircleOfConfusion.compute b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DoFCircleOfConfusion.compute
index 81e5829696a..8981d33ab2f 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DoFCircleOfConfusion.compute
+++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DoFCircleOfConfusion.compute
@@ -10,8 +10,16 @@
CBUFFER_START(cb0)
float4 _Params;
+float4 _Params2;
CBUFFER_END
+#define FarStart _Params.x
+#define NearEnd _Params.y
+#define FarRange _Params.z // 1 / (FarEnd - FarStart)
+#define NearRange _Params.w // 1 / (NearStart - NearEnd)
+#define NearMaxRadius _Params2.x
+#define FarMaxRadius _Params2.y
+
// outpute texture
RW_TEXTURE2D_X(float, _OutputTexture);
@@ -50,7 +58,19 @@ void KMainCoCManual(uint3 dispatchThreadId : SV_DispatchThreadID)
{
UNITY_XR_ASSIGN_VIEW_INDEX(dispatchThreadId.z);
- //TODO
+ float depth = LoadCameraDepth(dispatchThreadId.xy);
+ // Note: we can avoid explicit linearization by merging it with the other computations
+ float linearEyeDepth = LinearEyeDepth(depth, _ZBufferParams);
+
+ float CoC = 0;
+ if (linearEyeDepth > FarStart)
+ {
+ CoC = FarMaxRadius * saturate((linearEyeDepth - FarStart) * FarRange);
+ }
+ else if (linearEyeDepth < NearEnd)
+ {
+ CoC = - NearMaxRadius * saturate((linearEyeDepth - NearEnd) * NearRange);
+ }
- _OutputTexture[COORD_TEXTURE2D_X(dispatchThreadId.xy)] = 0.0f;
+ _OutputTexture[COORD_TEXTURE2D_X(dispatchThreadId.xy)] = CoC;
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DoFGather.compute b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DoFGather.compute
index 072d3173169..16ad4aaa67f 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DoFGather.compute
+++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DoFGather.compute
@@ -13,6 +13,10 @@ CBUFFER_START(cb0)
float4 _Params;
CBUFFER_END
+#define NumRings _Params.x
+#define MaxCoCRadius _Params.y
+#define MaxCoCMipLevel _Params.z
+
// Input textures
TEXTURE2D_X(_InputTexture);
TEXTURE2D_X(_InputCoCTexture);
@@ -22,24 +26,20 @@ RW_TEXTURE2D_X(CTYPE, _OutputTexture);
// A set of Defines to fine-tune the algorithm
#define NUM_BUCKETS 3
-#define COC_FAR_CLAMPING
-#define CENTER_DENSITY
-#define RING_DENSITY 8.0
-#define UNIFORM_WEIGHTS
-//#define ADAPTIVE_RADIUS
#define GRADIENT_NOISE
+#define RING_DENSITY 8.0
+#define ADAPTIVE_RADIUS
//#define OCTAWEB_SORTING
+//#define UNIFORM_WEIGHTS
-// DO NOT EDIT: Helper defines so we can have one code path when OCTAWEB_SORTING is enabled or disabled.
+// Helper defines so we can have one code path when OCTAWEB_SORTING is enabled or disabled.
#ifndef OCTAWEB_SORTING
#define RING_COLOR totalColor
#define RING_MAXCOC maxCoC
- #define RING_HITS totalHits
#define RING_ALPHA totalAlpha
#else
#define RING_COLOR ringColor
#define RING_MAXCOC ringMaxCoC
- #define RING_HITS ringHits
#define RING_ALPHA ringAlpha
#endif
@@ -78,18 +78,43 @@ float GetCoCRadius(int2 positionSS, out int bucketIndex)
{
float CoCRadius = LOAD_TEXTURE2D_X(_InputCoCTexture, positionSS).x;
bucketIndex = GetCoCBucket(CoCRadius);
- return abs(CoCRadius);
+ return CoCRadius;
}
float GetCoCMaxRadius(int2 positionSS)
{
#ifndef ADAPTIVE_RADIUS
- return _Params.y;
+ return MaxCoCRadius;
#else
// We only have up to 6 mip levels
- int lod = min(6, _Params.z);
- float maxOverlapingCoC = LOAD_TEXTURE2D_X_LOD(_InputCoCTexture, positionSS >> lod, lod).x;
- return abs(maxOverlapingCoC);
+ int lod = min(6, MaxCoCMipLevel);
+
+ // TODO FIXME - (Seb) I added this patch for metal as it was causing a
+ // Shader error in 'DoFGather': 'GetDimensions' : no matching 5 parameter intrinsic method;
+ // But overall I am even not this if this call work on Metal.
+#if defined(SHADER_API_METAL)
+ uint3 size;
+ // Texture2D.GetDimensions(uint, out uint width, out uint height, out uint levels)
+ _InputCoCTexture.GetDimensions(lod, size.x, size.y, size.z);
+#else
+ uint4 size;
+ _InputCoCTexture.GetDimensions(lod, size.x, size.y, size.z, size.w);
+#endif
+
+ // Take RTHandleScale into account and odd texture dimension sizes (it's not enough to do a positionSS >> lod)
+ uint2 coords = positionSS * _ScreenSize.zw * size.xy * _RTHandleScale.xy;
+
+ // Find the max CoC that is overlapping this pixel by sampling the max neighborhood
+ float maxOverlapingCoC = abs(LOAD_TEXTURE2D_X_LOD(_InputCoCTexture, coords, lod).x);
+ maxOverlapingCoC = max(maxOverlapingCoC, abs(LOAD_TEXTURE2D_X_LOD(_InputCoCTexture, coords + uint2 (1, 0), lod).x));
+ maxOverlapingCoC = max(maxOverlapingCoC, abs(LOAD_TEXTURE2D_X_LOD(_InputCoCTexture, coords + uint2 (0, 1), lod).x));
+ maxOverlapingCoC = max(maxOverlapingCoC, abs(LOAD_TEXTURE2D_X_LOD(_InputCoCTexture, coords + uint2 (1, 1), lod).x));
+ maxOverlapingCoC = max(maxOverlapingCoC, abs(LOAD_TEXTURE2D_X_LOD(_InputCoCTexture, coords + uint2 (-1, 0), lod).x));
+ maxOverlapingCoC = max(maxOverlapingCoC, abs(LOAD_TEXTURE2D_X_LOD(_InputCoCTexture, coords + uint2 (0, -1), lod).x));
+ maxOverlapingCoC = max(maxOverlapingCoC, abs(LOAD_TEXTURE2D_X_LOD(_InputCoCTexture, coords + uint2 (-1, -1), lod).x));
+ maxOverlapingCoC = max(maxOverlapingCoC, abs(LOAD_TEXTURE2D_X_LOD(_InputCoCTexture, coords + uint2 (-1, 1), lod).x));
+ maxOverlapingCoC = max(maxOverlapingCoC, abs(LOAD_TEXTURE2D_X_LOD(_InputCoCTexture, coords + uint2 (1, -1), lod).x));
+ return maxOverlapingCoC;
#endif
}
@@ -99,12 +124,9 @@ float GetSampleWeight(float cocRadius)
return 1.0f;
#endif
- if (cocRadius == 0.0) return 0.0;
-
float pixelRadius = 0.7071f;
- float singlePixelArea = PI * pixelRadius * pixelRadius;
- float diskArea = PI * cocRadius * cocRadius;
- return diskArea >= singlePixelArea ? rcp(diskArea) : rcp(singlePixelArea);
+ float radius = max(pixelRadius, cocRadius);
+ return rcp(PI * radius * radius);
}
float2 PointInCircle(float angle)
@@ -112,26 +134,34 @@ float2 PointInCircle(float angle)
return float2(cos(angle), sin(angle));
}
-float GetNumSamples(float radius)
+float GetNumSamples(float radius, float maxRadius)
{
- //TODO: needs to take into account the density push towards the center (when enabled)
- float numRings = _Params.x;
- float maxRadius = _Params.y;
-
- float dR = maxRadius / numRings;
+ float dR = maxRadius / NumRings;
float rings = floor(radius / dR);
float seriesSum = 0.5 * rings * (rings + 1);
return 1.0 + seriesSum * RING_DENSITY;
}
+float GetRingWeight(int index, float dR)
+{
+ float ringRadius = index * dR;
+ float ringArea = PI * ringRadius * ringRadius;
+
+ float prevRingRadius = max(0, index - 1) * dR;
+ float prevRingArea = PI * prevRingRadius * prevRingRadius;
+
+ ringArea = ringArea - prevRingArea;
+
+ float ringSamples = RING_DENSITY * index;
+ ringSamples = (index == 1) ? ringSamples + 1.0f : ringSamples;
+ return ringArea * rcp (ringSamples);
+}
+
[numthreads(GROUP_RES, GROUP_RES, 1)]
void KMain(uint3 dispatchThreadId : SV_DispatchThreadID)
{
PositionInputs posInputs = GetPositionInput(float2(dispatchThreadId.xy), _ScreenSize.zw, uint2(GROUP_RES, GROUP_RES));
-
- CTYPE centerColor = LOAD_TEXTURE2D_X(_InputTexture, posInputs.positionSS).CTYPE_SWIZZLE;
int bucketIndex = 0;
- float centerCoc = GetCoCRadius(posInputs.positionSS, bucketIndex);
// Bucket 0 : far focus region
// Bucket 1 : in focus region
@@ -150,60 +180,42 @@ void KMain(uint3 dispatchThreadId : SV_DispatchThreadID)
totalColor[i] = 0.0f;
maxCoC[i] = 0.0f;
prevRingWeight[i] = 0.0f;
- totalHits[i] = 0.0f;
#ifdef ENABLE_ALPHA
totalAlpha[i] = 0.0f;
#endif
}
- // Record the central sample
- {
- float weight = GetSampleWeight(centerCoc);
- totalColor[bucketIndex].xyz = centerColor.xyz * weight;
- totalColor[bucketIndex].w = weight;
- maxCoC[bucketIndex] = centerCoc;
- prevRingWeight[bucketIndex] = weight;
-#ifdef ENABLE_ALPHA
- totalAlpha[bucketIndex] = centerColor.w;
-#endif
- }
+ float maxRadius = GetCoCMaxRadius(posInputs.positionSS);
- float numRings = _Params.x;
- float maxRadius = GetCoCMaxRadius(posInputs.positionSS);
-
- float dR = maxRadius * rcp(numRings);
+ float dR = maxRadius * rcp(NumRings);
float stratum = fmod(posInputs.positionSS.x + posInputs.positionSS.y, 2.0f);
- // Note: gradient noise seems to give worse results than s
- float noise = InterleavedGradientNoise(posInputs.positionSS.xy, 0);
- float noise2 = InterleavedGradientNoise(posInputs.positionSS.xy, 9);
+
+ int sampleOffset = _TaaFrameInfo.w != 0.0 ? _TaaFrameInfo.z : 0;
+ float noise = InterleavedGradientNoise(posInputs.positionSS.xy, sampleOffset);
+ float noise2 = InterleavedGradientNoise(posInputs.positionSS.xy, 8 + sampleOffset);
// Iterate over the octaweb pattern and gather the DoF samples
- for (float ring = 1; ring <= numRings; ring += 1.0)
+ for (float ring = NumRings; ring >= 0; ring -= 1.0)
{
- float scaledRad = dR;
-
-#ifdef CENTER_DENSITY
- // make the samples more dense at the center
- scaledRad = lerp(0.5 * dR, dR, ring * rcp(numRings));
-#endif
+ float numSamples = max(ring * RING_DENSITY, 1);
+ float dAng = 2.0f * PI / numSamples;
- float dAng = 2.0f * PI / (ring * RING_DENSITY);
-
- // for high sample counts, checkerboarding looks better
#ifndef GRADIENT_NOISE
- float radius = ring * scaledRad + stratum * scaledRad;
+ float radius = ring * dR + stratum * dR;
float ringOffset = 0.5 * fmod(ring, 2.0f) * dAng;
#else
- float radius = ring * scaledRad + noise2 * scaledRad;
+ float radius = (ring - 1) * dR + noise2 * dR;
float ringOffset = noise * dAng;
#endif
+ float ringWeight = GetRingWeight(max(1, ring), dR);
+
#ifdef OCTAWEB_SORTING
float4 ringColor[NUM_BUCKETS];
float ringMaxCoC[NUM_BUCKETS];
float ringHits[NUM_BUCKETS];
#ifdef ENABLE_ALPHA
- float4 ringAlpha[NUM_BUCKETS];
+ float ringAlpha[NUM_BUCKETS];
#endif
for (int i = 0; i < NUM_BUCKETS; ++i)
@@ -226,127 +238,56 @@ void KMain(uint3 dispatchThreadId : SV_DispatchThreadID)
CTYPE sampleColor = LOAD_TEXTURE2D_X(_InputTexture, sampleTC).CTYPE_SWIZZLE;
float sampleCoC = GetCoCRadius(sampleTC, sampleBucket);
-#ifdef COC_FAR_CLAMPING
- if (sampleBucket < 1)
- sampleCoC = clamp(sampleCoC, 0, centerCoc);
-#endif
-
- if (sampleCoC > radius)
+ if (abs(sampleCoC) >= radius)
{
- float weight = GetSampleWeight(sampleCoC);
- RING_COLOR[sampleBucket].xyz += sampleColor.xyz * weight;
- RING_COLOR[sampleBucket].w += weight;
- RING_MAXCOC[sampleBucket] = max(RING_MAXCOC[sampleBucket], sampleCoC);
- RING_HITS[sampleBucket] += 1.0;
-#ifdef ENABLE_ALPHA
- RING_ALPHA[sampleBucket] = sampleColor.w * weight;
+ float weight = ringWeight * GetSampleWeight(abs(sampleCoC));
+ RING_COLOR[sampleBucket] += float4(sampleColor.xyz * weight, weight);
+ RING_MAXCOC[sampleBucket] = max(RING_MAXCOC[sampleBucket], abs(sampleCoC));
+#ifdef OCTAWEB_SORTING
+ ringHits[sampleBucket] += 1.0;
#endif
- }
-#ifdef UNIFORM_WEIGHTS
- else
- {
- RING_COLOR[sampleBucket].xyz += RING_COLOR[sampleBucket].xyz / RING_COLOR[sampleBucket].w;
- RING_COLOR[sampleBucket].w += 1.0f;
#ifdef ENABLE_ALPHA
- RING_ALPHA[sampleBucket] += RING_ALPHA[sampleBucket] / RING_COLOR[sampleBucket].w;
+ RING_ALPHA[sampleBucket] = sampleColor.w * weight;
#endif
}
-#endif
}
#ifdef OCTAWEB_SORTING
- // Far bucket
- {
- totalColor[0] += RING_COLOR[0];
- maxCoC[0] = max(maxCoC[0], RING_MAXCOC[0]);
- totalHits[0] += RING_HITS[0];
-#ifdef ENABLE_ALPHA
- totalAlpha[0] += RING_ALPHA[0];
-#endif
- }
-
- // In-focus bucket
- {
- totalColor[1] += RING_COLOR[1];
- maxCoC[1] = max(maxCoC[1], RING_MAXCOC[1]);
- totalHits[1] += RING_HITS[1];
-#ifdef ENABLE_ALPHA
- totalAlpha[1] += RING_ALPHA[1];
-#endif
- }
-
- // Near bucket
+ for (int j = 0; j < NUM_BUCKETS; ++j)
{
- float currentAvg = RING_COLOR[2].w * rcp(ring * RING_DENSITY);
- float prevAvg = prevRingWeight[2] * ((ring > 1) ? rcp((ring - 1.0) * RING_DENSITY) : 1);
+ float currentAvg = RING_COLOR[j].w * rcp(ring * RING_DENSITY);
+ float prevAvg = (ring < numRings) ? prevRingWeight[j] : currentAvg;
float occlusion = saturate(prevAvg - currentAvg);
- //float alpha = saturate(RING_COLOR[2].w * rcp(GetNumSamples(RING_MAXCOC[2])) * rcp(getSampleWeight(RING_MAXCOC[2])));
- float alpha = ringHits[2] * rcp(ring * RING_DENSITY);
-
- //totalColor[2] += RING_COLOR[2];
- maxCoC[2] = max(maxCoC[2], RING_MAXCOC[2]);
- totalHits[2] += RING_HITS[2];
+ float alpha = ringHits[j] * rcp(ring * RING_DENSITY);
float blendFactor = 1.0 - alpha * occlusion;
- totalColor[2] = blendFactor * totalColor[2] + RING_COLOR[2];
- prevRingWeight[2] = ringColor[2].w;
+ totalColor[j] = blendFactor * totalColor[j] + RING_COLOR[j];
+ prevRingWeight[j] = currentAvg;
#ifdef ENABLE_ALPHA
- totalAlpha[2] += blendFactor * totalAlpha[2] + RING_ALPHA[2];
+ totalAlpha[j] += blendFactor * totalAlpha[j] + RING_ALPHA[j];
#endif
}
#endif
}
- // Now compute the final color by combining the near, far and in-focus buckets with proper blending
-
- // Far range
- float3 outColor = totalColor[0].xyz;
- float totalW = totalColor[0].w;
-#ifdef ENABLE_ALPHA
- float outAlpha = totalAlpha[0];
-#endif
-
-#ifndef UNIFORM_WEIGHTS
- // In focus range
- {
- // TODO: we might need to re-investigate the normaziation here, there is banding
- float alpha = saturate(totalColor[1].w * rcp(GetNumSamples(maxCoC[1])) * rcp(GetSampleWeight(maxCoC[1])));
- outColor.xyz = (1.0 - alpha) * outColor.xyz + totalColor[1].xyz;
- totalW = (1.0 - alpha) * totalW + totalColor[1].w;
-#ifdef ENABLE_ALPHA
- outAlpha = (1.0 - alpha) * outAlpha + totalAlpha[1];
-#endif
- }
- if (totalW > 0) outColor.xyz /= totalW;
-
- // Near range
- float alpha = saturate(3 * totalHits[2] * rcp(GetNumSamples(maxCoC[2])));
- float3 srcColor = totalColor[2].w > 0 ? totalColor[2].xyz / totalColor[2].w : 0.0f;
- outColor.xyz = (1.0 - alpha) * outColor.xyz + alpha * srcColor;
+ float4 outColor = 0;
#ifdef ENABLE_ALPHA
- float srcAlpha = totalColor[2].w > 0 ? totalAlpha[2] / totalColor[2].w : 0.0f;
- outAlpha = (1.0 - alpha) * outAlpha + alpha * srcAlpha;
-
+ float outAlpha = 0;
#endif
-#else
- // back to front alpha blending of the other buckets
- for (int j = 1; j < NUM_BUCKETS; ++j)
+ // back to front alpha blending of the near, far and in-focus buckets
+ for (int j = 0; j < NUM_BUCKETS; ++j)
{
- // TODO: we might need to re-investigate the normaziation here, there is banding
- float alpha = saturate(totalColor[j].w * rcp(GetNumSamples(maxCoC[j])) * rcp(GetSampleWeight(maxCoC[j])));
-
- outColor.xyz = (1.0 - alpha) * outColor.xyz + totalColor[j].xyz;
- totalW = (1.0 - alpha) * totalW + totalColor[j].w;
+ float alpha = saturate(totalColor[j].w * rcp(GetNumSamples(maxCoC[j], maxRadius)) * rcp(GetSampleWeight(maxCoC[j])));
+ outColor = (1.0 - alpha) * outColor + alpha * totalColor[j];
#ifdef ENABLE_ALPHA
- outAlpha = (1.0 - alpha) * outAlpha + totalAlpha[j];
+ outAlpha = (1.0 - alpha) * outAlpha + alpha * totalAlpha[j];
#endif
}
- outColor.xyz = outColor.xyz * rcp(totalW);
-#endif
+ outColor.xyz = outColor.xyz * rcp(outColor.w);
#ifdef ENABLE_ALPHA
- _OutputTexture[COORD_TEXTURE2D_X(posInputs.positionSS)] = float4(outColor.xyz, outAlpha * rcp(totalW));
+ _OutputTexture[COORD_TEXTURE2D_X(posInputs.positionSS)] = float4(outColor.xyz, outAlpha * rcp(outColor.w));
#else
_OutputTexture[COORD_TEXTURE2D_X(posInputs.positionSS)] = outColor.xyz;
#endif
diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/TemporalAntiAliasing.shader b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/TemporalAntiAliasing.shader
index b88b6224d8d..907473c39e8 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/TemporalAntiAliasing.shader
+++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/TemporalAntiAliasing.shader
@@ -14,7 +14,7 @@ Shader "Hidden/HDRP/TemporalAA"
#pragma multi_compile_local _ FORCE_BILINEAR_HISTORY
#pragma multi_compile_local _ ENABLE_MV_REJECTION
#pragma multi_compile_local _ ANTI_RINGING
- #pragma multi_compile_local LOW_QUALITY MEDIUM_QUALITY HIGH_QUALITY
+ #pragma multi_compile_local LOW_QUALITY MEDIUM_QUALITY HIGH_QUALITY POST_DOF
#pragma only_renderers d3d11 playstation xboxone vulkan metal switch
@@ -69,6 +69,19 @@ Shader "Hidden/HDRP/TemporalAA"
#define PERCEPTUAL_SPACE 1
#define PERCEPTUAL_SPACE_ONLY_END 0 && (PERCEPTUAL_SPACE == 0)
+#elif defined(POST_DOF)
+ #define YCOCG 1
+ #define HISTORY_SAMPLING_METHOD BILINEAR
+ #define WIDE_NEIGHBOURHOOD 0
+ #define NEIGHBOUROOD_CORNER_METHOD VARIANCE
+ #define CENTRAL_FILTERING NO_FILTERINGs
+ #define HISTORY_CLIP DIRECT_CLIP
+ #define ANTI_FLICKER 1
+ #define ANTI_FLICKER_MV_DEPENDENT 1
+ #define VELOCITY_REJECTION (defined(ENABLE_MV_REJECTION) && 0)
+ #define PERCEPTUAL_SPACE 1
+ #define PERCEPTUAL_SPACE_ONLY_END 0 && (PERCEPTUAL_SPACE == 0)
+
#endif
@@ -85,9 +98,10 @@ Shader "Hidden/HDRP/TemporalAA"
#define _SpeedRejectionIntensity _TaaPostParameters.z
#define _ContrastForMaxAntiFlicker _TaaPostParameters.w
-
+#if VELOCITY_REJECTION
TEXTURE2D_X(_InputVelocityMagnitudeHistory);
RW_TEXTURE2D_X(float, _OutputVelocityMagnitudeHistory);
+#endif
float4 _TaaPostParameters;
float4 _TaaHistorySize;
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDAdditionalCameraData.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDAdditionalCameraData.cs
index a9667339265..fe2b89f1c15 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDAdditionalCameraData.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDAdditionalCameraData.cs
@@ -13,7 +13,7 @@ public class HDPhysicalCamera
///
/// The minimum allowed aperture.
///
- public const float kMinAperture = 1f;
+ public const float kMinAperture = 0.7f;
///
/// The maximum allowed aperture.
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCameraFrameHistoryType.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCameraFrameHistoryType.cs
index 08a16af16a0..95c52429323 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCameraFrameHistoryType.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCameraFrameHistoryType.cs
@@ -41,6 +41,8 @@ public enum HDCameraFrameHistoryType
RayTracedSubSurface,
/// Path tracing buffer.
PathTracing,
+ /// Temporal antialiasing history after DoF.
+ TemporalAntialiasingPostDoF,
/// Number of history buffers.
Count
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/GlobalPostProcessingQualitySettings.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/GlobalPostProcessingQualitySettings.cs
index f77d6923019..2710fc3a8c3 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/GlobalPostProcessingQualitySettings.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/GlobalPostProcessingQualitySettings.cs
@@ -122,6 +122,8 @@ internal GlobalPostProcessingQualitySettings()
public DepthOfFieldResolution[] DoFResolution = new DepthOfFieldResolution[s_QualitySettingCount];
/// Use Depth of field high quality filtering for each quality level.
public bool[] DoFHighQualityFiltering = new bool[s_QualitySettingCount];
+ /// Use Depth of field high physically based setting for each quality level.
+ public bool[] DoFPhysicallyBased = new bool[s_QualitySettingCount];
/* Motion Blur */
/// Motion Blur sample count for each quality level.
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs
index 82fa896ae5b..a0ea0620acb 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs
@@ -10,8 +10,11 @@ public partial class HDRenderPipeline
{
struct LightingBuffers
{
+ // TODO RENDERGRAPH: Those two buffers aren't really lighting buffers but only used for SSS
+ // We should probably move them out of here.
public TextureHandle sssBuffer;
public TextureHandle diffuseLightingBuffer;
+
public TextureHandle ambientOcclusionBuffer;
public TextureHandle ssrLightingBuffer;
public TextureHandle contactShadowsBuffer;
@@ -28,6 +31,13 @@ static LightingBuffers ReadLightingBuffers(in LightingBuffers buffers, RenderGra
return result;
}
+ static void BindGlobalLightingBuffers(in LightingBuffers buffers, CommandBuffer cmd)
+ {
+ cmd.SetGlobalTexture(HDShaderIDs._AmbientOcclusionTexture, buffers.ambientOcclusionBuffer);
+ cmd.SetGlobalTexture(HDShaderIDs._SsrLightingTexture, buffers.ssrLightingBuffer);
+ cmd.SetGlobalTexture(HDShaderIDs._ContactShadowTexture, buffers.contactShadowsBuffer);
+ }
+
class BuildGPULightListPassData
{
public BuildGPULightListParameters buildGPULightListParameters;
@@ -251,6 +261,7 @@ class DeferredLightingPassData
public int gbufferCount;
public int lightLayersTextureIndex;
+ public int shadowMaskTextureIndex;
public TextureHandle[] gbuffer = new TextureHandle[8];
public ComputeBufferHandle lightListBuffer;
@@ -301,6 +312,7 @@ LightingOutput RenderDeferredLighting( RenderGraph renderGraph,
passData.lightingBuffers = ReadLightingBuffers(lightingBuffers, builder);
passData.lightLayersTextureIndex = gbuffer.lightLayersTextureIndex;
+ passData.shadowMaskTextureIndex = gbuffer.shadowMaskTextureIndex;
passData.gbufferCount = gbuffer.gBufferCount;
for (int i = 0; i < gbuffer.gBufferCount; ++i)
passData.gbuffer[i] = builder.ReadTexture(gbuffer.mrt[i]);
@@ -343,11 +355,14 @@ LightingOutput RenderDeferredLighting( RenderGraph renderGraph,
else
context.cmd.SetGlobalTexture(HDShaderIDs._LightLayersTexture, TextureXR.GetWhiteTexture());
+ if (data.shadowMaskTextureIndex != -1)
+ context.cmd.SetGlobalTexture(HDShaderIDs._ShadowMaskTexture, data.gbuffer[data.shadowMaskTextureIndex]);
+ else
+ context.cmd.SetGlobalTexture(HDShaderIDs._ShadowMaskTexture, TextureXR.GetWhiteTexture());
+
// TODO RENDERGRAPH: Remove these SetGlobal and properly send these textures to the deferred passes and bind them directly to compute shaders.
// This can wait that we remove the old code path.
- context.cmd.SetGlobalTexture(HDShaderIDs._AmbientOcclusionTexture, data.lightingBuffers.ambientOcclusionBuffer);
- context.cmd.SetGlobalTexture(HDShaderIDs._SsrLightingTexture, data.lightingBuffers.ssrLightingBuffer);
- context.cmd.SetGlobalTexture(HDShaderIDs._ContactShadowTexture, data.lightingBuffers.contactShadowsBuffer);
+ BindGlobalLightingBuffers(data.lightingBuffers, context.cmd);
if (data.parameters.enableTile)
{
@@ -432,7 +447,7 @@ TextureHandle RenderSSR( RenderGraph renderGraph,
passData.hitPointsTexture = builder.CreateTransientTexture(new TextureDesc(Vector2.one, true, true)
{ colorFormat = GraphicsFormat.R16G16_UNorm, clearBuffer = true, clearColor = Color.clear, enableRandomWrite = true, name = "SSR_Hit_Point_Texture" });
passData.lightingTexture = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true)
- { colorFormat = GraphicsFormat.R16G16B16A16_SFloat, clearBuffer = true, clearColor = Color.clear, enableRandomWrite = true, name = "SSR_Lighting_Texture" }, HDShaderIDs._SsrLightingTexture));
+ { colorFormat = GraphicsFormat.R16G16B16A16_SFloat, clearBuffer = true, clearColor = Color.clear, enableRandomWrite = true, name = "SSR_Lighting_Texture" }));
//passData.hitPointsTexture = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true)
// { colorFormat = GraphicsFormat.ARGBFloat, clearBuffer = true, clearColor = Color.clear, enableRandomWrite = true, name = "SSR_Debug_Texture" }));
@@ -479,7 +494,7 @@ class RenderContactShadowPassData
TextureHandle RenderContactShadows(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle depthTexture, in BuildGPULightListOutput lightLists, int firstMipOffsetY)
{
if (!WillRenderContactShadow())
- return renderGraph.ImportTexture(TextureXR.GetClearTexture(), HDShaderIDs._ContactShadowTexture);
+ return renderGraph.defaultResources.clearTextureXR;
TextureHandle result;
using (var builder = renderGraph.AddRenderPass("Contact Shadows", out var passData))
@@ -494,7 +509,7 @@ TextureHandle RenderContactShadows(RenderGraph renderGraph, HDCamera hdCamera, T
passData.lightList = builder.ReadComputeBuffer(lightLists.lightList);
passData.depthTexture = builder.ReadTexture(depthTexture);
passData.contactShadowsTexture = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true)
- { colorFormat = GraphicsFormat.R32_UInt, enableRandomWrite = true, clearBuffer = clearBuffer, clearColor = Color.clear, name = "ContactShadowsBuffer" }, HDShaderIDs._ContactShadowTexture));
+ { colorFormat = GraphicsFormat.R32_UInt, enableRandomWrite = true, clearBuffer = clearBuffer, clearColor = Color.clear, name = "ContactShadowsBuffer" }));
result = passData.contactShadowsTexture;
@@ -589,7 +604,7 @@ TextureHandle VolumetricLightingPass(RenderGraph renderGraph, HDCamera hdCamera,
Vector3Int viewportSize = ComputeVolumetricViewportSize(hdCamera, ref tileSize);
// TODO RENDERGRAPH: Auto-scale of 3D RTs is not supported yet so we need to find a better solution for this. Or keep it as is?
- passData.lightingBuffer = builder.WriteTexture(renderGraph.ImportTexture(m_LightingBuffer, HDShaderIDs._VBufferLighting));
+ passData.lightingBuffer = builder.WriteTexture(renderGraph.ImportTexture(m_LightingBuffer));
if (passData.parameters.enableReprojection)
{
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs
index 5a6d58332b7..402c2be2dbf 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs
@@ -97,7 +97,7 @@ TextureHandle CreateNormalBuffer(RenderGraph renderGraph, bool msaa)
{
TextureDesc normalDesc = new TextureDesc(Vector2.one, true, true)
{ colorFormat = GraphicsFormat.R8G8B8A8_UNorm, clearBuffer = NeedClearGBuffer(), clearColor = Color.black, bindTextureMS = msaa, enableMSAA = msaa, enableRandomWrite = !msaa, name = msaa ? "NormalBufferMSAA" : "NormalBuffer" };
- return renderGraph.CreateTexture(normalDesc, msaa ? HDShaderIDs._NormalTextureMS : HDShaderIDs._NormalBufferTexture);
+ return renderGraph.CreateTexture(normalDesc);
}
TextureHandle CreateDecalPrepassBuffer(RenderGraph renderGraph, bool msaa)
@@ -111,7 +111,7 @@ TextureHandle CreateMotionVectorBuffer(RenderGraph renderGraph, bool msaa, bool
{
TextureDesc motionVectorDesc = new TextureDesc(Vector2.one, true, true)
{ colorFormat = Builtin.GetMotionVectorFormat(), bindTextureMS = msaa, enableMSAA = msaa, clearBuffer = clear, clearColor = Color.clear, name = msaa ? "Motion Vectors MSAA" : "Motion Vectors" };
- return renderGraph.CreateTexture(motionVectorDesc, HDShaderIDs._CameraMotionVectorsTexture);
+ return renderGraph.CreateTexture(motionVectorDesc);
}
// TODO RENDERGRAPH: in someplaces we auto bind and in others we have to generate MRT because of discrepancy with non render graph path.
@@ -288,7 +288,7 @@ bool RenderDepthPrepass(RenderGraph renderGraph, CullingResults cull, HDCamera h
if (msaa)
{
passData.depthAsColorBuffer = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true)
- { colorFormat = GraphicsFormat.R32_SFloat, clearBuffer = true, clearColor = Color.black, bindTextureMS = true, enableMSAA = true, name = "DepthAsColorMSAA" }, HDShaderIDs._DepthTextureMS));
+ { colorFormat = GraphicsFormat.R32_SFloat, clearBuffer = true, clearColor = Color.black, bindTextureMS = true, enableMSAA = true, name = "DepthAsColorMSAA" }));
}
if (passData.hasDepthDeferredPass)
@@ -404,6 +404,7 @@ struct GBufferOutput
public TextureHandle[] mrt;
public int gBufferCount;
public int lightLayersTextureIndex;
+ public int shadowMaskTextureIndex;
}
void SetupGBufferTargets(RenderGraph renderGraph, HDCamera hdCamera, GBufferPassData passData, TextureHandle sssBuffer, ref PrepassOutput prepassOutput, FrameSettings frameSettings, RenderGraphBuilder builder)
@@ -430,27 +431,28 @@ void SetupGBufferTargets(RenderGraph renderGraph, HDCamera hdCamera, GBufferPass
#if UNITY_2020_2_OR_NEWER
, fastMemoryDesc = gbufferFastMemDesc
#endif
- }, HDShaderIDs._GBufferTexture[2]), 2);
+ }), 2);
passData.gbufferRT[3] = builder.UseColorBuffer(renderGraph.CreateTexture(
new TextureDesc(Vector2.one, true, true) { colorFormat = Builtin.GetLightingBufferFormat(), clearBuffer = clearGBuffer, clearColor = Color.clear, name = "GBuffer3"
#if UNITY_2020_2_OR_NEWER
, fastMemoryDesc = gbufferFastMemDesc
#endif
- }, HDShaderIDs._GBufferTexture[3]), 3);
+ }), 3);
prepassOutput.gbuffer.lightLayersTextureIndex = -1;
+ prepassOutput.gbuffer.shadowMaskTextureIndex = -1;
int currentIndex = 4;
if (lightLayers)
{
passData.gbufferRT[currentIndex] = builder.UseColorBuffer(renderGraph.CreateTexture(
- new TextureDesc(Vector2.one, true, true) { colorFormat = GraphicsFormat.R8G8B8A8_UNorm, clearBuffer = clearGBuffer, clearColor = Color.clear, name = "LightLayers" }, HDShaderIDs._LightLayersTexture), currentIndex);
+ new TextureDesc(Vector2.one, true, true) { colorFormat = GraphicsFormat.R8G8B8A8_UNorm, clearBuffer = clearGBuffer, clearColor = Color.clear, name = "LightLayers" }), currentIndex);
prepassOutput.gbuffer.lightLayersTextureIndex = currentIndex++;
}
if (shadowMasks)
{
passData.gbufferRT[currentIndex] = builder.UseColorBuffer(renderGraph.CreateTexture(
- new TextureDesc(Vector2.one, true, true) { colorFormat = Builtin.GetShadowMaskBufferFormat(), clearBuffer = clearGBuffer, clearColor = Color.clear, name = "ShadowMasks" }, HDShaderIDs._ShadowMaskTexture), currentIndex);
- currentIndex++;
+ new TextureDesc(Vector2.one, true, true) { colorFormat = Builtin.GetShadowMaskBufferFormat(), clearBuffer = clearGBuffer, clearColor = Color.clear, name = "ShadowMasks" }), currentIndex);
+ prepassOutput.gbuffer.shadowMaskTextureIndex = currentIndex++;
}
prepassOutput.gbuffer.gBufferCount = currentIndex;
@@ -603,7 +605,7 @@ void CopyDepthBufferIfNeeded(RenderGraph renderGraph, HDCamera hdCamera, ref Pre
using (var builder = renderGraph.AddRenderPass("Copy depth buffer", out var passData, ProfilingSampler.Get(HDProfileId.CopyDepthBuffer)))
{
passData.inputDepth = builder.ReadTexture(output.resolvedDepthBuffer);
- passData.outputDepth = builder.WriteTexture(renderGraph.CreateTexture(m_DepthPyramidDesc, HDShaderIDs._CameraDepthTexture));
+ passData.outputDepth = builder.WriteTexture(renderGraph.CreateTexture(m_DepthPyramidDesc));
passData.GPUCopy = m_GPUCopy;
passData.width = hdCamera.actualWidth;
passData.height = hdCamera.actualHeight;
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs
index 4cff68277ba..3fca931cd83 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs
@@ -34,7 +34,7 @@ void ExecuteWithRenderGraph( RenderRequest renderRequest,
TextureHandle backBuffer = m_RenderGraph.ImportBackbuffer(target.id);
TextureHandle colorBuffer = CreateColorBuffer(m_RenderGraph, hdCamera, msaa);
m_NonMSAAColorBuffer = CreateColorBuffer(m_RenderGraph, hdCamera, false);
- TextureHandle currentColorPyramid = m_RenderGraph.ImportTexture(hdCamera.GetCurrentFrameRT((int)HDCameraFrameHistoryType.ColorBufferMipChain), HDShaderIDs._ColorPyramidTexture);
+ TextureHandle currentColorPyramid = m_RenderGraph.ImportTexture(hdCamera.GetCurrentFrameRT((int)HDCameraFrameHistoryType.ColorBufferMipChain));
LightingBuffers lightingBuffers = new LightingBuffers();
lightingBuffers.diffuseLightingBuffer = CreateDiffuseLightingBuffer(m_RenderGraph, msaa);
@@ -168,7 +168,7 @@ void ExecuteWithRenderGraph( RenderRequest renderRequest,
RenderForwardEmissive(m_RenderGraph, hdCamera, colorBuffer, prepassOutput.depthBuffer, cullingResults);
- RenderSky(m_RenderGraph, hdCamera, colorBuffer, volumetricLighting, prepassOutput.depthBuffer, prepassOutput.depthPyramidTexture);
+ RenderSky(m_RenderGraph, hdCamera, colorBuffer, volumetricLighting, prepassOutput.depthBuffer, msaa ? prepassOutput.depthAsColor : prepassOutput.depthPyramidTexture);
// Send all the geometry graphics buffer to client systems if required (must be done after the pyramid and before the transparent depth pre-pass)
SendGeometryGraphicsBuffers(m_RenderGraph, prepassOutput.normalBuffer, prepassOutput.depthPyramidTexture, hdCamera);
@@ -179,7 +179,7 @@ void ExecuteWithRenderGraph( RenderRequest renderRequest,
// No need for old stencil values here since from transparent on different features are tagged
ClearStencilBuffer(m_RenderGraph, colorBuffer, prepassOutput.depthBuffer);
- colorBuffer = RenderTransparency(m_RenderGraph, hdCamera, colorBuffer, currentColorPyramid, gpuLightListOutput, ref prepassOutput, shadowResult, cullingResults, customPassCullingResults, aovRequest, aovBuffers);
+ colorBuffer = RenderTransparency(m_RenderGraph, hdCamera, colorBuffer, currentColorPyramid, volumetricLighting, gpuLightListOutput, ref prepassOutput, shadowResult, cullingResults, customPassCullingResults, aovRequest, aovBuffers);
if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.TransparentsWriteMotionVector))
{
@@ -397,26 +397,36 @@ class ForwardPassData
public TextureHandle[] renderTarget = new TextureHandle[3];
public int renderTargetCount;
public TextureHandle depthBuffer;
- public TextureHandle ssrLlightingBuffer;
public ComputeBufferHandle lightListBuffer;
public ComputeBufferHandle perVoxelOffset;
public ComputeBufferHandle perTileLogBaseTweak;
public FrameSettings frameSettings;
- public bool decalsEnabled;
- public bool renderMotionVecForTransparent;
- public DBufferOutput? dbuffer;
}
- void PrepareForwardPassData(RenderGraph renderGraph,
- RenderGraphBuilder builder,
- ForwardPassData data,
- bool opaque,
- FrameSettings frameSettings,
- RendererListDesc rendererListDesc,
- in BuildGPULightListOutput lightLists,
- TextureHandle depthBuffer,
- ShadowResult shadowResult,
- DBufferOutput? dbuffer = null)
+ class ForwardOpaquePassData : ForwardPassData
+ {
+ public DBufferOutput dbuffer;
+ public LightingBuffers lightingBuffers;
+ }
+
+ class ForwardTransparentPassData : ForwardPassData
+ {
+ public bool decalsEnabled;
+ public bool renderMotionVecForTransparent;
+ public TextureHandle transparentSSRLighting;
+ public TextureHandle volumetricLighting;
+
+ }
+
+ void PrepareCommonForwardPassData( RenderGraph renderGraph,
+ RenderGraphBuilder builder,
+ ForwardPassData data,
+ bool opaque,
+ FrameSettings frameSettings,
+ RendererListDesc rendererListDesc,
+ in BuildGPULightListOutput lightLists,
+ TextureHandle depthBuffer,
+ ShadowResult shadowResult)
{
bool useFptl = frameSettings.IsEnabled(FrameSettingsField.FPTLForForwardOpaque) && opaque;
@@ -430,14 +440,8 @@ void PrepareForwardPassData(RenderGraph renderGraph,
}
data.depthBuffer = builder.UseDepthBuffer(depthBuffer, DepthAccess.ReadWrite);
data.rendererList = builder.UseRendererList(renderGraph.CreateRendererList(rendererListDesc));
- // enable d-buffer flag value is being interpreted more like enable decals in general now that we have clustered
- // decal datas count is 0 if no decals affect transparency
- data.decalsEnabled = (frameSettings.IsEnabled(FrameSettingsField.Decals)) && (DecalSystem.m_DecalDatasCount > 0);
- data.renderMotionVecForTransparent = NeedMotionVectorForTransparent(frameSettings);
HDShadowManager.ReadShadowResult(shadowResult, builder);
- if (dbuffer != null)
- data.dbuffer = ReadDBuffer(dbuffer.Value, builder);
}
// Guidelines: In deferred by default there is no opaque in forward. However it is possible to force an opaque material to render in forward
@@ -458,11 +462,11 @@ void RenderForwardOpaque( RenderGraph renderGraph,
{
bool debugDisplay = m_CurrentDebugDisplaySettings.IsDebugDisplayEnabled();
- using (var builder = renderGraph.AddRenderPass( debugDisplay ? "Forward Opaque Debug" : "Forward Opaque",
+ using (var builder = renderGraph.AddRenderPass( debugDisplay ? "Forward Opaque Debug" : "Forward Opaque",
out var passData,
debugDisplay ? ProfilingSampler.Get(HDProfileId.ForwardOpaqueDebug) : ProfilingSampler.Get(HDProfileId.ForwardOpaque)))
{
- PrepareForwardPassData(renderGraph, builder, passData, true, hdCamera.frameSettings, PrepareForwardOpaqueRendererList(cullResults, hdCamera), lightLists, depthBuffer, shadowResult, dbuffer);
+ PrepareCommonForwardPassData(renderGraph, builder, passData, true, hdCamera.frameSettings, PrepareForwardOpaqueRendererList(cullResults, hdCamera), lightLists, depthBuffer, shadowResult);
// In case of forward SSS we will bind all the required target. It is up to the shader to write into it or not.
if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.SubsurfaceScattering))
@@ -478,18 +482,19 @@ void RenderForwardOpaque( RenderGraph renderGraph,
passData.renderTargetCount = 1;
}
- ReadLightingBuffers(lightingBuffers, builder);
+ passData.dbuffer = ReadDBuffer(dbuffer, builder);
+ passData.lightingBuffers = ReadLightingBuffers(lightingBuffers, builder);
builder.SetRenderFunc(
- (ForwardPassData data, RenderGraphContext context) =>
+ (ForwardOpaquePassData data, RenderGraphContext context) =>
{
// TODO RENDERGRAPH: replace with UseColorBuffer when removing old rendering (SetRenderTarget is called inside RenderForwardRendererList because of that).
var mrt = context.renderGraphPool.GetTempArray(data.renderTargetCount);
for (int i = 0; i < data.renderTargetCount; ++i)
mrt[i] = data.renderTarget[i];
- if (data.dbuffer != null)
- BindDBufferGlobalData(data.dbuffer.Value, context);
+ BindDBufferGlobalData(data.dbuffer, context);
+ BindGlobalLightingBuffers(data.lightingBuffers, context.cmd);
RenderForwardRendererList(data.frameSettings, data.rendererList, mrt, data.depthBuffer, data.lightListBuffer, true, context.renderContext, context.cmd);
});
@@ -501,6 +506,7 @@ void RenderForwardTransparent( RenderGraph renderGraph,
TextureHandle colorBuffer,
TextureHandle motionVectorBuffer,
TextureHandle depthBuffer,
+ TextureHandle volumetricLighting,
TextureHandle ssrLighting,
TextureHandle? colorPyramid,
in BuildGPULightListOutput lightLists,
@@ -526,18 +532,20 @@ void RenderForwardTransparent( RenderGraph renderGraph,
profilingId = preRefractionPass ? HDProfileId.ForwardPreRefraction : HDProfileId.ForwardTransparent;
}
- using (var builder = renderGraph.AddRenderPass(passName, out var passData, ProfilingSampler.Get(profilingId)))
+ using (var builder = renderGraph.AddRenderPass(passName, out var passData, ProfilingSampler.Get(profilingId)))
{
- PrepareForwardPassData(renderGraph, builder, passData, false, hdCamera.frameSettings, PrepareForwardTransparentRendererList(cullResults, hdCamera, preRefractionPass), lightLists, depthBuffer, shadowResult);
-
- passData.ssrLlightingBuffer = builder.ReadTexture(ssrLighting);
-
- bool renderMotionVecForTransparent = NeedMotionVectorForTransparent(hdCamera.frameSettings);
+ PrepareCommonForwardPassData(renderGraph, builder, passData, false, hdCamera.frameSettings, PrepareForwardTransparentRendererList(cullResults, hdCamera, preRefractionPass), lightLists, depthBuffer, shadowResult);
+ // enable d-buffer flag value is being interpreted more like enable decals in general now that we have clustered
+ // decal datas count is 0 if no decals affect transparency
+ passData.decalsEnabled = (hdCamera.frameSettings.IsEnabled(FrameSettingsField.Decals)) && (DecalSystem.m_DecalDatasCount > 0);
+ passData.renderMotionVecForTransparent = NeedMotionVectorForTransparent(hdCamera.frameSettings);
+ passData.volumetricLighting = builder.ReadTexture(volumetricLighting);
+ passData.transparentSSRLighting = builder.ReadTexture(ssrLighting);
passData.renderTargetCount = 2;
passData.renderTarget[0] = builder.WriteTexture(colorBuffer);
- if (renderMotionVecForTransparent)
+ if (passData.renderMotionVecForTransparent)
{
passData.renderTarget[1] = builder.WriteTexture(motionVectorBuffer);
}
@@ -555,7 +563,7 @@ void RenderForwardTransparent( RenderGraph renderGraph,
}
builder.SetRenderFunc(
- (ForwardPassData data, RenderGraphContext context) =>
+ (ForwardTransparentPassData data, RenderGraphContext context) =>
{
// TODO: replace with UseColorBuffer when removing old rendering.
var mrt = context.renderGraphPool.GetTempArray(data.renderTargetCount);
@@ -569,7 +577,8 @@ void RenderForwardTransparent( RenderGraph renderGraph,
context.cmd.SetGlobalBuffer(HDShaderIDs.g_vLayeredOffsetsBuffer, data.perVoxelOffset);
context.cmd.SetGlobalBuffer(HDShaderIDs.g_logBaseBuffer, data.perTileLogBaseTweak);
- context.cmd.SetGlobalTexture(HDShaderIDs._SsrLightingTexture, data.ssrLlightingBuffer);
+ context.cmd.SetGlobalTexture(HDShaderIDs._SsrLightingTexture, data.transparentSSRLighting);
+ context.cmd.SetGlobalTexture(HDShaderIDs._VBufferLighting, data.volumetricLighting);
RenderForwardRendererList( data.frameSettings, data.rendererList, mrt, data.depthBuffer, data.lightListBuffer, false, context.renderContext, context.cmd);
});
@@ -738,6 +747,7 @@ TextureHandle RenderTransparency( RenderGraph renderGraph,
HDCamera hdCamera,
TextureHandle colorBuffer,
TextureHandle currentColorPyramid,
+ TextureHandle volumetricLighting,
in BuildGPULightListOutput lightLists,
ref PrepassOutput prepassOutput,
ShadowResult shadowResult,
@@ -760,7 +770,7 @@ TextureHandle RenderTransparency( RenderGraph renderGraph,
RenderCustomPass(m_RenderGraph, hdCamera, colorBuffer, prepassOutput.depthBuffer, prepassOutput.normalBuffer, customPassCullingResults, CustomPassInjectionPoint.BeforePreRefraction, aovRequest, aovBuffers);
// Render pre-refraction objects
- RenderForwardTransparent(renderGraph, hdCamera, colorBuffer, prepassOutput.motionVectorsBuffer, prepassOutput.depthBuffer, ssrLightingBuffer, null, lightLists, shadowResult, cullingResults, true);
+ RenderForwardTransparent(renderGraph, hdCamera, colorBuffer, prepassOutput.motionVectorsBuffer, prepassOutput.depthBuffer, volumetricLighting, ssrLightingBuffer, null, lightLists, shadowResult, cullingResults, true);
if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.Refraction))
{
@@ -772,7 +782,7 @@ TextureHandle RenderTransparency( RenderGraph renderGraph,
RenderCustomPass(m_RenderGraph, hdCamera, colorBuffer, prepassOutput.depthBuffer, prepassOutput.normalBuffer, customPassCullingResults, CustomPassInjectionPoint.BeforeTransparent, aovRequest, aovBuffers);
// Render all type of transparent forward (unlit, lit, complex (hair...)) to keep the sorting between transparent objects.
- RenderForwardTransparent(renderGraph, hdCamera, colorBuffer, prepassOutput.motionVectorsBuffer, prepassOutput.depthBuffer, ssrLightingBuffer, currentColorPyramid, lightLists, shadowResult, cullingResults, false);
+ RenderForwardTransparent(renderGraph, hdCamera, colorBuffer, prepassOutput.motionVectorsBuffer, prepassOutput.depthBuffer, volumetricLighting, ssrLightingBuffer, currentColorPyramid, lightLists, shadowResult, cullingResults, false);
colorBuffer = ResolveMSAAColor(renderGraph, hdCamera, colorBuffer, m_NonMSAAColorBuffer);
@@ -966,6 +976,7 @@ class RenderSkyPassData
public HDCamera hdCamera;
public TextureHandle volumetricLighting;
public TextureHandle colorBuffer;
+ public TextureHandle depthTexture;
public TextureHandle depthStencilBuffer;
public TextureHandle intermediateBuffer;
public DebugDisplaySettings debugDisplaySettings;
@@ -987,14 +998,13 @@ void RenderSky(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle colorBu
passData.hdCamera = hdCamera;
passData.volumetricLighting = builder.ReadTexture(volumetricLighting);
passData.colorBuffer = builder.WriteTexture(colorBuffer);
+ passData.depthTexture = builder.WriteTexture(depthTexture);
passData.depthStencilBuffer = builder.WriteTexture(depthStencilBuffer);
passData.intermediateBuffer = builder.CreateTransientTexture(colorBuffer);
passData.debugDisplaySettings = m_CurrentDebugDisplaySettings;
passData.skyManager = m_SkyManager;
passData.frameCount = m_FrameCount;
- builder.ReadTexture(depthTexture);
-
builder.SetRenderFunc(
(RenderSkyPassData data, RenderGraphContext context) =>
{
@@ -1006,7 +1016,7 @@ void RenderSky(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle colorBu
if (Fog.IsFogEnabled(data.hdCamera) || Fog.IsPBRFogEnabled(data.hdCamera))
{
var pixelCoordToViewDirWS = data.hdCamera.mainViewConstants.pixelCoordToViewDirWS;
- data.skyManager.RenderOpaqueAtmosphericScattering(context.cmd, data.hdCamera, data.colorBuffer, data.volumetricLighting, data.intermediateBuffer, data.depthStencilBuffer, pixelCoordToViewDirWS, data.hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA));
+ data.skyManager.RenderOpaqueAtmosphericScattering(context.cmd, data.hdCamera, data.colorBuffer, data.depthTexture, data.volumetricLighting, data.intermediateBuffer, data.depthStencilBuffer, pixelCoordToViewDirWS, data.hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA));
}
});
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
index 1bf6d41933b..fc95a564c36 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
@@ -2625,12 +2625,13 @@ void Callback(CommandBuffer c, HDGPUAsyncTaskParams a)
{
var depthTexture = m_SharedRTManager.GetDepthTexture();
var normalBuffer = m_SharedRTManager.GetNormalBuffer();
+ var motionVectors = m_SharedRTManager.GetMotionVectorsBuffer();
SSAOTask.Start(cmd, asyncParams, AsyncSSAODispatch, !haveAsyncTaskWithShadows);
haveAsyncTaskWithShadows = true;
void AsyncSSAODispatch(CommandBuffer c, HDGPUAsyncTaskParams a)
- => m_AmbientOcclusionSystem.Dispatch(c, a.hdCamera, depthTexture, normalBuffer, a.frameCount);
+ => m_AmbientOcclusionSystem.Dispatch(c, a.hdCamera, depthTexture, normalBuffer, motionVectors, a.frameCount);
}
using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.RenderShadowMaps)))
@@ -2694,7 +2695,7 @@ void Callback(CommandBuffer c, HDCamera cam)
}
if (!hdCamera.frameSettings.SSAORunsAsync())
- m_AmbientOcclusionSystem.Render(cmd, hdCamera, renderContext, m_SharedRTManager.GetDepthTexture(), m_SharedRTManager.GetNormalBuffer(), m_ShaderVariablesRayTracingCB, m_FrameCount);
+ m_AmbientOcclusionSystem.Render(cmd, hdCamera, renderContext, m_SharedRTManager.GetDepthTexture(), m_SharedRTManager.GetNormalBuffer(), m_SharedRTManager.GetMotionVectorsBuffer(), m_ShaderVariablesRayTracingCB, m_FrameCount);
// Run the contact shadows here as they need the light list
HDUtils.CheckRTCreated(m_ContactShadowBuffer);
@@ -4123,7 +4124,7 @@ void RenderSky(HDCamera hdCamera, CommandBuffer cmd)
if (Fog.IsFogEnabled(hdCamera) || Fog.IsPBRFogEnabled(hdCamera))
{
var pixelCoordToViewDirWS = hdCamera.mainViewConstants.pixelCoordToViewDirWS;
- m_SkyManager.RenderOpaqueAtmosphericScattering(cmd, hdCamera, colorBuffer, m_LightingBuffer, intermediateBuffer, depthBuffer, pixelCoordToViewDirWS, hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA));
+ m_SkyManager.RenderOpaqueAtmosphericScattering(cmd, hdCamera, colorBuffer, m_SharedRTManager.GetDepthTexture(msaaEnabled), m_LightingBuffer, intermediateBuffer, depthBuffer, pixelCoordToViewDirWS, hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA));
}
}
@@ -4633,6 +4634,7 @@ static void RenderSSR( in RenderSSRParameters parameters,
cmd.SetComputeTextureParam(cs, parameters.reprojectionKernel, HDShaderIDs._ColorPyramidTexture, previousColorPyramid);
cmd.SetComputeTextureParam(cs, parameters.reprojectionKernel, HDShaderIDs._SsrClearCoatMaskTexture, clearCoatMask);
cmd.SetComputeTextureParam(cs, parameters.reprojectionKernel, HDShaderIDs._CameraMotionVectorsTexture, motionVectorsBuffer);
+ cmd.SetComputeTextureParam(cs, parameters.reprojectionKernel, HDShaderIDs._NormalBufferTexture, normalBuffer);
ConstantBuffer.Push(cmd, parameters.cb, cs, HDShaderIDs._ShaderVariablesScreenSpaceReflection);
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs
index c43119a1969..ad7d2c006c1 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs
@@ -179,6 +179,7 @@ static class HDShaderIDs
public static readonly int _ContactShadowTextureUAV = Shader.PropertyToID("_ContactShadowTextureUAV");
public static readonly int _ContactShadowParamsParameters = Shader.PropertyToID("_ContactShadowParamsParameters");
public static readonly int _ContactShadowParamsParameters2 = Shader.PropertyToID("_ContactShadowParamsParameters2");
+ public static readonly int _ContactShadowParamsParameters3 = Shader.PropertyToID("_ContactShadowParamsParameters3");
public static readonly int _DirectionalContactShadowSampleCount = Shader.PropertyToID("_SampleCount");
public static readonly int _ShadowFrustumPlanes = Shader.PropertyToID("_ShadowFrustumPlanes");
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingBSDF.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingBSDF.hlsl
index 526b983bb9f..a56b52c75bb 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingBSDF.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingBSDF.hlsl
@@ -478,7 +478,7 @@ bool RandomWalk(float3 position, float3 normal, float3 diffuseColor, float3 mean
// Evaluate the length of our steps
rayDesc.TMax = -log(1.0 - distSample) / sigmaT[channelIdx];
- // Sample our next sepath segment direction
+ // Sample our next path segment direction
rayDesc.Direction = walkIdx ?
SampleSphereUniform(dirSample0, dirSample1) : SampleHemisphereCosine(dirSample0, dirSample1, -normal);
@@ -489,7 +489,7 @@ bool RandomWalk(float3 position, float3 normal, float3 diffuseColor, float3 mean
TraceRay(_RaytracingAccelerationStructure, RAY_FLAG_FORCE_OPAQUE | RAY_FLAG_CULL_FRONT_FACING_TRIANGLES,
RAYTRACINGRENDERERFLAG_PATH_TRACING, 0, 1, 1, rayDesc, intersection);
- // Define if we did a hit
+ // Check if we hit something
hit = intersection.t > 0.0;
// How much did the ray travel?
@@ -513,10 +513,24 @@ bool RandomWalk(float3 position, float3 normal, float3 diffuseColor, float3 mean
while (!hit && walkIdx < MAX_WALK_STEPS);
// Set the exit intersection position and normal
- result.exitPosition = rayDesc.Origin;
- result.exitNormal = intersection.value;
+ if (!hit)
+ {
+ result.exitPosition = position;
+ result.exitNormal = normal;
+ result.throughput = diffuseColor;
+
+ // By not returning false here, we default to a diffuse BRDF when an intersection is not found;
+ // this is physically wrong, but may prove more convenient for a user, as results will look
+ // like diffuse instead of getting slightly darker when the mean free path becomes shorter.
+ //return false;
+ }
+ else
+ {
+ result.exitPosition = rayDesc.Origin;
+ result.exitNormal = intersection.value;
+ }
- return hit;
+ return true;
}
} // namespace SSS
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Shader/DefaultCloudLayerShader.shader b/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Shader/DefaultCloudLayerShader.shader
index bef2212f91a..9d27c22d649 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Shader/DefaultCloudLayerShader.shader
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Shader/DefaultCloudLayerShader.shader
@@ -1,48 +1,50 @@
-Shader "Hidden/DefaultCloudLayer"
-{
- Properties
- {
- [NoScaleOffset]
- _Tex("Cloud Texture", 2D) = "white" {}
-
- Opacity_R("Cumulus Opacity", Range(0,1)) = 1
- Opacity_G("Stratus Opacity", Range(0,1)) = 0.25
- Opacity_B("Cirrus Opacity", Range(0,1)) = 1
- Opacity_A("Wispy Opacity", Range(0,1)) = 0.1
- }
-
- SubShader
- {
- Lighting Off
- Blend One Zero
-
- Pass
- {
- CGPROGRAM
-
- #include "UnityCustomRenderTexture.cginc"
- #pragma vertex CustomRenderTextureVertexShader
- #pragma fragment frag
- #pragma target 3.0
-
- sampler2D _Tex;
- float Opacity_R;
- float Opacity_G;
- float Opacity_B;
- float Opacity_A;
-
- float4 frag(v2f_customrendertexture IN) : COLOR
- {
- float2 UV = float2 (IN.localTexcoord.x, IN.localTexcoord.y);
- float4 opacity = float4(Opacity_R, Opacity_G, Opacity_B, Opacity_A);
- float4 clouds = tex2D(_Tex, UV) * opacity;
-
- return max(max(clouds.r, clouds.g), max(clouds.b, clouds.a));
- }
-
- ENDCG
- }
- }
- Fallback Off
- CustomEditor "Rendering.HighDefinition.DefaultCloudLayerGUI"
-}
+Shader "Hidden/DefaultCloudLayer"
+{
+ Properties
+ {
+ [NoScaleOffset]
+ _Tex("Cloud Texture", 2D) = "white" {}
+
+ Opacity_R("Cumulus Opacity", Range(0,1)) = 1
+ Opacity_G("Stratus Opacity", Range(0,1)) = 0.25
+ Opacity_B("Cirrus Opacity", Range(0,1)) = 1
+ Opacity_A("Wispy Opacity", Range(0,1)) = 0.1
+ }
+
+ SubShader
+ {
+ Lighting Off
+ Blend One Zero
+
+ Pass
+ {
+ Name "Cloud Map"
+
+ CGPROGRAM
+
+ #include "UnityCustomRenderTexture.cginc"
+ #pragma vertex CustomRenderTextureVertexShader
+ #pragma fragment frag
+ #pragma target 3.0
+
+ sampler2D _Tex;
+ float Opacity_R;
+ float Opacity_G;
+ float Opacity_B;
+ float Opacity_A;
+
+ float4 frag(v2f_customrendertexture IN) : COLOR
+ {
+ float2 UV = float2 (IN.localTexcoord.x, IN.localTexcoord.y);
+ float4 opacity = float4(Opacity_R, Opacity_G, Opacity_B, Opacity_A);
+ float4 clouds = tex2D(_Tex, UV) * opacity;
+
+ return max(max(clouds.r, clouds.g), max(clouds.b, clouds.a));
+ }
+
+ ENDCG
+ }
+ }
+ Fallback Off
+ CustomEditor "Rendering.HighDefinition.DefaultCloudLayerGUI"
+}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Texture/DefaultCloudLayer.asset b/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Texture/DefaultCloudLayer.asset
index 86fa47e3ea5..90c07aa77cd 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Texture/DefaultCloudLayer.asset
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Texture/DefaultCloudLayer.asset
@@ -19,7 +19,7 @@ CustomRenderTexture:
m_AntiAliasing: 1
m_MipCount: -1
m_DepthFormat: 0
- m_ColorFormat: 8
+ m_ColorFormat: 9
m_MipMap: 0
m_GenerateMips: 1
m_SRGB: 0
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/CloudLayer/CloudLayer.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/CloudLayer/CloudLayer.cs
index 10815785e6d..31f980f39e1 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Sky/CloudLayer/CloudLayer.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/CloudLayer/CloudLayer.cs
@@ -43,7 +43,7 @@ public class CloudLayer : VolumeComponent
public ClampedFloatParameter scrollDirection = new ClampedFloatParameter(0.0f, 0.0f, 360.0f);
/// Speed of the distortion.
[Tooltip("Sets the cloud scrolling speed. The higher the value, the faster the clouds will move.")]
- public MinFloatParameter scrollSpeed = new MinFloatParameter(2.0f, 0.0f);
+ public MinFloatParameter scrollSpeed = new MinFloatParameter(1.0f, 0.0f);
private float scrollFactor = 0.0f, lastTime = 0.0f;
@@ -60,9 +60,6 @@ public class CloudLayer : VolumeComponent
/// The shader parameters of the cloud layer.
public Vector4 GetParameters()
{
- scrollFactor += scrollSpeed.value * (Time.time - lastTime) * 0.01f;
- lastTime = Time.time;
-
float rot = -Mathf.Deg2Rad*scrollDirection.value;
float upper = upperHemisphereOnly.value ? 1.0f : -1.0f;
return new Vector4(upper * (rotation.value / 360.0f + 1), scrollFactor, Mathf.Cos(rot), Mathf.Sin(rot));
@@ -75,6 +72,9 @@ public static void Apply(CloudLayer layer, Material skyMaterial)
{
if (layer != null && layer.enabled.value == true)
{
+ layer.scrollFactor += layer.scrollSpeed.value * (Time.time - layer.lastTime) * 0.01f;
+ layer.lastTime = Time.time;
+
Vector4 cloudParam = layer.GetParameters();
Vector4 cloudParam2 = layer.tint.value;
cloudParam2.w = layer.intensityMultiplier.value;
@@ -112,33 +112,8 @@ public override int GetHashCode()
unchecked
{
-#if UNITY_2019_3 // In 2019.3, when we call GetHashCode on a VolumeParameter it generate garbage (due to the boxing of the generic parameter)
- hash = cloudMap.value != null ? hash * 23 + cloudMap.value.GetHashCode() : hash;
- hash = flowmap.value != null ? hash * 23 + flowmap.value.GetHashCode() : hash;
- hash = hash * 23 + enabled.value.GetHashCode();
- hash = hash * 23 + upperHemisphereOnly.value.GetHashCode();
- hash = hash * 23 + tint.value.GetHashCode();
- hash = hash * 23 + intensityMultiplier.value.GetHashCode();
- hash = hash * 23 + rotation.value.GetHashCode();
- hash = hash * 23 + enableDistortion.value.GetHashCode();
- hash = hash * 23 + procedural.value.GetHashCode();
- hash = hash * 23 + scrollDirection.value.GetHashCode();
- hash = hash * 23 + scrollSpeed.value.GetHashCode();
-
- hash = cloudMap.value != null ? hash * 23 + cloudMap.overrideState.GetHashCode() : hash;
- hash = flowmap.value != null ? hash * 23 + flowmap.overrideState.GetHashCode() : hash;
- hash = hash * 23 + enabled.overrideState.GetHashCode();
- hash = hash * 23 + upperHemisphereOnly.overrideState.GetHashCode();
- hash = hash * 23 + tint.overrideState.GetHashCode();
- hash = hash * 23 + intensityMultiplier.overrideState.GetHashCode();
- hash = hash * 23 + rotation.overrideState.GetHashCode();
- hash = hash * 23 + enableDistortion.overrideState.GetHashCode();
- hash = hash * 23 + procedural.overrideState.GetHashCode();
- hash = hash * 23 + scrollDirection.overrideState.GetHashCode();
- hash = hash * 23 + scrollSpeed.overrideState.GetHashCode();
-#else
- hash = cloudMap.value != null ? hash * 23 + cloudMap.GetHashCode() : hash;
- hash = flowmap.value != null ? hash * 23 + flowmap.GetHashCode() : hash;
+ hash = hash * 23 + cloudMap.GetHashCode();
+ hash = hash * 23 + flowmap.GetHashCode();
hash = hash * 23 + enabled.GetHashCode();
hash = hash * 23 + upperHemisphereOnly.GetHashCode();
hash = hash * 23 + tint.GetHashCode();
@@ -148,7 +123,6 @@ public override int GetHashCode()
hash = hash * 23 + procedural.GetHashCode();
hash = hash * 23 + scrollDirection.GetHashCode();
hash = hash * 23 + scrollSpeed.GetHashCode();
-#endif
}
return hash;
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/CloudLayer/CloudLayer.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Sky/CloudLayer/CloudLayer.hlsl
index e5614ad87d9..67cff3b0161 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Sky/CloudLayer/CloudLayer.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/CloudLayer/CloudLayer.hlsl
@@ -19,12 +19,13 @@ float4 _CloudParam2; // xyz tint, w intensity
#define USE_CLOUD_LAYER defined(USE_CLOUD_MAP) || (!defined(USE_CLOUD_MAP) && defined(USE_CLOUD_MOTION))
-float3 sampleCloud(float3 dir, float3 sky)
+float4 sampleCloud(float3 dir)
{
float2 coords = GetLatLongCoords(dir, _CloudUpperHemisphere);
coords.x = frac(coords.x + _CloudRotation);
- float4 cloudLayerColor = SAMPLE_TEXTURE2D_LOD(_CloudMap, sampler_CloudMap, coords, 0);
- return lerp(sky, sky + cloudLayerColor.rgb * _CloudTint * _CloudIntensity, cloudLayerColor.a);
+ float4 cloudLayerColor = SAMPLE_TEXTURE2D_LOD(_CloudMap, sampler_CloudMap, coords, 0).r;
+ cloudLayerColor.rgb *= _CloudTint * _CloudIntensity * cloudLayerColor.a;
+ return cloudLayerColor;
}
float3 CloudRotationUp(float3 p, float2 cos_sin)
@@ -35,46 +36,53 @@ float3 CloudRotationUp(float3 p, float2 cos_sin)
return float3(dot(rotDirX, p), p.y, dot(rotDirY, p));
}
-float3 GetDistordedCloudColor(float3 dir, float3 sky)
+float4 GetDistordedCloudColor(float3 dir)
{
#if USE_CLOUD_MOTION
- if (dir.y >= 0 || !_CloudUpperHemisphere)
- {
- float2 alpha = frac(float2(_CloudScrollFactor, _CloudScrollFactor + 0.5)) - 0.5;
+ float2 alpha = frac(float2(_CloudScrollFactor, _CloudScrollFactor + 0.5)) - 0.5;
#ifdef USE_CLOUD_MAP
- float3 tangent = normalize(cross(dir, float3(0.0, 1.0, 0.0)));
- float3 bitangent = cross(tangent, dir);
+ float3 tangent = normalize(cross(dir, float3(0.0, 1.0, 0.0)));
+ float3 bitangent = cross(tangent, dir);
- float3 windDir = CloudRotationUp(dir, _CloudScrollDirection);
- float2 flow = SAMPLE_TEXTURE2D_LOD(_CloudFlowmap, sampler_CloudFlowmap, GetLatLongCoords(windDir, _CloudUpperHemisphere), 0).rg * 2.0 - 1.0;
+ float3 windDir = CloudRotationUp(dir, _CloudScrollDirection);
+ float2 flow = SAMPLE_TEXTURE2D_LOD(_CloudFlowmap, sampler_CloudFlowmap, GetLatLongCoords(windDir, _CloudUpperHemisphere), 0).rg * 2.0 - 1.0;
- float3 dd = flow.x * tangent + flow.y * bitangent;
+ float3 dd = flow.x * tangent + flow.y * bitangent;
#else
- float3 windDir = CloudRotationUp(float3(0, 0, 1), _CloudScrollDirection);
- windDir.x *= -1.0;
- float3 dd = windDir*sin(dir.y*PI*0.5);
+ float3 windDir = CloudRotationUp(float3(0, 0, 1), _CloudScrollDirection);
+ windDir.x *= -1.0;
+ float3 dd = windDir*sin(dir.y*PI*0.5);
#endif
- // Sample twice
- float3 color1 = sampleCloud(normalize(dir - alpha.x * dd), sky);
- float3 color2 = sampleCloud(normalize(dir - alpha.y * dd), sky);
+ // Sample twice
+ float4 color1 = sampleCloud(normalize(dir - alpha.x * dd));
+ float4 color2 = sampleCloud(normalize(dir - alpha.y * dd));
- // Blend color samples
- sky = lerp(color1, color2, abs(2.0 * alpha.x));
- }
- return sky;
+ // Blend color samples
+ return lerp(color1, color2, abs(2.0 * alpha.x));
#else
- return sampleCloud(dir, sky);
+ return sampleCloud(dir);
#endif
}
+float GetCloudOpacity(float3 dir)
+{
+#if USE_CLOUD_LAYER
+ if (dir.y >= 0 || !_CloudUpperHemisphere)
+ return GetDistordedCloudColor(dir).a;
+ else
+#endif
+
+ return 0;
+}
+
float3 ApplyCloudLayer(float3 dir, float3 sky)
{
#if USE_CLOUD_LAYER
if (dir.y >= 0 || !_CloudUpperHemisphere)
- sky = GetDistordedCloudColor(dir, sky);
+ sky += GetDistordedCloudColor(dir).rgb;
#endif
return sky;
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs
index a68ed110d27..4bd8e47cb1e 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs
@@ -670,7 +670,7 @@ int ComputeSkyHash(HDCamera camera, SkyUpdateContext skyContext, Light sunLight,
sunHash = GetSunLightHashCode(sunLight);
int cloudHash = 0;
- if (skyContext.cloudLayer != null && skyContext.skyRenderer.SupportCloudLayer)
+ if (skyContext.cloudLayer != null && skyContext.skyRenderer.SupportDynamicCloudLayer)
cloudHash = skyContext.cloudLayer.GetHashCode();
// For planar reflections we want to use the parent position for hash.
@@ -932,6 +932,7 @@ public void RenderSky(HDCamera hdCamera, Light sunLight, RTHandle colorBuffer, R
public void RenderOpaqueAtmosphericScattering(CommandBuffer cmd, HDCamera hdCamera,
RTHandle colorBuffer,
+ RTHandle depthTexture,
RTHandle volumetricLighting,
RTHandle intermediateBuffer,
RTHandle depthBuffer,
@@ -940,16 +941,16 @@ public void RenderOpaqueAtmosphericScattering(CommandBuffer cmd, HDCamera hdCame
using (new ProfilingScope(m_BuiltinParameters.commandBuffer, ProfilingSampler.Get(HDProfileId.OpaqueAtmosphericScattering)))
{
m_OpaqueAtmScatteringBlock.SetMatrix(HDShaderIDs._PixelCoordToViewDirWS, pixelCoordToViewDirWS);
- if (isMSAA)
- m_OpaqueAtmScatteringBlock.SetTexture(HDShaderIDs._ColorTextureMS, colorBuffer);
- else
- m_OpaqueAtmScatteringBlock.SetTexture(HDShaderIDs._ColorTexture, colorBuffer);
+ m_OpaqueAtmScatteringBlock.SetTexture(isMSAA ? HDShaderIDs._DepthTextureMS : HDShaderIDs._CameraDepthTexture, depthTexture);
+
// The texture can be null when volumetrics are disabled.
if (volumetricLighting != null)
m_OpaqueAtmScatteringBlock.SetTexture(HDShaderIDs._VBufferLighting, volumetricLighting);
if (Fog.IsPBRFogEnabled(hdCamera))
{
+ m_OpaqueAtmScatteringBlock.SetTexture(isMSAA? HDShaderIDs._ColorTextureMS : HDShaderIDs._ColorTexture, colorBuffer);
+
// Color -> Intermediate.
HDUtils.DrawFullScreen(cmd, m_OpaqueAtmScatteringMaterial, intermediateBuffer, depthBuffer, m_OpaqueAtmScatteringBlock, isMSAA ? 3 : 2);
// Intermediate -> Color.
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyRenderer.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyRenderer.cs
index 64d226a480b..2449c1b37ed 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyRenderer.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyRenderer.cs
@@ -10,7 +10,7 @@ public abstract class SkyRenderer
/// Determines if the sky should be rendered when the sun light changes.
public bool SupportDynamicSunLight = true;
/// Determines if the sky should be rendered when the cloud layer changes.
- public bool SupportCloudLayer = true;
+ public bool SupportDynamicCloudLayer = true;
///
/// Called on startup. Create resources used by the renderer (shaders, materials, etc).