Skip to content

Commit 3b63ca5

Browse files
sebastienlagardepmavridisFrancescoC-unityjohnparsanisunity
authored
Merge Hd/bugfix (#5222)
* [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 <[email protected]> * 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 <[email protected]> * Fix distortion when resizing the window in player builds with the Graphics Compositor enabled (#4593) Co-authored-by: sebastienlagarde <[email protected]> * 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 <[email protected]> * Fixed a memory leak related to not disposing of the RTAS at the end HDRP's lifecycle. (#4688) Co-authored-by: sebastienlagarde <[email protected]> * Fix custom pass utils Blur + Copy overdraw. (#4623) * Fix overdraw in custom pass utils blur function * Updated changelog Co-authored-by: sebastienlagarde <[email protected]> * Fix draw procedural invalid pass idx 1 on first template load (#4632) * Fix * changelog * Force sync compilation for TAA Co-authored-by: CifaCia <[email protected]> Co-authored-by: sebastienlagarde <[email protected]> * Changed light reset to preserve type (#4624) Co-authored-by: sebastienlagarde <[email protected]> * 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 <[email protected]> * 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 <[email protected]> Co-authored-by: Sebastien Lagarde <[email protected]> * 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 <[email protected]> * 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 <[email protected]> * [HDRP] Fix VfX lit particle AOV output color space (#4646) * Fix VfX lit particle aov output color space * Update comment Co-authored-by: sebastienlagarde <[email protected]> * [HDRP][Path Tracing] Fixed transparent unlit (#4605) * Fixed issue with transparent unlit. * Updated changelog. * Reverted accidental change to default mtl. Co-authored-by: sebastienlagarde <[email protected]> * Fix distortion with MSAA (#4711) * Fix contact shadow debug views (#4720) * Fix * changelog Co-authored-by: sebastienlagarde <[email protected]> * 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 <[email protected]> * 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 <[email protected]> * 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 <[email protected]> * 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 <[email protected]> * Fix formatting * Fix volumetric fog in planar reflections (#4736) * Fix planar reflection * changelog Co-authored-by: sebastienlagarde <[email protected]> * Fix motion blur compute dispatch size (#4737) Co-authored-by: sebastienlagarde <[email protected]> * - Updated the recursive rendering documentation (case 1338639). (#4759) * - Updated the recursive rendering documentation (case 1338639). * review fixes Co-authored-by: sebastienlagarde <[email protected]> * 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 <[email protected]> * Fix cropping issue with the compositor camera bridge (#4802) Co-authored-by: sebastienlagarde <[email protected]> * 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 <[email protected]> * 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 <[email protected]> Co-authored-by: sebastienlagarde <[email protected]> * Use non jittered projection in outline pass (#4836) Co-authored-by: sebastienlagarde <[email protected]> * [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 <[email protected]> * 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 <[email protected]> * 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 <[email protected]> * [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 <[email protected]> * [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 <[email protected]> * Fix reflection probe tootltip (#4890) Co-authored-by: sebastienlagarde <[email protected]> * Updated the Physically Based Sky documentation for baked lights (#4891) * Updated the Physically Based Sky documentation for baked lights * Rewrite Co-authored-by: sebastienlagarde <[email protected]> * 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 <[email protected]> * 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 <[email protected]> * Revert: Fix wobble-like (or tearing-like) SSAO issues when temporal reprojection… * Fix GBuffer depth debug mode (#5054) * Fixed Volume Gizmo size when rescaling parent GameObject (#4915) * Fix Vertex Color Mode documentation (#4976) * Fix wobble-like (or tearing-like) SSAO issues when temporal reprojection is enabled. (#4986) * Fix AO perceived wobble * changelog * Update screenshots Co-authored-by: sebastienlagarde <[email protected]> * Fix formatting in NestedOverrideCameraRendering * [HDRP] Fix white flash with SSR when resetting camera history (#5089) * Fix white flash with SSR when resetting camera history * Move branch login inside GetPreviousExposureTexture * Fix for fixed exposure * [Fobguz # 1348357] VFX Particle templates missing stencil flags (#5080) * Adding missing macro for stencil flags in particle forward shaders. This will let flags like TAA Reject be useful * Changelog * Fix object disappearing from lookdev (#5063) * Fixed objects disappearing from Lookdev window when entering playmode (case 1309368). * Updated changelog * Added hideflags in Lookdev context * [HDRP] Fix render object after taa jittering (#5088) * Add a pass after TAA to restore non jittered matrices * updated changelog Co-authored-by: sebastienlagarde <[email protected]> * Fix GC alloc in hd/bugfix branch (#5134) * Fixed GC alloc on hd/bugfix branch * Fix GC alloc again * Fix refraction tile artifacts near reflection probe edges (#4727) * Pick the right probe at object center instead of tile granularity. * changelog * Missing commit * Move stuff in lightloop and out of prelightData * Update LightLoop.hlsl * Formatting Co-authored-by: sebastienlagarde <[email protected]> * Fix camera rotation uncontrollable with low framerate (#5076) * Fix camera rotation uncontrollable with low framerate. * updated changelog * Clearing out render targets and randmo write targets on pipeline destruction (#5176) Changelog Co-authored-by: sebastienlagarde <[email protected]> * Fixed a null ref exception when adding a new environment to the library. (#5131) * Fixed a null ref exception when adding a new environment to the library. * Update changelog Co-authored-by: sebastienlagarde <[email protected]> * FogBugz#1348462 - Wait for accessing the HDProjectSettings instance as it was before. (#5141) * Fix nullref in volume system after deleting a volume object (#5161) * Fix nullref in volume system after deleting a volume object (case 1348374) * Updated changelog Co-authored-by: sebastienlagarde <[email protected]> * [HDRP] Fix APV UI loosing focus when changing a param (#5219) * Fixed the APV UI losing focus when the helpbox about baking appears in the probe volume. Co-authored-by: Pavlos Mavridis <[email protected]> Co-authored-by: FrancescoC-unity <[email protected]> Co-authored-by: John Parsaie <[email protected]> Co-authored-by: anisunity <[email protected]> Co-authored-by: Antoine Lelievre <[email protected]> Co-authored-by: CifaCia <[email protected]> Co-authored-by: Adrien de Tocqueville <[email protected]> Co-authored-by: slunity <[email protected]> Co-authored-by: Remi Chapelain <[email protected]> Co-authored-by: Emmanuel Turquin <[email protected]> Co-authored-by: Adrian1066 <[email protected]> Co-authored-by: Kleber Garcia <[email protected]> Co-authored-by: Julien Ignace <[email protected]> Co-authored-by: alex-vazquez <[email protected]>
1 parent 48cb95b commit 3b63ca5

File tree

14 files changed

+133
-46
lines changed

14 files changed

+133
-46
lines changed

com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeUI.Drawer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ static void Drawer_VolumeContent(SerializedProbeVolume serialized, Editor owner)
139139
EditorGUI.BeginChangeCheck();
140140
if ((serialized.serializedObject.targetObject as ProbeVolume).mightNeedRebaking)
141141
{
142-
EditorGUILayout.HelpBox("The probe volume has changed since last baking or the data was never baked.\nPlease bake lighting in the lighting panel to update the lighting data.", MessageType.Warning, wide: true);
142+
var helpBoxRect = GUILayoutUtility.GetRect(new GUIContent(Styles.s_ProbeVolumeChangedMessage, EditorGUIUtility.IconContent("Warning@2x").image), EditorStyles.helpBox);
143+
EditorGUI.HelpBox(helpBoxRect, Styles.s_ProbeVolumeChangedMessage, MessageType.Warning);
143144
}
144145

145146
EditorGUILayout.PropertyField(serialized.globalVolume, Styles.s_GlobalVolume);

com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeUI.Skin.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ internal static class Styles
1111
internal static readonly GUIContent s_MinMaxSubdivSlider = new GUIContent("Subdivision Controller", "Control how much the probe baking system will subdivide in this volume.\nBoth min and max values are used to compute the allowed subdivision levels inside this volume. e.g. a Min subdivision of 2 will ensure that there is at least 2 levels of subdivision everywhere in the volume.");
1212
internal static readonly GUIContent s_ObjectLayerMask = new GUIContent("Object Layer Mask", "Control which layers will be used to select the meshes for the probe placement algorithm.");
1313
internal static readonly GUIContent s_GeometryDistanceOffset = new GUIContent("Geometry Distance Offset", "Affects the minimum distance at which the subdivision system will place probes near the geometry.");
14+
internal static readonly string s_ProbeVolumeChangedMessage = "The probe volume has changed since last baking or the data was never baked.\nPlease bake lighting in the lighting panel to update the lighting data.";
1415

1516
internal static readonly Color k_GizmoColorBase = new Color32(137, 222, 144, 255);
1617

com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.EnvironmentLibrarySidePanel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ void RefreshLibraryDisplay()
291291
m_EnvironmentListToolbar.style.visibility = Visibility.Visible;
292292
m_NoEnvironmentList.style.display = DisplayStyle.None;
293293
}
294+
m_EnvironmentList.RefreshItems();
294295
}
295296
}
296297

com.unity.render-pipelines.core/Editor/LookDev/LookDev.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using UnityEngine.Rendering.LookDev;
33
using UnityEditorInternal;
44
using UnityEngine;
5+
using System.Linq;
56

67
namespace UnityEditor.Rendering.LookDev
78
{
@@ -32,6 +33,11 @@ internal static Context currentContext
3233
{
3334
if (s_CurrentContext == null || s_CurrentContext.Equals(null))
3435
{
36+
// In case the context is still alive somewhere but the static reference has been lost, we can find the object back with this
37+
s_CurrentContext = TryFindCurrentContext();
38+
if (s_CurrentContext != null)
39+
return s_CurrentContext;
40+
3541
s_CurrentContext = LoadConfigInternal();
3642
if (s_CurrentContext == null)
3743
s_CurrentContext = defaultContext;
@@ -43,11 +49,22 @@ internal static Context currentContext
4349
private set => s_CurrentContext = value;
4450
}
4551

52+
static Context TryFindCurrentContext()
53+
{
54+
Context context = s_CurrentContext;
55+
56+
if (context != null)
57+
return context;
58+
59+
return Resources.FindObjectsOfTypeAll<Context>().FirstOrDefault();
60+
}
61+
4662
static Context defaultContext
4763
{
4864
get
4965
{
5066
var context = UnityEngine.ScriptableObject.CreateInstance<Context>();
67+
context.hideFlags = HideFlags.HideAndDontSave;
5168
context.Init();
5269
return context;
5370
}
@@ -132,7 +149,7 @@ internal static void Initialize(DisplayWindow window)
132149

133150
// Lookdev Initialize can be called when the window is re-created by the editor layout system.
134151
// In that case, the current context won't be null and there might be objects to reload from the temp ID
135-
ConfigureLookDev(reloadWithTemporaryID: s_CurrentContext != null);
152+
ConfigureLookDev(reloadWithTemporaryID: TryFindCurrentContext() != null);
136153
}
137154

138155
[Callbacks.DidReloadScripts]

com.unity.render-pipelines.core/Runtime/Camera/FreeCamera.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ namespace UnityEngine.Rendering
1414
[CoreRPHelpURLAttribute("Free-Camera")]
1515
public class FreeCamera : MonoBehaviour
1616
{
17+
const float k_MouseSensitivityMultiplier = 0.01f;
18+
1719
/// <summary>
1820
/// Rotation speed when using a controller.
1921
/// </summary>
2022
public float m_LookSpeedController = 120f;
2123
/// <summary>
2224
/// Rotation speed when using the mouse.
2325
/// </summary>
24-
public float m_LookSpeedMouse = 10.0f;
26+
public float m_LookSpeedMouse = 4.0f;
2527
/// <summary>
2628
/// Movement speed.
2729
/// </summary>
@@ -51,7 +53,6 @@ public class FreeCamera : MonoBehaviour
5153
InputAction lookAction;
5254
InputAction moveAction;
5355
InputAction speedAction;
54-
InputAction fireAction;
5556
InputAction yMoveAction;
5657
#endif
5758

@@ -94,7 +95,6 @@ void RegisterInputs()
9495
moveAction.Enable();
9596
lookAction.Enable();
9697
speedAction.Enable();
97-
fireAction.Enable();
9898
yMoveAction.Enable();
9999
#endif
100100

@@ -129,8 +129,8 @@ void UpdateInputs()
129129

130130
#if USE_INPUT_SYSTEM
131131
var lookDelta = lookAction.ReadValue<Vector2>();
132-
inputRotateAxisX = lookDelta.x * m_LookSpeedMouse * Time.deltaTime;
133-
inputRotateAxisY = lookDelta.y * m_LookSpeedMouse * Time.deltaTime;
132+
inputRotateAxisX = lookDelta.x * m_LookSpeedMouse * k_MouseSensitivityMultiplier;
133+
inputRotateAxisY = lookDelta.y * m_LookSpeedMouse * k_MouseSensitivityMultiplier;
134134

135135
leftShift = Keyboard.current.leftShiftKey.isPressed;
136136
fire1 = Mouse.current?.leftButton?.isPressed == true || Gamepad.current?.xButton?.isPressed == true;
@@ -148,8 +148,8 @@ void UpdateInputs()
148148
inputRotateAxisX = Input.GetAxis(kMouseX) * m_LookSpeedMouse;
149149
inputRotateAxisY = Input.GetAxis(kMouseY) * m_LookSpeedMouse;
150150
}
151-
inputRotateAxisX += (Input.GetAxis(kRightStickX) * m_LookSpeedController * Time.deltaTime);
152-
inputRotateAxisY += (Input.GetAxis(kRightStickY) * m_LookSpeedController * Time.deltaTime);
151+
inputRotateAxisX += (Input.GetAxis(kRightStickX) * m_LookSpeedController * k_MouseSensitivityMultiplier);
152+
inputRotateAxisY += (Input.GetAxis(kRightStickY) * m_LookSpeedController * k_MouseSensitivityMultiplier);
153153

154154
leftShift = Input.GetKey(KeyCode.LeftShift);
155155
fire1 = Input.GetAxis("Fire1") > 0.0f;

com.unity.render-pipelines.core/Runtime/Volume/VolumeManager.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ public void Update(VolumeStack stack, Transform trigger, LayerMask layerMask)
347347
// Traverse all volumes
348348
foreach (var volume in volumes)
349349
{
350+
if (volume == null)
351+
continue;
352+
350353
#if UNITY_EDITOR
351354
// Skip volumes that aren't in the scene currently displayed in the scene view
352355
if (!IsVolumeRenderedByCamera(volume, camera))
@@ -417,6 +420,7 @@ public void Update(VolumeStack stack, Transform trigger, LayerMask layerMask)
417420
public Volume[] GetVolumes(LayerMask layerMask)
418421
{
419422
var volumes = GrabVolumes(layerMask);
423+
volumes.RemoveAll(v => v == null);
420424
return volumes.ToArray();
421425
}
422426

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
315315
- Fixed an issue with reflection probe normalization via APV when no probes are in scene.
316316
- Fixed Volumetric Clouds not updated when using RenderTexture as input for cloud maps.
317317
- Fixed custom post process name not displayed correctly in GPU markers.
318+
- Fixed objects disappearing from Lookdev window when entering playmode (case 1309368).
319+
- Fixed rendering of objects just after the TAA pass (before post process injection point).
320+
- Fixed tiled artifacts in refraction at borders between two reflection probes.
321+
- Fixed the FreeCamera and SimpleCameraController mouse rotation unusable at low framerate (case 1340344).
322+
- Fixed warning "Releasing render texture that is set to be RenderTexture.active!" on pipeline disposal / hdrp live editing.
323+
- Fixed a null ref exception when adding a new environment to the Look Dev library.
324+
- Fixed a nullref in volume system after deleting a volume object (case 1348374).
325+
- Fixed the APV UI loosing focus when the helpbox about baking appears in the probe volume.
318326

319327
### Changed
320328
- Changed Window/Render Pipeline/HD Render Pipeline Wizard to Window/Rendering/HDRP Wizard

com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.Window.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,6 @@ static HDWizard()
252252

253253
static void WizardBehaviourDelayed()
254254
{
255-
if (!HDProjectSettings.wizardIsStartPopup)
256-
throw new Exception(
257-
$"HDProjectSettings.wizardIsStartPopup must be true");
258-
259255
if (frameToWait > 0)
260256
{
261257
--frameToWait;
@@ -265,6 +261,10 @@ static void WizardBehaviourDelayed()
265261
// No need to update this method, unsubscribe from the application update
266262
EditorApplication.update -= WizardBehaviourDelayed;
267263

264+
// If the wizard does not need to be shown at start up, do nothing.
265+
if (!HDProjectSettings.wizardIsStartPopup)
266+
return;
267+
268268
//Application.isPlaying cannot be called in constructor. Do it here
269269
if (Application.isPlaying)
270270
return;
@@ -307,10 +307,6 @@ static void CheckPersistencyPopupAlreadyOpened()
307307
[Callbacks.DidReloadScripts]
308308
static void WizardBehaviour()
309309
{
310-
// If the wizard does not need to be shown at start up, do nothing.
311-
if (!HDProjectSettings.wizardIsStartPopup)
312-
return;
313-
314310
//We need to wait at least one frame or the popup will not show up
315311
frameToWait = 10;
316312
EditorApplication.update += WizardBehaviourDelayed;

com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -349,21 +349,46 @@ void LightLoop( float3 V, PositionInputs posInput, PreLightData preLightData, BS
349349
}
350350
#endif
351351

352-
EnvLightData envLightData;
353-
if (envLightCount > 0)
354-
{
355-
envLightData = FetchEnvLight(envLightStart, 0);
356-
}
357-
else
358-
{
359-
envLightData = InitSkyEnvLightData(0);
360-
}
352+
#if HAS_REFRACTION
361353

354+
// For refraction to be stable, we should reuse the same refraction probe for the whole object.
355+
// Otherwise as if the object span different tiles it could produce a different refraction probe picking and thus have visual artifacts.
356+
// For this we need to find the tile that is at the center of the object that is being rendered.
357+
// And then select the first refraction probe of this list.
362358
if ((featureFlags & LIGHTFEATUREFLAGS_SSREFRACTION) && (_EnableSSRefraction > 0))
363359
{
360+
// grab current object position and retrieve in which tile it belongs too
361+
float4x4 modelMat = GetObjectToWorldMatrix();
362+
float3 objPos = modelMat._m03_m13_m23;
363+
float4 posClip = TransformWorldToHClip(objPos);
364+
posClip.xyz = posClip.xyz / posClip.w;
365+
366+
uint2 tileObj = (saturate(posClip.xy * 0.5f + 0.5f) * _ScreenSize.xy) / GetTileSize();
367+
368+
uint envLightStart, envLightCount;
369+
370+
// Fetch first env light to provide the scene proxy for screen space refraction computation
371+
PositionInputs localInput;
372+
ZERO_INITIALIZE(PositionInputs, localInput);
373+
localInput.tileCoord = tileObj.xy;
374+
localInput.linearDepth = posClip.w;
375+
376+
GetCountAndStart(localInput, LIGHTCATEGORY_ENV, envLightStart, envLightCount);
377+
378+
EnvLightData envLightData;
379+
if (envLightCount > 0)
380+
{
381+
envLightData = FetchEnvLight(FetchIndex(envLightStart, 0));
382+
}
383+
else // If no refraction probe, use sky
384+
{
385+
envLightData = InitSkyEnvLightData(0);
386+
}
387+
364388
IndirectLighting lighting = EvaluateBSDF_ScreenspaceRefraction(context, V, posInput, preLightData, bsdfData, envLightData, refractionHierarchyWeight);
365389
AccumulateIndirectLighting(lighting, aggregateLighting);
366390
}
391+
#endif
367392

368393

369394
#if defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2)

com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.PostProcess.cs

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ TextureHandle RenderPostProcess(RenderGraph renderGraph,
483483
if (hdCamera.antialiasing == HDAdditionalCameraData.AntialiasingMode.TemporalAntialiasing)
484484
{
485485
source = DoTemporalAntialiasing(renderGraph, hdCamera, depthBuffer, motionVectors, depthBufferMipChain, source, postDoF: false, "TAA Destination");
486+
RestoreNonjitteredMatrices(renderGraph, hdCamera);
486487
}
487488
else if (hdCamera.antialiasing == HDAdditionalCameraData.AntialiasingMode.SubpixelMorphologicalAntiAliasing)
488489
{
@@ -539,6 +540,34 @@ TextureHandle RenderPostProcess(RenderGraph renderGraph,
539540
return dest;
540541
}
541542

543+
class RestoreNonJitteredPassData
544+
{
545+
public ShaderVariablesGlobal globalCB;
546+
public HDCamera hdCamera;
547+
}
548+
549+
void RestoreNonjitteredMatrices(RenderGraph renderGraph, HDCamera hdCamera)
550+
{
551+
using (var builder = renderGraph.AddRenderPass<RestoreNonJitteredPassData>("Restore Non-Jittered Camera Matrices", out var passData))
552+
{
553+
passData.hdCamera = hdCamera;
554+
passData.globalCB = m_ShaderVariablesGlobalCB;
555+
556+
builder.SetRenderFunc((RestoreNonJitteredPassData data, RenderGraphContext ctx) =>
557+
{
558+
// Note about AfterPostProcess and TAA:
559+
// When TAA is enabled rendering is jittered and then resolved during the post processing pass.
560+
// It means that any rendering done after post processing need to disable jittering. This is what we do with hdCamera.UpdateViewConstants(false);
561+
// The issue is that the only available depth buffer is jittered so pixels would wobble around depth tested edges.
562+
// In order to avoid that we decide that objects rendered after Post processes while TAA is active will not benefit from the depth buffer so we disable it.
563+
data.hdCamera.UpdateAllViewConstants(false);
564+
data.hdCamera.UpdateShaderVariablesGlobalCB(ref data.globalCB);
565+
566+
ConstantBuffer.PushGlobal(ctx.cmd, data.globalCB, HDShaderIDs._ShaderVariablesGlobal);
567+
});
568+
}
569+
}
570+
542571
#region AfterPostProcess
543572
class AfterPostProcessPassData
544573
{
@@ -577,14 +606,6 @@ TextureHandle RenderAfterPostProcessObjects(RenderGraph renderGraph, HDCamera hd
577606
builder.SetRenderFunc(
578607
(AfterPostProcessPassData data, RenderGraphContext ctx) =>
579608
{
580-
// Note about AfterPostProcess and TAA:
581-
// When TAA is enabled rendering is jittered and then resolved during the post processing pass.
582-
// It means that any rendering done after post processing need to disable jittering. This is what we do with hdCamera.UpdateViewConstants(false);
583-
// The issue is that the only available depth buffer is jittered so pixels would wobble around depth tested edges.
584-
// In order to avoid that we decide that objects rendered after Post processes while TAA is active will not benefit from the depth buffer so we disable it.
585-
data.hdCamera.UpdateAllViewConstants(false);
586-
data.hdCamera.UpdateShaderVariablesGlobalCB(ref data.globalCB);
587-
588609
UpdateOffscreenRenderingConstants(ref data.globalCB, true, 1.0f);
589610
ConstantBuffer.PushGlobal(ctx.cmd, data.globalCB, HDShaderIDs._ShaderVariablesGlobal);
590611

0 commit comments

Comments
 (0)