Skip to content

Commit fd02566

Browse files
sebastienlagardepmavridisFrancescoC-unityjohnparsanisunity
authored
[HDRP] Merge Hd/bugfix (#4943)
* [HDRP] Fix AxF debug output in certain configurations (#4641) * Fix AxF debug output in certain configurations. * Update comment * Fix SSR accumulation white flash (#4648) * Fix white flash * changelog Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Display Info Box when MSAA + ray tracing is onr (#4627) * Show info box when ray tracing is enabled. * Changelog * Move below MSAA Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Fix distortion when resizing the window in player builds with the Graphics Compositor enabled (#4593) Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Add support for the camera bridge in the graphics compositor (#4599) * Fix Jittered Project Matrix Infinite Far Clip Plane (#4638) * Reconstruct jittered projection matrix far plane (for Infinite ) * Changelog Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Fixed a memory leak related to not disposing of the RTAS at the end HDRP's lifecycle. (#4688) Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Fix custom pass utils Blur + Copy overdraw. (#4623) * Fix overdraw in custom pass utils blur function * Updated changelog Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Fix draw procedural invalid pass idx 1 on first template load (#4632) * Fix * changelog * Force sync compilation for TAA Co-authored-by: CifaCia <f.cifariellociardi@gmail.com> Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Changed light reset to preserve type (#4624) Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Revert "Add support for the camera bridge in the graphics compositor (#4599)" This reverts commit 2325e3f. * AxF carpaint: Fix a compilation issue on Vulkan until the cpp HLSLcc side is updated. (case 1335737, related to 1314040) (#4691) Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Revert "Revert "Add support for the camera bridge in the graphics compositor (#4599)"" This reverts commit 30fffd5. * revert: Fix distortion when resizing the window in player builds with the Graphi * Fixed the ray traced sub subsurface scattering debug mode not displaying only the RTSSS Data (case 1332904). (#4626) * Fixed the ray traced sub subsurface scattering debug mode not displaying only the RTSSS Data (case 1332904). * Add test scene Co-authored-by: Remi Chapelain <remi.chapelain@unity3d.com> Co-authored-by: Sebastien Lagarde <sebastien@unity3d.com> * Fix for discrepancies in saturation and intensity between screen space refraction and probe refraction (#4653) * Delete the second transmittance mul * Changelog Co-authored-by: Sebastien Lagarde <sebastien@unity3d.com> * Fix a Divide-by-Zero Warning for some Anisotropic Models (Fabric, Lit) (#4636) * Initialize the shading normal to a non-zero value for anisotropy * Changelog Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * [HDRP] Fix VfX lit particle AOV output color space (#4646) * Fix VfX lit particle aov output color space * Update comment Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * [HDRP][Path Tracing] Fixed transparent unlit (#4605) * Fixed issue with transparent unlit. * Updated changelog. * Reverted accidental change to default mtl. Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Fix distortion with MSAA (#4711) * Fix contact shadow debug views (#4720) * Fix * changelog Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Update Decal-Projector.md (#4695) * [HDRP] Fixed nullref when deleting the texture asset assigned in a local volumetric fog volume (#4728) * Fixed nullref when deleting the 3D mask of a density volume (case 1339330) * Updated changelog Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Fix decal layer enum (#4753) * Fix typo * Fixed reflection probes being injected into the ray tracing light cluster even if not baked (case 1329083). (#4640) Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Ignore hybrid duplicated reflection probes during light baking (#4663) * Ignore hybrid duplicated reflection probes during light baking * test path instead of scene Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Fix double sided option moving when toggling it in the material UI (#4725) * Fix double sided option moving when toggling it in the material UI (case 1328877) * Updated changelog Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Fix formatting * Fix volumetric fog in planar reflections (#4736) * Fix planar reflection * changelog Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Fix motion blur compute dispatch size (#4737) Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * - Updated the recursive rendering documentation (case 1338639). (#4759) * - Updated the recursive rendering documentation (case 1338639). * review fixes Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Fix issue with OnDemand directional shadow map being corrupted when reflection probe are updated same frame (#4812) * Don't mark as rendered for reflection probes as we want the cached version to be from main view * Do the thing just for directional * Doc update * changelog Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Fix cropping issue with the compositor camera bridge (#4802) Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Fix for unused resources in depth of field (#4796) * Removing the word Radii from exposure settings (#4854) * Rename in UX * Update docs * [HDRP][Path Tracing] Support for shadow mattes (#4745) * Shadow matte support. * Updated changelog. * Only take occluders into account, closer match to raster mode. * Added test scene. Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Revert "[HDRP][Path Tracing] Support for shadow mattes (#4745)" This reverts commit 85ebbc2. * Fixed the transparent cutoff not working properly in semi-transparent and color shadows (case 1340234). (#4756) * Fixed the transparent cutoff not working properly in semi-transparent and color shadows (case 1340234). * Update test ref image Co-authored-by: Remi Chapelain <remi.chapelain@unity3d.com> Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Use non jittered projection in outline pass (#4836) Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * [HDRP][Path Tracing] Sky settings now properly taken into account when using recorder (#4856) * Make sure sky settings are correctly set when recording. * Updated changelog. Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Fix Resolution Issues for Physically Based Depth of Field (#4848) * Add the necesarry texture coordinate clamping for RTHandle for color pyramid sampling * Add some resolution independence, fitted for 1920x1080 * Changelog * Switch back to point sampling from trilinear, with commentary * Update test reference images * Small correction to the point sampling, always sample mip 0. * Re-update the test images, for mip 0 color sampling * Use a simpler UV scaling/clamping since we are now point sampling. Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Fixed bug introduced by sky-for-recorder support. (#4906) * [Fogbugz 1341576] Memory leaks when the player is paused, and the user changes pipeline… (#4845) * Memory leaks when the player is paused, and the user changes pipeline settings * changelog * [HDRP] Fixed shadergraph double save (#4916) * Don't need to save twice shadergraph the first time we create a graph * Updated changelog * Write 0 instead of micro sized motion vectors + fix extremely fast velocities (#4820) * Kill micromovements. * Do same for camera * Debug view update * Changelog * Remove unnecessary comment * Fix excessive velocity end up marked as no velocity Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * [HDRP] Fix material upgrader (#4821) * Fix HDRP material upgrade failing when there is a texture inside the builtin resources assigned in the material * Updated changelog Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * [HDRP] Fix custom pass volume not executed in scene view (#4860) * Fix custom pass volume not executed in scene view because of the volume culling mask * Updated changelog Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Fix reflection probe tootltip (#4890) Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Updated the Physically Based Sky documentation for baked lights (#4891) * Updated the Physically Based Sky documentation for baked lights * Rewrite Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Fixed remapping of depth pyramid debug (#4893) * Fixed remapping of depth pyramid debug * Removed debug pragma * Update changelog * Updated tooltip * Fix wobble-like (or tearing-like) SSAO issues when temporal reprojection is enabled. (#4895) * Fix AO perceived wobble * changelog Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Fix Asymmetric Projection Matrices and Fog / Pathtracing (#4926) * Check for asymmetric projections and choose the generic path if so. * Fix asymmetric projections for the pathtracer ray generation. * Changelog * Simplify the matrix multiplication for computing the generic matrix. Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Revert: Fix wobble-like (or tearing-like) SSAO issues when temporal reprojection… Co-authored-by: Pavlos Mavridis <pavlos.mavridis@unity3d.com> Co-authored-by: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com> Co-authored-by: John Parsaie <johnpa@unity3d.com> Co-authored-by: anisunity <42026998+anisunity@users.noreply.github.com> Co-authored-by: Antoine Lelievre <antoinel@unity3d.com> Co-authored-by: CifaCia <f.cifariellociardi@gmail.com> Co-authored-by: Adrien de Tocqueville <adrien.tocqueville@unity3d.com> Co-authored-by: slunity <37302815+slunity@users.noreply.github.com> Co-authored-by: Remi Chapelain <remi.chapelain@unity3d.com> Co-authored-by: Emmanuel Turquin <emmanuel@turquin.org> Co-authored-by: Adrian1066 <44636759+Adrian1066@users.noreply.github.com> Co-authored-by: Kleber Garcia <kleber.garcia@unity3d.com> Co-authored-by: Julien Ignace <julien@unity3d.com>
1 parent 21888f7 commit fd02566

File tree

16 files changed

+112
-35
lines changed

16 files changed

+112
-35
lines changed

com.unity.render-pipelines.high-definition/CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7575
- Added support of motion vector buffer in custom postprocess
7676
- Added tooltips for content inside the Rendering Debugger window.
7777
- Added support for reflection probes as a fallback for ray traced reflections (case 1338644).
78+
- Added a minimum motion vector length to the motion vector debug view.
7879

7980
### Fixed
8081
- Fixed Intensity Multiplier not affecting realtime global illumination.
@@ -264,6 +265,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
264265
- Fixed an issue where disabled reflection probes were still sent into the the ray tracing light cluster.
265266
- Fixed nullref when enabling fullscreen passthrough in HDRP Camera.
266267
- Fixed tessellation displacement with planar mapping
268+
- Fixed the shader graph files that was still dirty after the first save (case 1342039).
269+
- Fixed cases in which object and camera motion vectors would cancel out, but didn't.
270+
- Fixed HDRP material upgrade failing when there is a texture inside the builtin resources assigned in the material (case 1339865).
271+
- Fixed custom pass volume not executed in scene view because of the volume culling mask.
272+
- Fixed remapping of depth pyramid debug view
273+
- Fixed an issue with asymmetric projection matrices and fog / pathtracing. (case 1330290).
267274

268275
### Changed
269276
- Changed Window/Render Pipeline/HD Render Pipeline Wizard to Window/Rendering/HDRP Wizard
@@ -350,7 +357,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
350357
- Display an info box and disable MSAA asset entry when ray tracing is enabled.
351358
- Changed light reset to preserve type.
352359
- Ignore hybrid duplicated reflection probes during light baking.
353-
- Updated the recursive rendering documentation (case 1338639).
354360
- Replaced the context menu by a search window when adding custom pass.
355361
- Moved supportRuntimeDebugDisplay option from HDRPAsset to HDRPGlobalSettings.
356362
- When a ray hits the sky in the ray marching part of mixed ray tracing, it is considered a miss.

com.unity.render-pipelines.high-definition/Documentation~/Override-Physically-Based-Sky.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Next, set the Volume to use **Physically Based Sky**. The [Visual Environment](O
2727

2828
To change how much the atmosphere attenuates light, you can change the density of both air and aerosol molecules (participating media) in the atmosphere. You can also use aerosols to simulate real-world pollution or fog.
2929

30+
**Note**: HDRP only takes into account Lights that have **Affect Physically Based Sky** enabled. After Unity bakes the lighting in your project, Physically Based Sky ignores all Lights that have their **Mode** property set to **Baked**. To fix this, set the **Mode** to **Realtime** or **Mixed**.
31+
3032
**Note:** When Unity initializes a Physically Based Sky, it performs a resource-intensive operation which can cause the frame rate of your project to drop for a few frames. Once Unity has completed this operation, it stores the data in a cache to access the next time Unity initializes this volume. However, you may experience this frame rate drop if you have two Physically Based Sky volumes with different properties and switch between them.
3133

3234
![](Images/Override-PhysicallyBasedSky4.png)

com.unity.render-pipelines.high-definition/Editor/Core/TextureCombiner/TextureCombiner.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public Texture2D Combine(string savePath)
246246
//cleanup "raw" textures
247247
foreach (KeyValuePair<Texture, Texture> prop in m_RawTextures)
248248
{
249-
if (AssetDatabase.Contains(prop.Value))
249+
if (prop.Key != prop.Value && AssetDatabase.Contains(prop.Value))
250250
AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(prop.Value));
251251
}
252252

@@ -262,13 +262,12 @@ private Texture GetRawTexture(Texture original, bool sRGBFallback = false)
262262
if (m_RawTextures == null) m_RawTextures = new Dictionary<Texture, Texture>();
263263
if (!m_RawTextures.ContainsKey(original))
264264
{
265-
if (AssetDatabase.Contains(original))
266-
{
267-
string path = AssetDatabase.GetAssetPath(original);
268-
string rawPath = "Assets/raw_" + Path.GetFileName(path);
269-
270-
AssetDatabase.CopyAsset(path, rawPath);
265+
string path = AssetDatabase.GetAssetPath(original);
266+
string rawPath = "Assets/raw_" + Path.GetFileName(path);
267+
bool isBuiltinResource = path.Contains("unity_builtin");
271268

269+
if (!isBuiltinResource && AssetDatabase.Contains(original) && AssetDatabase.CopyAsset(path, rawPath))
270+
{
272271
AssetDatabase.ImportAsset(rawPath);
273272

274273
TextureImporter rawImporter = (TextureImporter)AssetImporter.GetAtPath(rawPath);

com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/ProbeSettingsUI.Drawers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ ProbeSettingsOverride displayedFields
6464
if ((displayedFields.probe & proxy) != 0)
6565
{
6666
PropertyFieldWithoutToggle(ProbeSettingsFields.proxyUseInfluenceVolumeAsProxyVolume, serialized.proxyUseInfluenceVolumeAsProxyVolume, EditorGUIUtility.TrTextContent("Use Influence Volume As Proxy Volume", "When enabled, this Reflection Probe uses the boundaries of the Influence Volume as its Proxy Volume."), displayedFields.probe);
67-
PropertyFieldWithoutToggle(ProbeSettingsFields.proxyCapturePositionProxySpace, serialized.proxyCapturePositionProxySpace, EditorGUIUtility.TrTextContent("Capture Position", "Sets the position, relative to the Transform Position, from which the Reflection Probe captures its surroundings."), displayedFields.probe,
67+
PropertyFieldWithoutToggle(ProbeSettingsFields.proxyCapturePositionProxySpace, serialized.proxyCapturePositionProxySpace, EditorGUIUtility.TrTextContent("Capture Position", "Sets the position, relative to the Proxy Volume Position, from which the Reflection Probe captures its surroundings."), displayedFields.probe,
6868
(p, l) =>
6969
{
7070
EditorGUILayout.PropertyField(p, l);

com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubTarget.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ public override void Setup(ref TargetSetupContext context)
113113
{
114114
Migrate();
115115

116+
systemData.materialNeedsUpdateHash = ComputeMaterialNeedsUpdateHash();
116117
context.AddAssetDependency(kSourceCodeGuid, AssetCollection.Flags.SourceDependency);
117118
context.AddAssetDependency(subTargetAssetGuid, AssetCollection.Flags.SourceDependency);
118119
var inspector = TargetsVFX() ? VFXHDRPSubTarget.Inspector : customInspector;

com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,10 @@ public class DebugData
264264
/// <summary>Index of the camera to freeze for visibility.</summary>
265265
public int debugCameraToFreeze = 0;
266266

267+
/// <summary>Minimum length a motion vector needs to be to be displayed in the debug display. Unit is pixels.</summary>
268+
public float minMotionVectorLength = 0.0f;
269+
270+
267271
// TODO: The only reason this exist is because of Material/Engine debug enums
268272
// They have repeating values, which caused issues when iterating through the enum, thus the need for explicit indices
269273
// Once we refactor material/engine debug to avoid repeating values, we should be able to remove that.
@@ -1188,9 +1192,9 @@ static class LightingStrings
11881192
public static readonly NameAndTooltip FullscreenDebugMode = new() { name = "Fullscreen Debug Mode", tooltip = "Use the drop-down to select a rendering mode to display as an overlay on the screen." };
11891193
public static readonly NameAndTooltip ScreenSpaceShadowIndex = new() { name = "Screen Space Shadow Index", tooltip = "Select the index of the screen space shadows to view with the slider. There must be a Light in the scene that uses Screen Space Shadows." };
11901194
public static readonly NameAndTooltip DepthPyramidDebugMip = new() { name = "Debug Mip", tooltip = "Enable to view a lower-resolution mipmap." };
1191-
public static readonly NameAndTooltip DepthPyramidEnableRemap = new() { name = "Enable Depth Remap", tooltip = "" };
1192-
public static readonly NameAndTooltip DepthPyramidRangeMin = new() { name = "Depth Range Min Value", tooltip = "" };
1193-
public static readonly NameAndTooltip DepthPyramidRangeMax = new() { name = "Depth Range Max Value", tooltip = "" };
1195+
public static readonly NameAndTooltip DepthPyramidEnableRemap = new() { name = "Enable Depth Remap", tooltip = "Enable remapping of displayed depth values for better vizualization." };
1196+
public static readonly NameAndTooltip DepthPyramidRangeMin = new() { name = "Depth Range Min Value", tooltip = "Distance at which depth values remap starts (0 is near plane, 1 is far plane)" };
1197+
public static readonly NameAndTooltip DepthPyramidRangeMax = new() { name = "Depth Range Max Value", tooltip = "Distance at which depth values remap ends (0 is near plane, 1 is far plane)" };
11941198
public static readonly NameAndTooltip ContactShadowsLightIndex = new() { name = "Light Index", tooltip = "Enable to display Contact shadows for each Light individually." };
11951199

11961200
// Tile/Cluster debug
@@ -1495,16 +1499,16 @@ void RegisterLightingDebug()
14951499
case FullScreenDebugMode.FinalColorPyramid:
14961500
case FullScreenDebugMode.DepthPyramid:
14971501
{
1498-
list.Add(new DebugUI.Container
1502+
var depthPyramidContainer = new DebugUI.Container();
1503+
depthPyramidContainer.children.Add(new DebugUI.FloatField { nameAndTooltip = LightingStrings.DepthPyramidDebugMip, getter = () => data.fullscreenDebugMip, setter = value => data.fullscreenDebugMip = value, min = () => 0f, max = () => 1f, incStep = 0.05f });
1504+
depthPyramidContainer.children.Add(new DebugUI.BoolField { nameAndTooltip = LightingStrings.DepthPyramidEnableRemap, getter = () => data.enableDebugDepthRemap, setter = value => data.enableDebugDepthRemap = value, onValueChanged = RefreshLightingDebug });
1505+
if (data.enableDebugDepthRemap)
14991506
{
1500-
children =
1501-
{
1502-
new DebugUI.FloatField { nameAndTooltip = LightingStrings.DepthPyramidDebugMip, getter = () => data.fullscreenDebugMip, setter = value => data.fullscreenDebugMip = value, min = () => 0f, max = () => 1f, incStep = 0.05f },
1503-
new DebugUI.BoolField { nameAndTooltip = LightingStrings.DepthPyramidEnableRemap, getter = () => data.enableDebugDepthRemap, setter = value => data.enableDebugDepthRemap = value },
1504-
new DebugUI.FloatField { nameAndTooltip = LightingStrings.DepthPyramidRangeMin, getter = () => data.fullScreenDebugDepthRemap.x, setter = value => data.fullScreenDebugDepthRemap.x = value, min = () => 0f, max = () => 1f, incStep = 0.05f },
1505-
new DebugUI.FloatField { nameAndTooltip = LightingStrings.DepthPyramidRangeMax, getter = () => data.fullScreenDebugDepthRemap.y, setter = value => data.fullScreenDebugDepthRemap.y = value, min = () => 0f, max = () => 1f, incStep = 0.05f }
1506-
}
1507-
});
1507+
depthPyramidContainer.children.Add(new DebugUI.FloatField { nameAndTooltip = LightingStrings.DepthPyramidRangeMin, getter = () => data.fullScreenDebugDepthRemap.x, setter = value => data.fullScreenDebugDepthRemap.x = Mathf.Min(value, data.fullScreenDebugDepthRemap.y), min = () => 0f, max = () => 1f, incStep = 0.01f });
1508+
depthPyramidContainer.children.Add(new DebugUI.FloatField { nameAndTooltip = LightingStrings.DepthPyramidRangeMax, getter = () => data.fullScreenDebugDepthRemap.y, setter = value => data.fullScreenDebugDepthRemap.y = Mathf.Max(value, data.fullScreenDebugDepthRemap.x), min = () => 0.01f, max = () => 1f, incStep = 0.01f });
1509+
}
1510+
1511+
list.Add(depthPyramidContainer);
15081512
break;
15091513
}
15101514
case FullScreenDebugMode.ContactShadows:
@@ -1955,6 +1959,16 @@ void RegisterRenderingDebug()
19551959
}
19561960
});
19571961
}
1962+
else if (data.fullScreenDebugMode == FullScreenDebugMode.MotionVectors)
1963+
{
1964+
widgetList.Add(new DebugUI.Container
1965+
{
1966+
children =
1967+
{
1968+
new DebugUI.FloatField {displayName = "Min Motion Vector Length (in pixels)", getter = () => data.minMotionVectorLength, setter = value => data.minMotionVectorLength = value, min = () => 0}
1969+
}
1970+
});
1971+
}
19581972

19591973
widgetList.AddRange(new DebugUI.Widget[]
19601974
{

com.unity.render-pipelines.high-definition/Runtime/Debug/DebugFullScreen.shader

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Shader "Hidden/HDRP/DebugFullScreen"
3535
float _VertexDensityMaxPixelCost;
3636
uint _DebugContactShadowLightIndex;
3737
int _DebugDepthPyramidMip;
38+
float _MinMotionVector;
3839
CBUFFER_END
3940

4041
TEXTURE2D_X(_DebugFullScreenTexture);
@@ -219,7 +220,10 @@ Shader "Hidden/HDRP/DebugFullScreen"
219220
if (_FullScreenDebugMode == FULLSCREENDEBUGMODE_MOTION_VECTORS)
220221
{
221222
float2 mv = SampleMotionVectors(input.texcoord);
222-
223+
if (length(mv * _ScreenSize.xy) < _MinMotionVector)
224+
{
225+
return float4(0, 0, 0, 1);
226+
}
223227
// Background color intensity - keep this low unless you want to make your eyes bleed
224228
const float kMinIntensity = 0.03f;
225229
const float kMaxIntensity = 0.50f;
@@ -338,7 +342,10 @@ Shader "Hidden/HDRP/DebugFullScreen"
338342
float depth = LOAD_TEXTURE2D_X(_CameraDepthTexture, pixCoord + mipOffset).r;
339343
PositionInputs posInput = GetPositionInput(input.positionCS.xy, _ScreenSize.zw, depth, UNITY_MATRIX_I_VP, UNITY_MATRIX_V);
340344

341-
float linearDepth = lerp(_FullScreenDebugDepthRemap.x, _FullScreenDebugDepthRemap.y, (posInput.linearDepth - _FullScreenDebugDepthRemap.z) / (_FullScreenDebugDepthRemap.w - _FullScreenDebugDepthRemap.z));
345+
// We square the factors to have more precision near zero which is where people usually want to visualize depth.
346+
float remappedFar = min(_FullScreenDebugDepthRemap.w, _FullScreenDebugDepthRemap.y * _FullScreenDebugDepthRemap.y * _FullScreenDebugDepthRemap.w);
347+
float remappedNear = max(_FullScreenDebugDepthRemap.z, _FullScreenDebugDepthRemap.x * _FullScreenDebugDepthRemap.x * _FullScreenDebugDepthRemap.w);
348+
float linearDepth = lerp(0.0, 1.0, (posInput.linearDepth - remappedNear) / (remappedFar - remappedNear));
342349
return float4(linearDepth.xxx, 1.0);
343350
}
344351

com.unity.render-pipelines.high-definition/Runtime/Material/Builtin/BuiltinData.hlsl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@
1111
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Debug.hlsl" // Require for GetIndexColor auto generated
1212
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Builtin/BuiltinData.cs.hlsl"
1313

14+
//-----------------------------------------------------------------------------
15+
// Modification Options
16+
//-----------------------------------------------------------------------------
17+
// Due to various transform and conversions that happen, some precision is lost along the way.
18+
// as a result, motion vectors that are close to 0 due to cancellation of components (camera and object) end up not doing so.
19+
// To workaround the issue, if the computed motion vector is less than MICRO_MOVEMENT_THRESHOLD (now 1% of a pixel)
20+
// if KILL_MICRO_MOVEMENT is == 1, we set the motion vector to 0 instead.
21+
// An alternative could be rounding the motion vectors (e.g. round(motionVec.xy * 1eX) / 1eX) with X varying on how many digits)
22+
// but that might lead to artifacts with mismatch between actual motion and written motion vectors on non trivial motion vector lengths.
23+
#define KILL_MICRO_MOVEMENT
24+
#define MICRO_MOVEMENT_THRESHOLD (0.01f * _ScreenSize.zw)
25+
1426
//-----------------------------------------------------------------------------
1527
// helper macro
1628
//-----------------------------------------------------------------------------

com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ float2 CalculateMotionVector(float4 positionCS, float4 previousPositionCS)
1414
previousPositionCS.xy = previousPositionCS.xy / previousPositionCS.w;
1515

1616
float2 motionVec = (positionCS.xy - previousPositionCS.xy);
17+
18+
#ifdef KILL_MICRO_MOVEMENT
19+
motionVec.x = abs(motionVec.x) < MICRO_MOVEMENT_THRESHOLD.x ? 0 : motionVec.x;
20+
motionVec.y = abs(motionVec.y) < MICRO_MOVEMENT_THRESHOLD.y ? 0 : motionVec.y;
21+
#endif
22+
23+
motionVec = clamp(motionVec, -1.0f + MICRO_MOVEMENT_THRESHOLD, 1.0f - MICRO_MOVEMENT_THRESHOLD);
24+
1725
#if UNITY_UV_STARTS_AT_TOP
1826
motionVec.y = -motionVec.y;
1927
#endif

com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,14 +1755,24 @@ Matrix4x4 GetJitteredProjectionMatrix(Matrix4x4 origProj)
17551755
Matrix4x4 ComputePixelCoordToWorldSpaceViewDirectionMatrix(ViewConstants viewConstants, Vector4 resolution, float aspect = -1)
17561756
{
17571757
// In XR mode, use a more generic matrix to account for asymmetry in the projection
1758-
if (xr.enabled)
1758+
var useGenericMatrix = xr.enabled;
1759+
1760+
// Asymmetry is also possible from a user-provided projection, so we must check for it too.
1761+
// Note however, that in case of physical camera, the lens shift term is the only source of
1762+
// asymmetry, and this is accounted for in the optimized path below. Additionally, Unity C++ will
1763+
// automatically disable physical camera when the projection is overridden by user.
1764+
useGenericMatrix |= HDUtils.IsProjectionMatrixAsymmetric(viewConstants.projMatrix) && !camera.usePhysicalProperties;
1765+
1766+
if (useGenericMatrix)
17591767
{
1760-
var transform = Matrix4x4.Scale(new Vector3(-1.0f, -1.0f, -1.0f)) * viewConstants.invViewProjMatrix;
1761-
transform = transform * Matrix4x4.Scale(new Vector3(1.0f, -1.0f, 1.0f));
1762-
transform = transform * Matrix4x4.Translate(new Vector3(-1.0f, -1.0f, 0.0f));
1763-
transform = transform * Matrix4x4.Scale(new Vector3(2.0f * resolution.z, 2.0f * resolution.w, 1.0f));
1768+
var viewSpaceRasterTransform = new Matrix4x4(
1769+
new Vector4(2.0f * resolution.z, 0.0f, 0.0f, -1.0f),
1770+
new Vector4(0.0f, -2.0f * resolution.w, 0.0f, 1.0f),
1771+
new Vector4(0.0f, 0.0f, 1.0f, 0.0f),
1772+
new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
17641773

1765-
return transform.transpose;
1774+
var transformT = viewConstants.invViewProjMatrix.transpose * Matrix4x4.Scale(new Vector3(-1.0f, -1.0f, -1.0f));
1775+
return viewSpaceRasterTransform * transformT;
17661776
}
17671777

17681778
float verticalFoV = camera.GetGateFittedFieldOfView() * Mathf.Deg2Rad;

0 commit comments

Comments
 (0)