Skip to content

Commit 1a77f8c

Browse files
sebastienlagardeadrien-de-tocquevilleFrancescoC-unitypmavridisalelievr
authored
[HDRP] Merge hd/bugfix (#2787)
* Fixed volume component tooltips using the same parameter name (#2754) * Use the proper history info for Bicubic resampling in TAA (#2759) * Use proper info for previous buffer info * changelog * Fixed lookdev movement (#2757) Co-authored-by: sebastienlagarde <[email protected]> * [HDRP] Fix issue with saving some quality settings in volume overrides (#2758) * Fix issue with saving some quality settings volume overrides * Fix typo in changelog Co-authored-by: sebastienlagarde <[email protected]> * [HDRP] Fixed NullReferenceException in HDRenderPipeline.UpgradeResourcesIfNeeded (case 1292524) (#2765) * fix issue with confusing text (#2766) * Fixed SSGI texture allocation with RG disabled (#2768) * [HDRP] Fixed max shadow crash (#2760) * Fixed NullReference Exception when setting Max Shadows On Screen to 0 in the HDRP asset * Updated changelog * Fixed nullref again + debug * Initialize shadow request count Co-authored-by: sebastienlagarde <[email protected]> * Formatting * Update CHANGELOG.md Co-authored-by: Adrien de Tocqueville <[email protected]> Co-authored-by: FrancescoC-unity <[email protected]> Co-authored-by: Pavlos Mavridis <[email protected]> Co-authored-by: Antoine Lelievre <[email protected]>
1 parent 3a976b6 commit 1a77f8c

File tree

12 files changed

+149
-76
lines changed

12 files changed

+149
-76
lines changed

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

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,24 @@ enum Direction
3838
bool m_InFlyMotion;
3939

4040
bool m_IsDragging;
41-
ViewTool m_BehaviorState;
4241
static TimeHelper s_Timer = new TimeHelper();
4342

43+
ViewTool m_BehaviorState;
44+
ViewTool behaviorState
45+
{
46+
get { return m_BehaviorState; }
47+
set
48+
{
49+
if (value != m_BehaviorState && m_BehaviorState == ViewTool.FPS)
50+
{
51+
isDragging = false;
52+
inFlyMotion = false;
53+
m_DirectionKeyPressed = Direction.None;
54+
}
55+
m_BehaviorState = value;
56+
}
57+
}
58+
4459
protected CameraState m_CameraState;
4560
DisplayWindow m_Window;
4661
protected Action m_Focused;
@@ -125,13 +140,13 @@ private void ResetCameraControl()
125140
{
126141
isDragging = false;
127142
inFlyMotion = false;
128-
m_BehaviorState = ViewTool.None;
143+
behaviorState = ViewTool.None;
129144
}
130145

131146
protected virtual void OnScrollWheel(WheelEvent evt)
132147
{
133148
// See UnityEditor.SceneViewMotion.HandleScrollWheel
134-
switch (m_BehaviorState)
149+
switch (behaviorState)
135150
{
136151
case ViewTool.FPS: OnChangeFPSCameraSpeed(evt); break;
137152
default: OnZoom(evt); break;
@@ -140,7 +155,7 @@ protected virtual void OnScrollWheel(WheelEvent evt)
140155

141156
void OnMouseDrag(MouseMoveEvent evt)
142157
{
143-
switch (m_BehaviorState)
158+
switch (behaviorState)
144159
{
145160
case ViewTool.Orbit: OnMouseDragOrbit(evt); break;
146161
case ViewTool.FPS: OnMouseDragFPS(evt); break;
@@ -241,7 +256,7 @@ void OnKeyDownReset(KeyDownEvent evt)
241256
void OnKeyUpOrDownFPS<T>(KeyboardEventBase<T> evt)
242257
where T : KeyboardEventBase<T>, new()
243258
{
244-
if (m_BehaviorState != ViewTool.FPS)
259+
if (behaviorState != ViewTool.FPS)
245260
return;
246261

247262
//Note: Keydown is called in loop but between first occurence of the
@@ -319,29 +334,40 @@ bool GetKeyCombinationByID(string ID, out KeyCombination combination)
319334
}
320335
}
321336

337+
ViewTool GetBehaviorTool<T>(MouseEventBase<T> evt, bool onMac) where T : MouseEventBase<T>, new()
338+
{
339+
if (evt.button == 2)
340+
return ViewTool.Pan;
341+
else if (evt.button == 0 && evt.ctrlKey && onMac || evt.button == 1 && evt.altKey)
342+
return ViewTool.Zoom;
343+
else if (evt.button == 0)
344+
return ViewTool.Orbit;
345+
else if (evt.button == 1 && !evt.altKey)
346+
return ViewTool.FPS;
347+
return ViewTool.None;
348+
}
349+
322350
void OnMouseUp(MouseUpEvent evt)
323351
{
324-
ResetCameraControl();
352+
bool onMac = Application.platform == RuntimePlatform.OSXEditor;
353+
var state = GetBehaviorTool(evt, onMac);
354+
355+
if (state == behaviorState)
356+
ResetCameraControl();
325357
evt.StopPropagation();
326358
}
327359

328360
void OnMouseDown(MouseDownEvent evt)
329361
{
330362
bool onMac = Application.platform == RuntimePlatform.OSXEditor;
363+
behaviorState = GetBehaviorTool(evt, onMac);
331364

332-
if (evt.button == 2)
333-
m_BehaviorState = ViewTool.Pan;
334-
else if (evt.button == 0 && evt.ctrlKey && onMac || evt.button == 1 && evt.altKey)
365+
if (behaviorState == ViewTool.Zoom)
335366
{
336-
m_BehaviorState = ViewTool.Zoom;
337367
m_StartZoom = m_CameraState.viewSize;
338368
m_ZoomSpeed = Mathf.Max(Mathf.Abs(m_StartZoom), .3f);
339369
m_TotalMotion = 0;
340370
}
341-
else if (evt.button == 0)
342-
m_BehaviorState = ViewTool.Orbit;
343-
else if (evt.button == 1 && !evt.altKey)
344-
m_BehaviorState = ViewTool.FPS;
345371

346372
// see also SceneView.HandleClickAndDragToFocus()
347373
if (evt.button == 1 && onMac)

com.unity.render-pipelines.core/Editor/Volume/VolumeComponentEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ protected SerializedDataParameter Unpack(SerializedProperty property)
318318
/// <param name="property">The property to draw in the editor</param>
319319
protected void PropertyField(SerializedDataParameter property)
320320
{
321-
var title = EditorGUIUtility.TrTextContent(property.displayName);
321+
var title = EditorGUIUtility.TrTextContent(property.displayName, property.GetAttribute<TooltipAttribute>()?.tooltip);
322322
PropertyField(property, title);
323323
}
324324

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
88

99
### Added
1010
- Added a new API to bake HDRP probes from C# (case 1276360)
11+
- Added support for pre-exposure for planar reflections.
1112

1213
### Fixed
1314
- Fixed probe volumes debug views.
@@ -43,6 +44,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
4344
- Fixed the clear coat not being handled properly for SSR and RTR (case 1291654).
4445
- Fixed ghosting in RTGI and RTAO when denoising is enabled and the RTHandle size is not equal to the Viewport size (case 1291654).
4546
- Fixed alpha output when atmospheric scattering is enabled.
47+
- Fixed issue with TAA history sharpening when view is downsampled.
48+
- Fixed lookdev movement.
49+
- Fixed volume component tooltips using the same parameter name.
50+
- Fixed issue with saving some quality settings in volume overrides (case 1293747)
51+
- Fixed NullReferenceException in HDRenderPipeline.UpgradeResourcesIfNeeded (case 1292524)
52+
- Fixed SSGI texture allocation when not using the RenderGraph.
53+
- Fixed NullReference Exception when setting Max Shadows On Screen to 0 in the HDRP asset.
4654

4755
### Changed
4856
- Volume Manager now always tests scene culling masks. This was required to fix hybrid workflow.
@@ -193,7 +201,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
193201
- Added the support of eye shader for ray tracing.
194202
- Exposed Refraction Model to the material UI when using a Lit ShaderGraph.
195203
- Added bounding sphere support to screen-space axis-aligned bounding box generation pass.
196-
- Added support for exposure for the case of planar reflections.
197204

198205
### Fixed
199206
- Fixed several issues with physically-based DoF (TAA ghosting of the CoC buffer, smooth layer transitions, etc)

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,22 @@ public override void OnEnable()
9898

9999
void RayTracingQualityModeGUI()
100100
{
101-
PropertyField(m_MinSmoothness, k_MinimumSmoothnessText);
102-
PropertyField(m_SmoothnessFadeStart, k_SmoothnessFadeStartText);
103-
m_SmoothnessFadeStart.value.floatValue = Mathf.Max(m_MinSmoothness.value.floatValue, m_SmoothnessFadeStart.value.floatValue);
104-
PropertyField(m_RayLength, k_RayLengthText);
105-
PropertyField(m_ClampValue, k_ClampValueText);
106-
PropertyField(m_SampleCount, k_SampleCountText);
107-
PropertyField(m_BounceCount, k_BounceCountText);
108-
PropertyField(m_Denoise, k_DenoiseText);
101+
base.OnInspectorGUI();
109102
using (new HDEditorUtils.IndentScope())
103+
using (new QualityScope(this))
110104
{
111-
PropertyField(m_DenoiserRadius, k_DenoiseRadiusText);
105+
PropertyField(m_MinSmoothness, k_MinimumSmoothnessText);
106+
PropertyField(m_SmoothnessFadeStart, k_SmoothnessFadeStartText);
107+
m_SmoothnessFadeStart.value.floatValue = Mathf.Max(m_MinSmoothness.value.floatValue, m_SmoothnessFadeStart.value.floatValue);
108+
PropertyField(m_RayLength, k_RayLengthText);
109+
PropertyField(m_ClampValue, k_ClampValueText);
110+
PropertyField(m_SampleCount, k_SampleCountText);
111+
PropertyField(m_BounceCount, k_BounceCountText);
112+
PropertyField(m_Denoise, k_DenoiseText);
113+
using (new HDEditorUtils.IndentScope())
114+
{
115+
PropertyField(m_DenoiserRadius, k_DenoiseRadiusText);
116+
}
112117
}
113118
}
114119

com.unity.render-pipelines.high-definition/Editor/Material/DiffusionProfile/DiffusionProfileMaterialUI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace UnityEditor.Rendering.HighDefinition
88
{
99
static class DiffusionProfileMaterialUI
1010
{
11-
static GUIContent diffusionProfileNotInHDRPAsset = new GUIContent("You must make sure that this diffusion profile is either referenced in the HDRP asset or in the Diffusion Profile Override to make it work.", EditorGUIUtility.IconContent("console.infoicon").image);
11+
static GUIContent diffusionProfileNotInHDRPAsset = new GUIContent("Make sure this Diffusion Profile is referenced in either a Diffusion Profile Override or the HDRP Default Settings. If the Diffusion Profile is not referenced in either, HDRP cannot use it. To add a reference to the Diffusion Profile in the HDRP Default Settings, press Fix.", EditorGUIUtility.IconContent("console.infoicon").image);
1212

1313
public static bool IsSupported(MaterialEditor materialEditor)
1414
{

com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/GlobalIlluminationEditor.cs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,17 @@ public override void OnInspectorGUI()
145145
break;
146146
case RayTracingMode.Quality:
147147
{
148-
PropertyField(m_RayLength, k_RayLengthText);
149-
PropertyField(m_ClampValue);
150-
PropertyField(m_SampleCount);
151-
PropertyField(m_BounceCount);
152-
DenoiserGUI();
148+
base.OnInspectorGUI(); // Quality Setting
149+
150+
using (new HDEditorUtils.IndentScope())
151+
using (new QualityScope(this))
152+
{
153+
PropertyField(m_RayLength, k_RayLengthText);
154+
PropertyField(m_ClampValue);
155+
PropertyField(m_SampleCount);
156+
PropertyField(m_BounceCount);
157+
DenoiserGUI();
158+
}
153159
}
154160
break;
155161
}
@@ -158,11 +164,16 @@ public override void OnInspectorGUI()
158164
else if (currentAsset.currentPlatformRenderPipelineSettings.supportedRayTracingMode ==
159165
RenderPipelineSettings.SupportedRayTracingMode.Quality)
160166
{
161-
PropertyField(m_RayLength, k_RayLengthText);
162-
PropertyField(m_ClampValue);
163-
PropertyField(m_SampleCount);
164-
PropertyField(m_BounceCount);
165-
DenoiserGUI();
167+
base.OnInspectorGUI(); // Quality Setting
168+
EditorGUI.indentLevel++;
169+
using (new QualityScope(this))
170+
{
171+
PropertyField(m_RayLength, k_RayLengthText);
172+
PropertyField(m_ClampValue);
173+
PropertyField(m_SampleCount);
174+
PropertyField(m_BounceCount);
175+
DenoiserGUI();
176+
}
166177
}
167178
else
168179
{

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4208,6 +4208,9 @@ static void RenderLightLoopDebugOverlay(in DebugParameters debugParameters,
42084208

42094209
static void RenderShadowsDebugOverlay(in DebugParameters debugParameters, in HDShadowManager.ShadowDebugAtlasTextures atlasTextures, CommandBuffer cmd, MaterialPropertyBlock mpb)
42104210
{
4211+
if (HDRenderPipeline.currentAsset.currentPlatformRenderPipelineSettings.hdShadowInitParams.maxShadowRequests == 0)
4212+
return;
4213+
42114214
LightingDebugSettings lightingDebug = debugParameters.debugDisplaySettings.data.lightingDebugSettings;
42124215
if (lightingDebug.shadowDebugMode != ShadowMapDebugMode.None)
42134216
{

com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/lightlistbuild-clustered.compute

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,11 @@ void LIGHTLISTGEN(uint threadID : SV_GroupIndex, uint3 u3GroupID : SV_GroupID)
233233
for(int i=0; i<g_iNumSamplesMSAA; i++)
234234
{
235235
const float fDpth = FetchDepthMSAA(uPixCrd, i);
236-
#if defined(SHADER_API_METAL) // GetSamplePosition isn't supported on Metal yet in Unity. TODO: remove when support is added
236+
#if defined(SHADER_API_METAL) // GetSamplePosition isn't supported on Metal yet in Unity. TODO: remove when support is added
237237
const float2 fracSampleCoord = float2(0.0, 0.0);
238-
#else
239-
const float2 fracSampleCoord = g_depth_tex.GetSamplePosition(i).xy; // this is optimized away when USE_OBLIQUE_MODE is NOT set.
240-
#endif
238+
#else
239+
const float2 fracSampleCoord = g_depth_tex.GetSamplePosition(i).xy; // this is optimized away when USE_OBLIQUE_MODE is NOT set.
240+
#endif
241241
#else
242242
const float fDpth = FetchDepth(uPixCrd);
243243
const float2 fracSampleCoord = float2(0.5,0.5);

com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,16 @@ private HDShadowManager()
307307

308308
public void InitShadowManager(RenderPipelineResources renderPipelineResources, HDShadowInitParameters initParams, Shader clearShader)
309309
{
310+
// Even when shadows are disabled (maxShadowRequests == 0) we need to allocate compute buffers to avoid having
311+
// resource not bound errors when dispatching a compute shader.
312+
m_ShadowDataBuffer = new ComputeBuffer(Mathf.Max(initParams.maxShadowRequests, 1), System.Runtime.InteropServices.Marshal.SizeOf(typeof(HDShadowData)));
313+
m_DirectionalShadowDataBuffer = new ComputeBuffer(1, System.Runtime.InteropServices.Marshal.SizeOf(typeof(HDDirectionalShadowData)));
314+
m_MaxShadowRequests = initParams.maxShadowRequests;
315+
m_ShadowRequestCount = 0;
316+
317+
if (initParams.maxShadowRequests == 0)
318+
return;
319+
310320
m_ClearShadowMaterial = CoreUtils.CreateEngineMaterial(clearShader);
311321
m_BlitShadowMaterial = CoreUtils.CreateEngineMaterial(renderPipelineResources.shaders.shadowBlitPS);
312322

@@ -332,11 +342,6 @@ public void InitShadowManager(RenderPipelineResources renderPipelineResources, H
332342
m_AreaLightShadowAtlas = new HDDynamicShadowAtlas(renderPipelineResources, initParams.areaLightShadowAtlas.shadowAtlasResolution, initParams.areaLightShadowAtlas.shadowAtlasResolution,
333343
HDShaderIDs._ShadowmapAreaAtlas, m_ClearShadowMaterial, initParams.maxShadowRequests, initParams, HDShadowAtlas.BlurAlgorithm.EVSM, depthBufferBits: initParams.areaLightShadowAtlas.shadowAtlasDepthBits, name: "Area Light Shadow Map Atlas");
334344

335-
m_ShadowDataBuffer = new ComputeBuffer(initParams.maxShadowRequests, System.Runtime.InteropServices.Marshal.SizeOf(typeof(HDShadowData)));
336-
m_DirectionalShadowDataBuffer = new ComputeBuffer(1, System.Runtime.InteropServices.Marshal.SizeOf(typeof(HDDirectionalShadowData)));
337-
338-
m_MaxShadowRequests = initParams.maxShadowRequests;
339-
340345
cachedShadowManager.InitPunctualShadowAtlas(renderPipelineResources, initParams.cachedPunctualLightShadowAtlas, initParams.cachedPunctualLightShadowAtlas,
341346
HDShaderIDs._CachedShadowmapAtlas, m_ClearShadowMaterial, initParams.maxShadowRequests, initParams: initParams, depthBufferBits: initParams.punctualLightShadowAtlas.shadowAtlasDepthBits, name: "Cached Shadow Map Atlas");
342347
if (ShaderConfig.s_AreaLights == 1)
@@ -392,6 +397,9 @@ public static DirectionalShadowAlgorithm GetDirectionalShadowAlgorithm()
392397

393398
public void UpdateShaderVariablesGlobalCB(ref ShaderVariablesGlobal cb)
394399
{
400+
if (m_MaxShadowRequests == 0)
401+
return;
402+
395403
cb._CascadeShadowCount = (uint)(m_CascadeCount + 1);
396404
cb._ShadowAtlasSize = new Vector4(m_Atlas.width, m_Atlas.height, 1.0f / m_Atlas.width, 1.0f / m_Atlas.height);
397405
cb._CascadeShadowAtlasSize = new Vector4(m_CascadeAtlas.width, m_CascadeAtlas.height, 1.0f / m_CascadeAtlas.width, 1.0f / m_CascadeAtlas.height);
@@ -596,6 +604,9 @@ public void UpdateCullingParameters(ref ScriptableCullingParameters cullingParam
596604

597605
public void LayoutShadowMaps(LightingDebugSettings lightingDebugSettings)
598606
{
607+
if (m_MaxShadowRequests == 0)
608+
return;
609+
599610
cachedShadowManager.UpdateDebugSettings(lightingDebugSettings);
600611

601612
m_Atlas.UpdateDebugSettings(lightingDebugSettings);
@@ -627,6 +638,9 @@ public void LayoutShadowMaps(LightingDebugSettings lightingDebugSettings)
627638

628639
unsafe public void PrepareGPUShadowDatas(CullingResults cullResults, HDCamera camera)
629640
{
641+
if (m_MaxShadowRequests == 0)
642+
return;
643+
630644
int shadowIndex = 0;
631645

632646
m_ShadowDatas.Clear();
@@ -787,6 +801,9 @@ public int GetShadowRequestCount()
787801

788802
public void Clear()
789803
{
804+
if (m_MaxShadowRequests == 0)
805+
return;
806+
790807
// Clear the shadows atlas infos and requests
791808
m_Atlas.Clear();
792809
m_CascadeAtlas.Clear();
@@ -897,6 +914,10 @@ public void Dispose()
897914
{
898915
m_ShadowDataBuffer.Dispose();
899916
m_DirectionalShadowDataBuffer.Dispose();
917+
918+
if (m_MaxShadowRequests == 0)
919+
return;
920+
900921
m_Atlas.Release();
901922
if (ShaderConfig.s_AreaLights == 1)
902923
m_AreaLightShadowAtlas.Release();

com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,6 +1598,7 @@ struct TemporalAntiAliasingParameters
15981598
public MaterialPropertyBlock taaPropertyBlock;
15991599
public bool resetPostProcessingHistory;
16001600

1601+
public Vector4 previousScreenSize;
16011602
public Vector4 taaParameters;
16021603
public Vector4 taaFilterWeights;
16031604
public bool motionVectorRejection;
@@ -1681,6 +1682,8 @@ TemporalAntiAliasingParameters PrepareTAAParameters(HDCamera camera, bool PostDO
16811682

16821683
parameters.taaHistoryPropertyBlock = m_TAAHistoryBlitPropertyBlock;
16831684
parameters.taaPropertyBlock = m_TAAPropertyBlock;
1685+
Vector2Int prevViewPort = camera.historyRTHandleProperties.previousViewportSize;
1686+
parameters.previousScreenSize = new Vector4(prevViewPort.x, prevViewPort.y, 1.0f / prevViewPort.x, 1.0f / prevViewPort.y);
16841687

16851688
return parameters;
16861689
}
@@ -1719,9 +1722,7 @@ static void DoTemporalAntialiasing(in TemporalAntiAliasingParameters taaParams,
17191722

17201723
taaParams.taaPropertyBlock.SetTexture(HDShaderIDs._DepthTexture, depthMipChain);
17211724

1722-
Vector2 historySize = new Vector2(prevHistory.referenceSize.x * prevHistory.scaleFactor.x,
1723-
prevHistory.referenceSize.y * prevHistory.scaleFactor.y);
1724-
var taaHistorySize = new Vector4(historySize.x, historySize.y, 1.0f / historySize.x, 1.0f / historySize.y);
1725+
var taaHistorySize = taaParams.previousScreenSize;
17251726

17261727
taaParams.taaPropertyBlock.SetVector(HDShaderIDs._TaaPostParameters, taaParams.taaParameters);
17271728
taaParams.taaPropertyBlock.SetVector(HDShaderIDs._TaaHistorySize, taaHistorySize);

0 commit comments

Comments
 (0)