From 6f397e9a2ecea271d7c734d19843d6c97e223509 Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Thu, 24 Apr 2025 18:26:30 +0200 Subject: [PATCH] Auto-sync from SVN revision 61331 --- .../CHANGELOG.md | 60 ++ .../Editor/CoreEditorUtils.cs | 2 +- .../Debugging/DebugUIDrawer.Builtins.cs | 11 +- .../Editor/Debugging/DebugWindow.cs | 69 ++- .../ProbeGIBaking.LightTransport.cs | 62 ++- .../ProbeGIBaking.Serialization.cs | 10 +- .../Lighting/ProbeVolume/ProbeGIBaking.cs | 2 +- .../Lighting/ProbeVolume/ProbeVolumeEditor.cs | 2 +- .../ProbeVolume/ProbeVolumeLightingTab.cs | 7 +- .../Editor/LookDev/EnvironmentLibrary.cs | 2 +- .../Editor/RenderGraph/RenderGraphViewer.cs | 4 +- .../Debugging/DebugDisplaySettingsUI.cs | 4 + .../Debugging/DebugDisplaySettingsVolumes.cs | 519 ++++++++++-------- .../Runtime/Debugging/DebugUI.Panel.cs | 4 + .../Runtime/Debugging/VolumeDebugSettings.cs | 34 +- .../Runtime/Documentation.cs | 74 ++- .../Debug/DebugDisplayGPUResidentDrawer.cs | 1 + .../Runtime/GPUDriven/GPUResidentBatcher.cs | 66 ++- .../GPUDriven/GPUResidentDrawer.Validator.cs | 5 + .../Runtime/GPUDriven/GPUResidentDrawer.cs | 242 +++++++- .../GPUDriven/InstanceCullingBatcher.cs | 93 +++- .../InstanceData/InstanceAllocator.cs | 2 +- .../ProbeVolume/ProbeAdjustmentVolume.cs | 2 +- .../ProbeReferenceVolume.Streaming.cs | 2 + .../ProbeVolume/ProbeReferenceVolume.cs | 3 +- .../Lighting/ProbeVolume/ProbeVolume.cs | 2 +- .../ProbeVolume/ProbeVolumePerSceneData.cs | 7 + .../ProbeVolumeScratchBufferPool.cs | 6 + .../Debug/DebugDisplaySettingsRenderGraph.cs | 1 + .../Default Lens Flare (SRP).asset | 77 ++- .../Runtime/Volume/VolumeComponent.cs | 11 + .../Runtime/Volume/VolumeParameter.cs | 4 + .../Shadow/ShadowSamplingTent.hlsl | 202 +++---- .../GPUDriven/GPUDrivenRenderingTests.cs | 30 +- .../Tests/Editor/RenderGraphViewerTests.cs | 4 +- .../package.json | 4 +- .../CHANGELOG.md | 7 + .../package.json | 6 +- .../CHANGELOG.md | 120 ++++ .../Editor/Compositor/CompositorWindow.cs | 2 +- .../HDScreenSpaceReflectionEditor.cs | 6 +- .../Reflection/ScreenSpaceRefractionEditor.cs | 2 +- .../ScreenSpaceAmbientOcclusionEditor.cs | 4 +- .../Lighting/Shadow/ContactShadowsEditor.cs | 2 +- .../Lighting/Shadow/HDShadowSettingsEditor.cs | 2 +- .../VolumetricCloudsEditor.cs | 2 +- .../Editor/PostProcessing/BloomEditor.cs | 2 +- .../ChromaticAberrationEditor.cs | 2 +- .../PostProcessing/DepthOfFieldEditor.cs | 2 +- .../Editor/PostProcessing/FilmGrainEditor.cs | 2 +- .../Editor/PostProcessing/MotionBlurEditor.cs | 2 +- .../PostProcessing/PaniniProjectionEditor.cs | 2 +- .../ScreenSpaceLensFlareEditor.cs | 15 +- .../PostProcessing/TonemappingEditor.cs | 2 +- .../Editor/PostProcessing/VignetteEditor.cs | 2 +- .../Camera/HDCameraUI.Drawers.cs | 2 +- .../Editor/RenderPipeline/HDEditorUtils.cs | 135 ++--- ...ine.LineRendering.VolumeComponentEditor.cs | 2 +- .../PathTracing/PathTracingEditor.cs | 2 +- .../Raytracing/GlobalIlluminationEditor.cs | 4 +- .../Raytracing/LightClusterEditor.cs | 2 +- .../Raytracing/RayTracingSettingsEditor.cs | 2 +- .../Raytracing/RecursiveRenderingEditor.cs | 2 +- .../Raytracing/SubSurfaceScatteringEditor.cs | 2 +- .../Sky/AtmosphericScattering/FogEditor.cs | 4 +- .../Sky/HDLightingWindowEnvironmentSection.cs | 47 +- .../VFXGraph/Outputs/VFXDecalHDRPOutput.cs | 2 +- .../Editor/Water/WaterRenderingEditor.cs | 2 +- .../Water/WaterSurface/WaterSurfaceEditor.cs | 4 +- .../Editor/Wizard/HDWizard.Configuration.cs | 100 ++-- .../Editor/Wizard/HDWizard.UIElement.cs | 95 ++-- .../Editor/Wizard/HDWizard.Window.cs | 15 +- .../Editor/Wizard/USS/Wizard.uss | 2 +- .../Debug/DebugDisplaySettingsDecal.cs | 1 + .../Lighting/AtmosphericScattering/Fog.cs | 2 +- .../Lighting/Light/HDAdditionalLightData.cs | 5 +- .../Runtime/Lighting/LightEvaluation.hlsl | 22 +- .../VolumetricClouds/VolumetricClouds.cs | 2 +- .../VolumetricLighting/LocalVolumetricFog.cs | 2 +- .../Runtime/Material/Decal/DecalProjector.cs | 2 +- .../DiffusionProfileSettings.cs | 2 +- .../Runtime/Material/Lit/Lit.hlsl | 2 +- .../Material/TerrainLit/TerrainLitData.hlsl | 2 + .../Components/ScreenSpaceLensFlare.cs | 2 +- .../Camera/HDAdditionalCameraData.cs | 2 +- .../Runtime/RenderPipeline/Camera/HDCamera.cs | 30 +- .../HDRenderPipeline.RenderGraph.cs | 6 + .../RenderPipeline/HDRenderPipeline.cs | 2 +- .../LineRendering/Core/LineRendering.cs | 3 + .../Shaders/Denoising/TemporalFilter.compute | 2 +- .../Upscalers/FSR/Runtime/FSR2/Fsr2Context.cs | 94 ++-- .../FSR/Runtime/FSR3/Fsr3UpscalerContext.cs | 9 +- .../FSR/Runtime/FSR3/Fsr3UpscalerPass.cs | 5 +- .../FSR/Runtime/FSR3/Fsr3UpscalerResources.cs | 7 +- .../ffx_fsr3upscaler_luma_pyramid_pass.hlsl | 3 +- .../ffx_fsr3upscaler_accumulate.h | 8 +- .../ffx_fsr3upscaler_luma_pyramid.h | 4 +- .../Upscalers/FSR2UpscalerPlugin.cs | 20 +- .../Upscalers/FSR3UpscalerPlugin.cs | 159 +++++- .../RenderPipeline/Settings/FrameSettings.cs | 4 +- .../ShaderLibrary/ShaderVariables.hlsl | 2 +- .../Sky/CloudSystem/CloudLayer/CloudLayer.cs | 2 +- .../Runtime/Sky/GradientSky/GradientSky.cs | 2 +- .../Runtime/Sky/HDRISky/HDRISky.cs | 2 +- .../PhysicallyBasedSky/PhysicallyBasedSky.cs | 2 +- .../Runtime/Sky/StaticLightingSky.cs | 2 +- .../Water/HDRenderPipeline.WaterSystem.cs | 4 +- .../Runtime/Water/WaterDecal/WaterDecal.cs | 2 +- .../Runtime/Water/WaterExcluder.cs | 2 +- .../Runtime/Water/WaterRendering.cs | 2 +- .../Water/WaterSurface/WaterSurface.cs | 2 +- .../Tests/Editor/HDCameraTests.cs | 58 ++ .../Tests/Editor/HDCameraTests.cs.meta | 3 + .../package.json | 12 +- Packages/com.unity.shadergraph/CHANGELOG.md | 44 ++ .../ShaderGraph/Includes/PBRDeferredPass.hlsl | 4 +- Packages/com.unity.shadergraph/package.json | 13 +- .../Editor/TMP/TMPro_ContextMenus.cs | 26 +- .../TMP/TMPro_FontAssetCreatorWindow.cs | 4 +- .../TMP Essential Resources.unitypackage | 4 +- .../TMP Examples & Extras.unitypackage | 4 +- .../Runtime/TMP/TMP_DefaultControls.cs | 4 + .../Runtime/TMP/TMP_FontAsset.cs | 31 +- .../Runtime/TMP/TMP_FontAssetUtilities.cs | 104 ++-- .../com.unity.ugui/Runtime/TMP/TMP_Text.cs | 61 +- .../com.unity.ugui/Runtime/TMP/TextMeshPro.cs | 11 +- .../Runtime/TMP/TextMeshProUGUI.cs | 11 +- .../TMP/Unity.TextMeshPro.Editor.Tests.asmdef | 26 +- .../UI/PropertyDrawers/PropertyDrawerTests.cs | 2 +- .../UGUI/UnityEditor.UI.EditorTests.asmdef | 24 +- .../TMP/Unity.TextMeshPro.Tests.asmdef | 26 +- .../Runtime/UGUI/UnityEngine.UI.Tests.asmdef | 6 +- Packages/com.unity.ugui/package.json | 2 +- .../com.unity.visualeffectgraph/CHANGELOG.md | 88 +++ .../Controllers/VFXDataAnchorController.cs | 6 +- .../Controllers/VFXOperatorController.cs | 8 +- .../GraphView/Elements/VFXDataAnchor.cs | 2 +- .../GraphView/Elements/VFXEdgeDragInfo.cs | 8 +- .../GraphView/Profiling/VFXProfilingBoard.cs | 2 + .../Editor/GraphView/VFXComponentBoard.cs | 2 + .../GraphView/Views/VFXHelpDropdownButton.cs | 16 - .../Editor/Inspector/VFXAssetEditor.cs | 3 +- .../Editor/Manipulators/SuperCollapser.cs | 2 +- .../Contexts/VFXAbstractParticleOutput.cs | 16 +- .../Operators/Implementations/CustomHLSL.cs | 2 +- .../TemplateWindow/VFXTemplateWindow.cs | 50 +- .../UIResources/VFX/EditStolen.png.meta | 66 ++- .../Editor/UIResources/VFX/Execution.png.meta | 110 +++- .../UIResources/VFX/FloatField.png.meta | 25 +- .../UIResources/VFX/FloatField@2x.png.meta | 25 +- .../UIResources/VFX/FloatField@4x.png.meta | 25 +- .../UIResources/VFX/FloatField@8x.png.meta | 25 +- .../Editor/UIResources/VFX/Folder.png.meta | 22 +- .../UIResources/VFX/LocalSpace.png.meta | 19 +- .../UIResources/VFX/LocalSpace@2x.png.meta | 19 +- .../VFX/NodeSearch-expand.png.meta | 19 +- .../VFX/NodeSearch-expand@2x.png.meta | 19 +- .../UIResources/VFX/NoneSpace@2x.png.meta | 17 +- .../UIResources/VFX/ParticleStrips.png.meta | 52 +- .../VFX/ParticleStrips@2x.png.meta | 62 ++- .../Editor/UIResources/VFX/Particles.png.meta | 118 +++- .../UIResources/VFX/Particles@2x.png.meta | 118 +++- .../Editor/UIResources/VFX/Pause.png.meta | 63 ++- .../Editor/UIResources/VFX/Play.png.meta | 63 ++- .../Editor/UIResources/VFX/Restart.png.meta | 63 ++- .../Editor/UIResources/VFX/Step.png.meta | 63 ++- .../Editor/UIResources/VFX/Stop.png.meta | 63 ++- .../UIResources/VFX/WorldSpace.png.meta | 19 +- .../UIResources/VFX/WorldSpace@2x.png.meta | 19 +- .../UIResources/VFX/bitfield-bit.png.meta | 45 +- .../UIResources/VFX/bitfield-bkgnd.png.meta | 45 +- .../VFX/cat-background-dark.png.meta | 45 +- .../VFX/cat-background-light.png.meta | 45 +- .../Editor/UIResources/VFX/compile.png.meta | 44 +- .../UIResources/VFX/compile@2x.png.meta | 44 +- .../Editor/UIResources/VFX/controls.png.meta | 44 +- .../UIResources/VFX/controls@2x.png.meta | 44 +- .../Editor/UIResources/VFX/d_Age.png.meta | 26 +- .../Editor/UIResources/VFX/d_Awake.png.meta | 28 +- .../Editor/UIResources/VFX/d_Culled.png.meta | 28 +- .../UIResources/VFX/d_LocalSpace.png.meta | 19 +- .../UIResources/VFX/d_LocalSpace@2x.png.meta | 19 +- .../VFX/d_NodeSearch-expand.png.meta | 19 +- .../VFX/d_NodeSearch-expand@2x.png.meta | 19 +- .../UIResources/VFX/d_NoneSpace@2x.png.meta | 19 +- .../UIResources/VFX/d_Position.png.meta | 26 +- .../Editor/UIResources/VFX/d_Record.png.meta | 56 +- .../UIResources/VFX/d_Rotation.png.meta | 26 +- .../Editor/UIResources/VFX/d_Sleep.png.meta | 28 +- .../Editor/UIResources/VFX/d_Visible.png.meta | 28 +- .../UIResources/VFX/d_WorldSpace.png.meta | 19 +- .../UIResources/VFX/d_WorldSpace@2x.png.meta | 19 +- .../Editor/UIResources/VFX/d_compile.png.meta | 44 +- .../UIResources/VFX/d_compile@2x.png.meta | 44 +- .../UIResources/VFX/d_controls.png.meta | 44 +- .../UIResources/VFX/d_controls@2x.png.meta | 44 +- .../Editor/UIResources/VFX/d_debug.png | Bin 0 -> 2693 bytes .../Editor/UIResources/VFX/d_debug.png.meta | 130 +++++ .../UIResources/VFX/d_pauseBadge.png.meta | 28 +- .../UIResources/VFX/d_playBadge.png.meta | 28 +- .../UIResources/VFX/d_stopBadge.png.meta | 26 +- .../VFX/d_sub-variant-hidden.png.meta | 19 +- .../VFX/d_sub-variant-visible.png.meta | 19 +- .../UIResources/VFX/d_subgraph-block.png.meta | 41 +- .../VFX/d_subgraph-operator.png.meta | 41 +- .../VFX/d_variableswindow.png.meta | 44 +- .../VFX/d_variableswindow@2x.png.meta | 44 +- .../Editor/UIResources/VFX/debug.png | Bin 618 -> 2831 bytes .../Editor/UIResources/VFX/debug.png.meta | 30 +- .../UIResources/VFX/exposed-dot.png.meta | 69 ++- .../UIResources/VFX/lock_locked.png.meta | 28 +- .../UIResources/VFX/lock_unlocked.png.meta | 28 +- .../UIResources/VFX/marker_In1x.png.meta | 30 +- .../UIResources/VFX/marker_In2x.png.meta | 30 +- .../UIResources/VFX/marker_Out1x.png.meta | 30 +- .../UIResources/VFX/marker_Out2x.png.meta | 30 +- .../UIResources/VFX/marker_Single1x.png.meta | 30 +- .../UIResources/VFX/marker_Single2x.png.meta | 30 +- .../Editor/UIResources/VFX/minus.png.meta | 64 ++- .../UIResources/VFX/output-dot.png.meta | 55 +- .../Editor/UIResources/VFX/plus.png.meta | 64 ++- .../Editor/UIResources/VFX/profiling.png.meta | 28 +- .../VFX/sub-variant-hidden.png.meta | 24 +- .../VFX/sub-variant-visible.png.meta | 24 +- .../UIResources/VFX/subgraph-block.png.meta | 41 +- .../VFX/subgraph-operator.png.meta | 41 +- .../UIResources/VFX/variableswindow.png.meta | 44 +- .../VFX/variableswindow@2x.png.meta | 44 +- .../VFX/vfx_graph_icon_gray_dark.png.meta | 59 +- .../VFX/vfx_graph_icon_gray_light.png.meta | 59 +- .../UIResources/uss/VFXAnchoredProfiler.uss | 2 +- .../UIResources/uss/VFXProfilingBoard.uss | 4 +- .../Editor/UIResources/uss/VFXToolbar.uss | 20 +- .../Editor/UIResources/uss/VFXView.uss | 24 +- .../uxml/VFXHelpDropdownPanel.uxml | 8 +- .../com.unity.visualeffectgraph/package.json | 8 +- 236 files changed, 5072 insertions(+), 1650 deletions(-) create mode 100644 Packages/com.unity.render-pipelines.high-definition/Tests/Editor/HDCameraTests.cs create mode 100644 Packages/com.unity.render-pipelines.high-definition/Tests/Editor/HDCameraTests.cs.meta create mode 100644 Packages/com.unity.visualeffectgraph/Editor/UIResources/VFX/d_debug.png create mode 100644 Packages/com.unity.visualeffectgraph/Editor/UIResources/VFX/d_debug.png.meta diff --git a/Packages/com.unity.render-pipelines.core/CHANGELOG.md b/Packages/com.unity.render-pipelines.core/CHANGELOG.md index 1b94923d..ac6e577b 100644 --- a/Packages/com.unity.render-pipelines.core/CHANGELOG.md +++ b/Packages/com.unity.render-pipelines.core/CHANGELOG.md @@ -10,6 +10,66 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. Version Updated The version number for this package has increased due to a version update of a related graphics package. +## [17.0.3] - 2025-02-13 + +This version is compatible with Unity 6000.0.39f1. + +### Added +- helper functions to Render Graph. + +### Changed +- Improved the Native Render Pass CPU performance by implementing a Render Pass pooling system (URP RG). +- Reworked the additional properties. +- Improved Render Graph warning message in URP when missing RecordRenderGraph implementation. +- Displayed subpass and attachment index on Render Graph Viewer. +- Added a new icon and tooltip if there are multiple usage details for a resource block on Render Graph Viewer. +- Fixed Render Graph Viewer being called before Render Graph execution and its resource deallocation. +- Added What's New in Unity 6 to SRP Core Package. + +### Fixed +- Added messaging to the Rendering Debugger UI to make it clearer that GPU Resident Drawer settings do not work if GPU Resident Drawer is not enabled. +- GPU Resident Drawer: Changed BatchRendererGroup variants was not reinitializing the system. +- Improved the compiler logic that detects if the current render target is being used outside the current native render pass (e.g., when the pass is broken up by an unsafe pass), and determines the store action for this case. The fix now ensures that the `StoreAndResolve` action is used when the resource is read by an Unsafe Pass. +- Rendering Debugger - Keep the correct selected panel when entering and exiting from playmode. +- Removed "depth only surface" warning message appearing when using Game View Gizmos in URP RG. +- Render Graph Viewer: Fixed missing min height when resizing side panel vertical splitter. +- Render Graph Viewer: Fixed possible NullReferenceException when opening the project. +- Render Graph Viewer: Fixed side panel splitter state after returning from empty pass/resource filter. +- Render Graph Viewer: Fixed long resource name clipping issues in side panel. +- Render Graph Viewer: Fixed tooltip size bug and restructure tooltip messages. +- Fixed memory usage regression causing up to 150MB higher memory usage in URP player builds. +- Added missing user-facing text when inspecting volume profile when render pipeline has not been properly initialized yet. +- Game view background turn yellow after enable render graph. +- Fixed light.useViewFrustumForShadowCasterCull previously being ignored for shadow cascades. light.useViewFrustumForShadowCasterCull now works as expected. +- Fixed an exception thrown when Render Graph pass was missing its renderFunc but tried to compute its hash value. +- Fixed Render Graph Compiler logic bug where UnsafePass using MSAA texture could result in missing resolve surface errors. +- Fixed incorrect default source texture name for Render Graph blit util function. +- Fixed NullReferenceException when jumping to pass code from Render Graph Viewer. +- Fixed _FOVEATED_RENDERING_NON_UNIFORM_RASTER shader compilation errors. +- Fixed a null reference exception on the Graphics Settings stripper. +- Avoid that the same volume can be registered more than 1 time in the VolumeManager. +- Fixed crash caused by indirect argument buffer being one item too small. +- [GLES3] Fixed an issue where Blitter.GetBlitMaterial(TextureDimension.Tex2DArray) returns null. +- Fixed alignment of the columns on DebugUI.Foldouts. +- Fixed BlitTexture(RenderTargetIdentifier) to be affected by PostProcessing. +- Fixed errors that could happen when interacting with the Default Volume Profile context menu in Project Settings > Graphics. +- Fixed a numerical error of ComputeEdgeFactor(V1, V2) when two vectors are colinear. +- Fixed potential data corruption due to incorrect native render pass store action in NRP compiler. +- Added stencil flag to read-only depth logic in NRP compiler to avoid unintentional usage of depth read and stencil write states on some APIs. +- Added more error checking to `RenderGraph.ImportTexture` to prevent importing RenderTextures that have both color and depth. +An exception will now be thrown in this case. +- Fixed an issue when using multiple AddBlitPass would binds the _BlitTexture wrongly. +- Modified TextureDesc so it can now use GraphicsFormat to set the depthStencil format (TextureDesc.format). The TextureDesc.depthBufferBits and TextureDesc.colorFormat fields are now properties that call GraphicsFormatUtilities functions for backwards compatibility. The descriptor now unambiguously describes a single resource, either color or depth. Therefore, TextureHandle clearly represents a single resource. +- Modified RTHandle allocators so they can now use GraphicsFormat to set the depthStencil format (TextureDesc.format). The allocators take a single format for either color or depth stencil to avoid incorrectly creating depth instead of color or vice versa. +- Fixed a crash on DX12 due to invalid subpass flags passed by native render pass compiler. +- Fixed an issue where Lens Flare was not rendering properly in OpenGLES3. +- Fixed render graph incorrectly handling rendering to array slices and mipmaps other than 0 in some cases. +- Render Graph Viewer - Improved UI lock when searching on side panels. +- Render Graph Viewer - Padding corrected on burger menu on the side panels. +- Fixed missing STP shaders & visual artifacts when targeting GLCore renderer +- Rendering Debugger - Silent crash when selecting a Volume component with public RTHandles. +- Fixed a crash on leaking streaming scratch buffer differently sized into the current pool. + ## [17.0.2] - 2024-04-02 This version is compatible with Unity 6000.0.0b15. diff --git a/Packages/com.unity.render-pipelines.core/Editor/CoreEditorUtils.cs b/Packages/com.unity.render-pipelines.core/Editor/CoreEditorUtils.cs index 0f9077c7..0d8a485d 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/CoreEditorUtils.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/CoreEditorUtils.cs @@ -863,7 +863,7 @@ namespace UnityEditor.Rendering return state; } - static void ShowHelpButton(Rect contextMenuRect, string documentationURL, GUIContent title) + internal static void ShowHelpButton(Rect contextMenuRect, string documentationURL, GUIContent title) { if (string.IsNullOrEmpty(documentationURL)) return; diff --git a/Packages/com.unity.render-pipelines.core/Editor/Debugging/DebugUIDrawer.Builtins.cs b/Packages/com.unity.render-pipelines.core/Editor/Debugging/DebugUIDrawer.Builtins.cs index cb89a140..f5bed0d0 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Debugging/DebugUIDrawer.Builtins.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Debugging/DebugUIDrawer.Builtins.cs @@ -830,7 +830,10 @@ namespace UnityEditor.Rendering rowRect.xMin += 2; rowRect.xMax -= 2; - EditorGUI.LabelField(rowRect, GUIContent.none, EditorGUIUtility.TrTextContent(row.displayName), DebugWindow.Styles.centeredLeft); + + bool isAlternate = r % 2 == 0; + + EditorGUI.LabelField(rowRect, GUIContent.none, EditorGUIUtility.TrTextContent(row.displayName),isAlternate ? DebugWindow.Styles.centeredLeft : DebugWindow.Styles.centeredLeftAlternate); rowRect.xMin -= 2; rowRect.xMax += 2; @@ -841,7 +844,7 @@ namespace UnityEditor.Rendering rowRect.x += rowRect.width; rowRect.width = columns[visible[c]].width; if (!row.isHidden) - DisplayChild(rowRect, row.children[visible[c] - 1]); + DisplayChild(rowRect, row.children[visible[c] - 1], isAlternate); } rowRect.y += rowRect.height; } @@ -884,7 +887,7 @@ namespace UnityEditor.Rendering return new Rect(rect.x + size, rect.y + size, rect.width - 2 * size, rect.height - 2 * size); } - internal void DisplayChild(Rect rect, DebugUI.Widget child) + internal void DisplayChild(Rect rect, DebugUI.Widget child, bool isAlternate) { rect.xMin += 2; rect.xMax -= 2; @@ -898,7 +901,7 @@ namespace UnityEditor.Rendering if (child.GetType() == typeof(DebugUI.Value)) { var widget = Cast(child); - EditorGUI.LabelField(rect, GUIContent.none, EditorGUIUtility.TrTextContent(widget.GetValue().ToString())); + EditorGUI.LabelField(rect, GUIContent.none, EditorGUIUtility.TrTextContent(widget.GetValue().ToString()), isAlternate ? DebugWindow.Styles.centeredLeft : DebugWindow.Styles.centeredLeftAlternate); } else if (child.GetType() == typeof(DebugUI.ColorField)) { diff --git a/Packages/com.unity.render-pipelines.core/Editor/Debugging/DebugWindow.cs b/Packages/com.unity.render-pipelines.core/Editor/Debugging/DebugWindow.cs index 4de92d66..1ca095c6 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Debugging/DebugWindow.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Debugging/DebugWindow.cs @@ -12,8 +12,6 @@ using UnityEngine; using UnityEngine.Assertions; using UnityEngine.Rendering; -using PackageInfo = UnityEditor.PackageManager.PackageInfo; - namespace UnityEditor.Rendering { #pragma warning disable 414 @@ -45,7 +43,8 @@ namespace UnityEditor.Rendering hideFlags = HideFlags.HideAndDontSave; } } - + + [CoreRPHelpURL("Rendering-Debugger")] sealed class DebugWindow : EditorWindowWithHelpButton, IHasCustomMenu { static Styles s_Styles; @@ -77,37 +76,6 @@ namespace UnityEditor.Rendering private set => DebugManager.instance.displayEditorUI = value; } - protected override void OnHelpButtonClicked() - { - //Deduce documentation url and open it in browser - var url = GetSpecificURL() ?? GetDefaultURL(); - Application.OpenURL(url); - } - - string GetDefaultURL() - { - //Find package info of the current CoreRP package - return $"https://docs.unity3d.com/Packages/com.unity.render-pipelines.core@{DocumentationInfo.version}/manual/Rendering-Debugger.html"; - } - - string GetSpecificURL() - { - //Find package info of the current RenderPipeline - var currentPipeline = GraphicsSettings.currentRenderPipeline; - if (currentPipeline == null) - return null; - - if (!DocumentationUtils.TryGetPackageInfoForType(currentPipeline.GetType(), out var packageName, out var version)) - return null; - - return packageName switch - { - "com.unity.render-pipelines.universal" => $"https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@{version}/manual/features/rendering-debugger.html", - "com.unity.render-pipelines.high-definition" => $"https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@{version}/manual/Render-Pipeline-Debug-Window.html", - _ => null - }; - } - [DidReloadScripts] static void OnEditorReload() { @@ -509,10 +477,23 @@ namespace UnityEditor.Rendering { using (new EditorGUILayout.VerticalScope()) { - const float leftMargin = 4f; - GUILayout.Space(leftMargin); var selectedPanel = panels[m_Settings.selectedPanel]; + + using (new EditorGUILayout.HorizontalScope()) + { + var style = new GUIStyle(CoreEditorStyles.sectionHeaderStyle) { fontStyle = FontStyle.Bold }; + EditorGUILayout.LabelField(new GUIContent(selectedPanel.displayName), style); + + // Context menu + var rect = GUILayoutUtility.GetLastRect(); + var contextMenuRect = new Rect(rect.xMax, rect.y + 4f, 16f, 16f); + + CoreEditorUtils.ShowHelpButton(contextMenuRect, selectedPanel.documentationUrl, new GUIContent($"{selectedPanel.displayName} panel.")); + } + const float leftMargin = 4f; + GUILayout.Space(leftMargin); + using (var scrollScope = new EditorGUILayout.ScrollViewScope(m_ContentScroll)) { TraverseContainerGUI(selectedPanel); @@ -626,6 +607,7 @@ namespace UnityEditor.Rendering public readonly Color skinBackgroundColor; public static GUIStyle centeredLeft = new GUIStyle(EditorStyles.label) { alignment = TextAnchor.MiddleLeft }; + public static GUIStyle centeredLeftAlternate = new GUIStyle(EditorStyles.label) { alignment = TextAnchor.MiddleLeft }; public static float singleRowHeight = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; public static int foldoutColumnWidth = 70; @@ -637,6 +619,12 @@ namespace UnityEditor.Rendering Color backgroundColorDarkSkin = new Color32(38, 38, 38, 128); Color backgroundColorLightSkin = new Color32(128, 128, 128, 96); + centeredLeftAlternate.normal.background = CoreEditorUtils.CreateColoredTexture2D( + EditorGUIUtility.isProSkin + ? new Color(63 / 255.0f, 63 / 255.0f, 63 / 255.0f, 255 / 255.0f) + : new Color(202 / 255.0f, 202 / 255.0f, 202 / 255.0f, 255 / 255.0f), + "centeredLeftAlternate Background"); + sectionScrollView = new GUIStyle(sectionScrollView); sectionScrollView.overflow.bottom += 1; @@ -650,6 +638,15 @@ namespace UnityEditor.Rendering skinBackgroundColor = EditorGUIUtility.isProSkin ? backgroundColorDarkSkin : backgroundColorLightSkin; labelWithZeroValueStyle.normal.textColor = Color.gray; + + // Make sure that textures are unloaded on domain reloads. + void OnBeforeAssemblyReload() + { + UnityEngine.Object.DestroyImmediate(centeredLeftAlternate.normal.background); + AssemblyReloadEvents.beforeAssemblyReload -= OnBeforeAssemblyReload; + } + + AssemblyReloadEvents.beforeAssemblyReload += OnBeforeAssemblyReload; } } diff --git a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.LightTransport.cs b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.LightTransport.cs index a0be9e1a..67d6182f 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.LightTransport.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.LightTransport.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Runtime.CompilerServices; using Unity.Collections; using UnityEditor; @@ -8,7 +9,7 @@ using UnityEngine.LightTransport; using UnityEngine.LightTransport.PostProcessing; using UnityEngine.Rendering.Sampling; using UnityEngine.Rendering.UnifiedRayTracing; - +using UnityEngine.SceneManagement; using TouchupVolumeWithBoundsList = System.Collections.Generic.List<(UnityEngine.Rendering.ProbeReferenceVolume.Volume obb, UnityEngine.Bounds aabb, UnityEngine.Rendering.ProbeAdjustmentVolume volume)>; namespace UnityEngine.Rendering @@ -584,13 +585,16 @@ namespace UnityEngine.Rendering } } + // The contribution from all Baked and Mixed lights in the scene should be disabled to avoid double contribution. static void UpdateLightStatus() { var lightingSettings = ProbeVolumeLightingTab.GetLightingSettings(); - // The contribution from all Baked and Mixed lights in the scene should be disabled to avoid double contribution. - var lights = Object.FindObjectsByType(FindObjectsSortMode.None); - foreach (var light in lights) + var sceneLights = new Dictionary>(); + + // Modify each baked light, take note of which scenes they belong to. + var allLights = Object.FindObjectsByType(FindObjectsSortMode.None); + foreach (var light in allLights) { if (light.lightmapBakeType != LightmapBakeType.Realtime) { @@ -600,6 +604,56 @@ namespace UnityEngine.Rendering bakingOutput.mixedLightingMode = lightingSettings.mixedBakeMode; light.bakingOutput = bakingOutput; } + + // Take note of the lights from each scene + var scene = light.gameObject.scene; + if (!sceneLights.TryGetValue(scene, out var sceneLightList)) + { + sceneLightList = new List(); + sceneLights.Add(scene, sceneLightList); + } + sceneLightList.Add(light); + } + + // Now we make the modifications persistent by modifying Lighting Data Assets (LDA) on disk. + string ldaFolderPath = Path.GetDirectoryName(AssetDatabase.GetAssetPath(m_BakingSet)); + for (int i = 0; i < m_BakingSet.sceneGUIDs.Count; i++) + { + string guid = m_BakingSet.sceneGUIDs[i]; + Scene scene = SceneManager.GetSceneByPath(AssetDatabase.GUIDToAssetPath(guid)); + if (!scene.isLoaded) + continue; + + LightingDataAsset prevLDA = Lightmapping.GetLightingDataAssetForScene(scene); + LightingDataAsset newLDA = prevLDA; + + // If the scene has no (modifiable) LDA, create a new one. + bool isDefaultLDA = prevLDA && prevLDA.hideFlags.HasFlag(HideFlags.NotEditable); + if (prevLDA == null || isDefaultLDA) + { + newLDA = new LightingDataAsset(scene); + } + + // Update the LDA with the new light settings + if (sceneLights.TryGetValue(scene, out var lights)) + newLDA.SetLights(lights.ToArray()); + else + newLDA.SetLights(Array.Empty()); + + // If the scene was using the builtin/default LDA before, copy over environment lighting, so it doesn't change. + if (prevLDA != null) + { + newLDA.SetAmbientProbe(prevLDA.GetAmbientProbe()); + newLDA.SetDefaultReflectionCubemap(prevLDA.GetDefaultReflectionCubemap()); + } + + // Save the LDA to disk and assign it to the scene. + if (newLDA != prevLDA) + { + string ldaPath = $"{ldaFolderPath}/LightingData-{i}.asset".Replace('\\', '/'); + AssetDatabase.CreateAsset(newLDA, ldaPath); + Lightmapping.SetLightingDataAssetForScene(scene, newLDA); + } } } diff --git a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.Serialization.cs b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.Serialization.cs index d0dadf25..12733d3c 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.Serialization.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.Serialization.cs @@ -1031,7 +1031,7 @@ namespace UnityEngine.Rendering AssetDatabase.SaveAssets(); // Explicitly make sure the binary output files are writable since we write them using the C# file API (i.e. check out Perforce files if applicable) - var outputPaths = new List(new[] { cellDataFilename, cellBricksDataFilename, cellSharedDataFilename, cellSupportDataFilename, cellOptionalDataFilename }); + var outputPaths = new List(new[] { cellDataFilename, cellBricksDataFilename, cellSharedDataFilename, cellSupportDataFilename, cellOptionalDataFilename, cellProbeOcclusionDataFilename }); if (!AssetDatabase.MakeEditable(outputPaths.ToArray())) Debug.LogWarning($"Failed to make one or more probe volume output file(s) writable. This could result in baked data not being properly written to disk. {string.Join(",", outputPaths)}"); @@ -1046,9 +1046,13 @@ namespace UnityEngine.Rendering { WriteNativeArray(fs, probesL2); } - using (var fs = new System.IO.FileStream(cellProbeOcclusionDataFilename, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite)) + if (probeOcclusion.Length > 0) { - WriteNativeArray(fs, probeOcclusion); + // Write the probe occlusion data file, only if this data was baked (shadowmask mode) - UUM-85411 + using (var fs = new System.IO.FileStream(cellProbeOcclusionDataFilename, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite)) + { + WriteNativeArray(fs, probeOcclusion); + } } using (var fs = new System.IO.FileStream(cellSharedDataFilename, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite)) { diff --git a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.cs b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.cs index e54acb2b..922c77f8 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.cs @@ -1234,7 +1234,7 @@ namespace UnityEngine.Rendering // the dilation process consits in doing a trilinear sample of the higher subdivision brick and override the lower subdiv with that // We have to mark the probes on the boundary as valid otherwise leak reduction at runtime will interfere with this method - + // Use an indirection structure to ensure mem usage stays reasonable VoxelToBrickCache cache = new VoxelToBrickCache(); diff --git a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeEditor.cs b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeEditor.cs index 20de07ed..dffbc3e3 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeEditor.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeEditor.cs @@ -123,7 +123,7 @@ namespace UnityEditor.Rendering var k_EnsureFrameSetting = Type.GetType("UnityEditor.Rendering.HighDefinition.HDEditorUtils,Unity.RenderPipelines.HighDefinition.Editor") .GetMethod("EnsureFrameSetting", BindingFlags.Static | BindingFlags.NonPublic); - k_EnsureFrameSetting.Invoke(null, new object[] { k_APVFrameSetting, "Adaptive Probe Volumes" }); + k_EnsureFrameSetting.Invoke(null, new object[] { k_APVFrameSetting}); } } diff --git a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeLightingTab.cs b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeLightingTab.cs index 6da03237..8aaa605c 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeLightingTab.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeLightingTab.cs @@ -2,6 +2,7 @@ using System; using System.Linq; using System.Reflection; using System.Collections.Generic; +using System.IO; using UnityEditor; using UnityEditor.Rendering; using UnityEditor.SceneManagement; @@ -510,7 +511,9 @@ namespace UnityEngine.Rendering string path = string.IsNullOrEmpty(scene.path) ? ProbeVolumeBakingSet.GetDirectory("Assets/", "Untitled") : ProbeVolumeBakingSet.GetDirectory(scene.path, scene.name); - path = System.IO.Path.Combine(path, activeSet.name + ".asset"); + if (!Directory.Exists(path)) + Directory.CreateDirectory(path); + path = Path.Combine(path, activeSet.name + ".asset"); path = AssetDatabase.GenerateUniqueAssetPath(path); AssetDatabase.CreateAsset(activeSet, path); @@ -1012,7 +1015,7 @@ namespace UnityEngine.Rendering if (AdaptiveProbeVolumes.partialBakeSceneList.Count == activeSet.sceneGUIDs.Count) AdaptiveProbeVolumes.partialBakeSceneList = null; - if (ProbeReferenceVolume.instance.supportLightingScenarios && !activeSet.m_LightingScenarios.Contains(activeSet.lightingScenario)) + if (ProbeReferenceVolume.instance.supportLightingScenarios && !activeSet.m_LightingScenarios.Contains(activeSet.lightingScenario) && activeSet.m_LightingScenarios.Count > 0) activeSet.SetActiveScenario(activeSet.m_LightingScenarios[0], false); // Layout has changed and is incompatible. diff --git a/Packages/com.unity.render-pipelines.core/Editor/LookDev/EnvironmentLibrary.cs b/Packages/com.unity.render-pipelines.core/Editor/LookDev/EnvironmentLibrary.cs index 3ab31ee7..830560fc 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/LookDev/EnvironmentLibrary.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/LookDev/EnvironmentLibrary.cs @@ -12,7 +12,7 @@ namespace UnityEditor.Rendering.LookDev /// /// Class containing a collection of Environment /// - [CoreRPHelpURL("Environment-Library")] + [CoreRPHelpURL("Look-Dev-Environment-Library")] public class EnvironmentLibrary : ScriptableObject { [field: SerializeField] diff --git a/Packages/com.unity.render-pipelines.core/Editor/RenderGraph/RenderGraphViewer.cs b/Packages/com.unity.render-pipelines.core/Editor/RenderGraph/RenderGraphViewer.cs index 75bbb04a..d6a78d50 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/RenderGraph/RenderGraphViewer.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/RenderGraph/RenderGraphViewer.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using UnityEditor.Rendering.Analytics; using UnityEditor.UIElements; using UnityEngine; +using UnityEngine.Rendering; using UnityEngine.Rendering.RenderGraphModule; using UnityEngine.Scripting.APIUpdating; using UnityEngine.UIElements; @@ -13,7 +14,8 @@ namespace UnityEditor.Rendering /// Editor window class for the Render Graph Viewer /// [MovedFrom("")] - public partial class RenderGraphViewer : EditorWindow + [CoreRPHelpURL(packageName: "com.unity.render-pipelines.universal", pageName: "render-graph-view")] + public partial class RenderGraphViewer : EditorWindowWithHelpButton { static partial class Names { diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugDisplaySettingsUI.cs b/Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugDisplaySettingsUI.cs index 0d6769de..2dbc44e2 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugDisplaySettingsUI.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugDisplaySettingsUI.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Reflection; using UnityEngine.Rendering.RenderGraphModule; namespace UnityEngine.Rendering @@ -51,6 +52,9 @@ namespace UnityEngine.Rendering displayName: disposableSettingsPanel.PanelName, createIfNull: true, groupIndex: (disposableSettingsPanel is DebugDisplaySettingsPanel debugDisplaySettingsPanel) ? debugDisplaySettingsPanel.Order : 0); +#if UNITY_EDITOR + panel.documentationUrl = disposableSettingsPanel.GetType().GetCustomAttribute()?.URL; +#endif ObservableList panelChildren = panel.children; diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugDisplaySettingsVolumes.cs b/Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugDisplaySettingsVolumes.cs index eb34eeaf..f7f88572 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugDisplaySettingsVolumes.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugDisplaySettingsVolumes.cs @@ -39,16 +39,19 @@ namespace UnityEngine.Rendering public static readonly string camera = "Camera"; public static readonly string parameter = "Parameter"; public static readonly string component = "Component"; - public static readonly string debugViewNotSupported = "Debug view not supported"; + public static readonly string debugViewNotSupported = "N/A"; + public static readonly string parameterNotOverrided = "-"; public static readonly string volumeInfo = "Volume Info"; + public static readonly string gameObject = "GameObject"; public static readonly string resultValue = "Result"; public static readonly string resultValueTooltip = "The interpolated result value of the parameter. This value is used to render the camera."; - public static readonly string globalDefaultValue = "Default"; + public static readonly string globalDefaultValue = "Graphics Settings"; public static readonly string globalDefaultValueTooltip = "Default value for this parameter, defined by the Default Volume Profile in Global Settings."; - public static readonly string qualityLevelValue = "SRP Asset"; + public static readonly string qualityLevelValue = "Quality Settings"; public static readonly string qualityLevelValueTooltip = "Override value for this parameter, defined by the Volume Profile in the current SRP Asset."; public static readonly string global = "Global"; public static readonly string local = "Local"; + public static readonly string volumeProfile = "Volume Profile"; } const string k_PanelTitle = "Volume"; @@ -107,40 +110,26 @@ namespace UnityEngine.Rendering }; } - static DebugUI.Widget CreateVolumeParameterWidget(string name, VolumeParameter param, Func isHiddenCallback = null) + static DebugUI.Widget CreateVolumeParameterWidget(string name, bool isResultParameter, VolumeParameter param, Func isHiddenCallback = null) { - if (param == null) - return new DebugUI.Value() { displayName = name, getter = () => "-" }; - - var parameterType = param.GetType(); - - // Special overrides - if (parameterType == typeof(ColorParameter)) +#if UNITY_EDITOR || DEVELOPMENT_BUILD + if (param != null) { - var p = (ColorParameter)param; - return new DebugUI.ColorField() + var parameterType = param.GetType(); + if (parameterType == typeof(ColorParameter)) { - displayName = name, - hdr = p.hdr, - showAlpha = p.showAlpha, - getter = () => p.value, - setter = value => p.value = value, - isHiddenCallback = isHiddenCallback - }; - } - else if (parameterType == typeof(BoolParameter)) - { - var p = (BoolParameter)param; - return new DebugUI.BoolField() - { - displayName = name, - getter = () => p.value, - setter = value => p.value = value, - isHiddenCallback = isHiddenCallback - }; - } - else - { + var p = (ColorParameter)param; + return new DebugUI.ColorField() + { + displayName = name, + hdr = p.hdr, + showAlpha = p.showAlpha, + getter = () => p.value, + setter = value => p.value = value, + isHiddenCallback = isHiddenCallback + }; + } + var typeInfo = parameterType.GetTypeInfo(); var genericArguments = typeInfo.BaseType.GenericTypeArguments; if (genericArguments.Length > 0 && genericArguments[0].IsArray) @@ -152,247 +141,201 @@ namespace UnityEngine.Rendering type = parameterType }; } - } - // For parameters that do not override `ToString` - var property = param.GetType().GetProperty("value"); - var toString = property.PropertyType.GetMethod("ToString", Type.EmptyTypes); - if ((toString == null) || (toString.DeclaringType == typeof(object)) || (toString.DeclaringType == typeof(UnityEngine.Object))) - { - // Check if the parameter has a name - var nameProp = property.PropertyType.GetProperty("name"); - if (nameProp == null) - return new DebugUI.Value() { displayName = name, getter = () => Strings.debugViewNotSupported }; - - // Return the parameter name return new DebugUI.Value() { displayName = name, getter = () => { - var value = property.GetValue(param); - if (value == null || value.Equals(null)) - return Strings.none; - var valueString = nameProp.GetValue(value); - return valueString ?? Strings.none; + var property = param.GetType().GetProperty("value"); + if (property == null) + return "-"; + + if (isResultParameter || param.overrideState) + { + var value = property.GetValue(param); + var propertyType = property.PropertyType; + if (value == null || value.Equals(null)) + return Strings.none + $" ({propertyType.Name})"; + + var toString = propertyType.GetMethod("ToString", Type.EmptyTypes); + if ((toString == null) || (toString.DeclaringType == typeof(object)) || (toString.DeclaringType == typeof(UnityEngine.Object))) + { + // Check if the parameter has a name + var nameProp = property.PropertyType.GetProperty("name"); + if (nameProp == null) + return Strings.debugViewNotSupported; + + var valueString = nameProp.GetValue(value); + return valueString ?? Strings.none; + } + + return value.ToString(); + } + + return Strings.parameterNotOverrided; }, isHiddenCallback = isHiddenCallback }; } - - // Call the ToString method - return new DebugUI.Value() - { - displayName = name, - getter = () => - { - var value = property.GetValue(param); - return value == null ? Strings.none : value.ToString(); - }, - isHiddenCallback = isHiddenCallback - }; + #endif + return new DebugUI.Value(); } static DebugUI.Value s_EmptyDebugUIValue = new DebugUI.Value { getter = () => string.Empty }; - public static DebugUI.Table CreateVolumeTable(DebugDisplaySettingsVolume data) + struct VolumeParameterChain { - var table = new DebugUI.Table() + public DebugUI.Widget.NameAndTooltip nameAndTooltip; + public VolumeProfile volumeProfile; + public VolumeComponent volumeComponent; + public Volume volume; + } + + static VolumeComponent GetSelectedVolumeComponent(VolumeProfile profile, Type selectedType) + { + if (profile != null) { - displayName = Strings.parameter, - isReadOnly = true, - isHiddenCallback = () => data.volumeDebugSettings.selectedComponent == 0 - }; + foreach (var component in profile.components) + if (component.GetType() == selectedType) + return component; + } + return null; + } + + static List GetResolutionChain(DebugDisplaySettingsVolume data) + { + List chain = new List(); Type selectedType = data.volumeDebugSettings.selectedComponentType; if (selectedType == null) - return table; + return chain; var volumeManager = VolumeManager.instance; var stack = data.volumeDebugSettings.selectedCameraVolumeStack ?? volumeManager.stack; var stackComponent = stack.GetComponent(selectedType); if (stackComponent == null) - return table; - - var volumes = data.volumeDebugSettings.GetVolumes(); + return chain; - // First row for volume info - var row1 = new DebugUI.Table.Row() + var result = new VolumeParameterChain() { - displayName = Strings.volumeInfo, - opened = true, // Open by default for the in-game view - children = + nameAndTooltip = new DebugUI.Widget.NameAndTooltip() { - new DebugUI.Value() - { - displayName = Strings.resultValue, - tooltip = Strings.resultValueTooltip, - getter = () => string.Empty - } - } - }; - - // Second row, links to volume gameobjects - var row2 = new DebugUI.Table.Row() - { - displayName = "GameObject", - children = { s_EmptyDebugUIValue } - }; - - // Third row, links to volume profile assets - var row3 = new DebugUI.Table.Row() - { - displayName = "Volume Profile", - children = { s_EmptyDebugUIValue } + name = Strings.resultValue, + tooltip = Strings.resultValueTooltip, + }, + volumeComponent = stackComponent, }; - // Fourth row, empty (to separate from actual data) - var row4 = new DebugUI.Table.Row() - { - displayName = string.Empty , - children = { s_EmptyDebugUIValue } - }; + chain.Add(result); + // Add volume components that override default values + var volumes = data.volumeDebugSettings.GetVolumes(); foreach (var volume in volumes) { var profile = volume.HasInstantiatedProfile() ? volume.profile : volume.sharedProfile; - row1.children.Add(new DebugUI.Value() + var overrideComponent = GetSelectedVolumeComponent(profile, selectedType); + if (overrideComponent != null) { - displayName = profile.name, - tooltip = $"Override value for this parameter, defined by {profile.name}", - getter = () => + var overrideVolume = new VolumeParameterChain() { - var scope = volume.isGlobal ? Strings.global : Strings.local; - var weight = data.volumeDebugSettings.GetVolumeWeight(volume); - return scope + " (" + (weight * 100f) + "%)"; - } - }); - row2.children.Add(new DebugUI.ObjectField() { displayName = string.Empty, getter = () => volume }); - row3.children.Add(new DebugUI.ObjectField() { displayName = string.Empty, getter = () => profile }); - row4.children.Add(s_EmptyDebugUIValue); + nameAndTooltip = new DebugUI.Widget.NameAndTooltip() + { + name = profile.name, + tooltip = profile.name, + }, + volumeProfile = profile, + volumeComponent = overrideComponent, + volume = volume + }; + chain.Add(overrideVolume); + } } - // Default value profiles - var globalDefaultComponent = GetSelectedVolumeComponent(volumeManager.globalDefaultProfile); - var qualityDefaultComponent = GetSelectedVolumeComponent(volumeManager.qualityDefaultProfile); - List<(VolumeProfile, VolumeComponent)> customDefaultComponents = new(); + // Add custom default profiles if (volumeManager.customDefaultProfiles != null) { foreach (var customProfile in volumeManager.customDefaultProfiles) { - var customDefaultComponent = GetSelectedVolumeComponent(customProfile); - if (customDefaultComponent != null) - customDefaultComponents.Add((customProfile, customDefaultComponent)); + var customProfileComponent = GetSelectedVolumeComponent(customProfile, selectedType); + if (customProfileComponent != null) + { + var overrideVolume = new VolumeParameterChain() + { + nameAndTooltip = new DebugUI.Widget.NameAndTooltip() + { + name = customProfile.name, + tooltip = customProfile.name, + }, + volumeProfile = customProfile, + volumeComponent = customProfileComponent, + }; + chain.Add(overrideVolume); + } } } - foreach (var (customProfile, _) in customDefaultComponents) - { - row1.children.Add(new DebugUI.Value() { displayName = customProfile.name, getter = () => string.Empty }); - row2.children.Add(s_EmptyDebugUIValue); - row3.children.Add(new DebugUI.ObjectField() { displayName = string.Empty, getter = () => customProfile }); - row4.children.Add(s_EmptyDebugUIValue); - } - - row1.children.Add(new DebugUI.Value() { displayName = Strings.qualityLevelValue, tooltip = Strings.qualityLevelValueTooltip, getter = () => string.Empty }); - row2.children.Add(s_EmptyDebugUIValue); - row3.children.Add(new DebugUI.ObjectField() { displayName = string.Empty, getter = () => volumeManager.qualityDefaultProfile }); - row4.children.Add(s_EmptyDebugUIValue); - - row1.children.Add(new DebugUI.Value() { displayName = Strings.globalDefaultValue, tooltip = Strings.globalDefaultValueTooltip, getter = () => string.Empty }); - row2.children.Add(s_EmptyDebugUIValue); - row3.children.Add(new DebugUI.ObjectField() { displayName = string.Empty, getter = () => volumeManager.globalDefaultProfile }); - row4.children.Add(s_EmptyDebugUIValue); - - table.children.Add(row1); - table.children.Add(row2); - table.children.Add(row3); - table.children.Add(row4); - - VolumeComponent GetSelectedVolumeComponent(VolumeProfile profile) + // Add Quality Settings + if (volumeManager.globalDefaultProfile != null) { - if (profile != null) + var qualitySettingsComponent = GetSelectedVolumeComponent(volumeManager.qualityDefaultProfile, selectedType); + if (qualitySettingsComponent != null) { - foreach (var component in profile.components) - if (component.GetType() == selectedType) - return component; + var overrideVolume = new VolumeParameterChain() + { + nameAndTooltip = new DebugUI.Widget.NameAndTooltip() + { + name = Strings.qualityLevelValue, + tooltip = Strings.qualityLevelValueTooltip, + }, + volumeProfile = volumeManager.qualityDefaultProfile, + volumeComponent = qualitySettingsComponent, + }; + chain.Add(overrideVolume); } - return null; } - // Build rows - recursively handles nested parameters - var rows = new List(); - int AddParameterRows(Type type, string baseName = null, int skip = 0) + // Add Graphics Settings + if (volumeManager.globalDefaultProfile != null) { - void AddRow(FieldInfo f, string prefix, int skip) + var graphicsSettingsComponent = GetSelectedVolumeComponent(volumeManager.globalDefaultProfile, selectedType); + if (graphicsSettingsComponent != null) { - var fieldName = prefix + f.Name; - var attr = (DisplayInfoAttribute[])f.GetCustomAttributes(typeof(DisplayInfoAttribute), true); - if (attr.Length != 0) - fieldName = prefix + attr[0].name; -#if UNITY_EDITOR - // Would be nice to have the equivalent for the runtime debug. - else - fieldName = UnityEditor.ObjectNames.NicifyVariableName(fieldName); -#endif - - int currentParam = rows.Count + skip; - DebugUI.Table.Row row = new DebugUI.Table.Row() + var overrideVolume = new VolumeParameterChain() { - displayName = fieldName, - children = { CreateVolumeParameterWidget(Strings.resultValue, stackComponent.parameterList[currentParam]) }, + nameAndTooltip = new DebugUI.Widget.NameAndTooltip() + { + name = Strings.globalDefaultValue, + tooltip = Strings.globalDefaultValueTooltip, + }, + volumeProfile = volumeManager.globalDefaultProfile, + volumeComponent = graphicsSettingsComponent, }; - - foreach (var volume in volumes) - { - VolumeParameter param = null; - var profile = volume.HasInstantiatedProfile() ? volume.profile : volume.sharedProfile; - if (profile.TryGet(selectedType, out VolumeComponent component)) - param = component.parameterList[currentParam]; - row.children.Add(CreateVolumeParameterWidget(volume.name + " (" + profile.name + ")", param, () => !component.parameterList[currentParam].overrideState)); - } - - foreach (var (customProfile, customComponent) in customDefaultComponents) - row.children.Add(CreateVolumeParameterWidget(customProfile.name, - customComponent != null ? customComponent.parameterList[currentParam] : null)); - - row.children.Add(CreateVolumeParameterWidget(Strings.qualityLevelValue, - qualityDefaultComponent != null ? qualityDefaultComponent.parameterList[currentParam] : null)); - - row.children.Add(CreateVolumeParameterWidget(Strings.globalDefaultValue, - globalDefaultComponent != null ? globalDefaultComponent.parameterList[currentParam] : null)); - - rows.Add(row); - } - - var fields = type - .GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) - .OrderBy(t => t.MetadataToken); - foreach (var field in fields) - { - if (field.GetCustomAttributes(typeof(ObsoleteAttribute), false).Length != 0) - { - skip++; - continue; - } - var fieldType = field.FieldType; - if (fieldType.IsSubclassOf(typeof(VolumeParameter))) - AddRow(field, baseName ?? string.Empty, skip); - else if (!fieldType.IsArray && fieldType.IsClass) - skip += AddParameterRows(fieldType, baseName ?? (field.Name + " "), skip); + chain.Add(overrideVolume); } - return skip; } - AddParameterRows(selectedType); - foreach (var r in rows.OrderBy(t => t.displayName)) - table.children.Add(r); + return chain; + } + + public static DebugUI.Table CreateVolumeTable(DebugDisplaySettingsVolume data) + { + var table = new DebugUI.Table() + { + displayName = Strings.parameter, + isReadOnly = true, + isHiddenCallback = () => data.volumeDebugSettings.selectedComponent == 0 + }; + + var resolutionChain = GetResolutionChain(data); + if (resolutionChain.Count == 0) + return table; - data.volumeDebugSettings.RefreshVolumes(volumes); - for (int i = 0; i < volumes.Length; i++) - table.SetColumnVisibility(i + 1, data.volumeDebugSettings.VolumeHasInfluence(volumes[i])); + GenerateTableRows(table, resolutionChain); + GenerateTableColumns(table, data, resolutionChain); float timer = 0.0f, refreshRate = 0.2f; + var volumes = data.volumeDebugSettings.GetVolumes(); table.isHiddenCallback = () => { timer += Time.deltaTime; @@ -400,16 +343,9 @@ namespace UnityEngine.Rendering { if (data.volumeDebugSettings.selectedCamera != null) { - var newVolumes = data.volumeDebugSettings.GetVolumes(); - if (!data.volumeDebugSettings.RefreshVolumes(newVolumes)) - { - for (int i = 0; i < newVolumes.Length; i++) - { - var visible = data.volumeDebugSettings.VolumeHasInfluence(newVolumes[i]); - table.SetColumnVisibility(i + 1, visible); - } - } + SetTableColumnVisibility(data, table); + var newVolumes = data.volumeDebugSettings.GetVolumes(); if (!volumes.SequenceEqual(newVolumes)) { volumes = newVolumes; @@ -424,6 +360,139 @@ namespace UnityEngine.Rendering return table; } + + private static void SetTableColumnVisibility(DebugDisplaySettingsVolume data, DebugUI.Table table) + { + var newResolutionChain = GetResolutionChain(data); + for (int i = 1; i < newResolutionChain.Count; i++) // We always skip the interpolated stack that is in index 0 + { + bool visible = true; + if (newResolutionChain[i].volume != null) + { + visible = data.volumeDebugSettings.VolumeHasInfluence(newResolutionChain[i].volume); + } + else + { + visible = newResolutionChain[i].volumeComponent.active; + + if (visible) + { + bool atLeastOneParameterIsOverriden = false; + foreach (var parameter in newResolutionChain[i].volumeComponent.parameterList) + { + if (parameter.overrideState == true) + { + atLeastOneParameterIsOverriden = true; + break; + } + } + + visible &= atLeastOneParameterIsOverriden; + } + } + + table.SetColumnVisibility(i, visible); + } + } + + private static void GenerateTableColumns(DebugUI.Table table, DebugDisplaySettingsVolume data, List resolutionChain) + { + for (int i = 0; i < resolutionChain.Count; ++i) + { + var chain = resolutionChain[i]; + int iRowIndex = -1; + + if (chain.volume != null) + { + ((DebugUI.Table.Row)table.children[++iRowIndex]).children.Add(new DebugUI.Value() + { + nameAndTooltip = chain.nameAndTooltip, + getter = () => + { + var scope = chain.volume.isGlobal ? Strings.global : Strings.local; + var weight = data.volumeDebugSettings.GetVolumeWeight(chain.volume); + return scope + " (" + (weight * 100f) + "%)"; + }, + refreshRate = 0.2f + }); + ((DebugUI.Table.Row)table.children[++iRowIndex]).children.Add(new DebugUI.ObjectField() { displayName = string.Empty, getter = () => chain.volume }); + } + else + { + ((DebugUI.Table.Row)table.children[++iRowIndex]).children.Add(new DebugUI.Value() + { + nameAndTooltip = chain.nameAndTooltip, + getter = () => string.Empty + }); + ((DebugUI.Table.Row)table.children[++iRowIndex]).children.Add(s_EmptyDebugUIValue); + } + + ((DebugUI.Table.Row)table.children[++iRowIndex]).children.Add(chain.volumeProfile != null ? new DebugUI.ObjectField() { displayName = string.Empty, getter = () => chain.volumeProfile } : + s_EmptyDebugUIValue); + + ((DebugUI.Table.Row)table.children[++iRowIndex]).children.Add(s_EmptyDebugUIValue); + + bool isResultParameter = i == 0; + for (int j = 0; j < chain.volumeComponent.parameterList.Count; ++j) + { + var parameter = chain.volumeComponent.parameterList[j]; + ((DebugUI.Table.Row)table.children[++iRowIndex]).children.Add(CreateVolumeParameterWidget(chain.nameAndTooltip.name, isResultParameter, parameter)); + } + } + } + + private static void GenerateTableRows(DebugUI.Table table, List resolutionChain) + { + // First row for volume info + var volumeInfoRow = new DebugUI.Table.Row() + { + displayName = Strings.volumeInfo, + opened = true, // Open by default for the in-game view + }; + + table.children.Add(volumeInfoRow); + + // Second row, links to volume gameobjects + var gameObjectRow = new DebugUI.Table.Row() + { + displayName = Strings.gameObject, + }; + + table.children.Add(gameObjectRow); + + // Third row, links to volume profile assets + var volumeProfileRow = new DebugUI.Table.Row() + { + displayName = Strings.volumeProfile, + }; + table.children.Add(volumeProfileRow); + + var separatorRow = new DebugUI.Table.Row() + { + displayName = string.Empty , + }; + + table.children.Add(separatorRow); + + var results = resolutionChain[0].volumeComponent; + for (int i = 0; i < results.parameterList.Count; ++i) + { + var parameter = results.parameterList[i]; + +#if UNITY_EDITOR + string displayName = UnityEditor.ObjectNames.NicifyVariableName(parameter.debugId); // In the editor, make the name more readable +#elif DEVELOPMENT_BUILD + string displayName = parameter.debugId; // In the development player, just the debug id +#else + string displayName = i.ToString(); // Everywhere else, just a dummy id ( TODO: The Volume panel code should be stripped completely in nom-development builds ) +#endif + + table.children.Add(new DebugUI.Table.Row() + { + displayName = displayName + }); + } + } } [DisplayInfo(name = k_PanelTitle, order = int.MaxValue)] diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugUI.Panel.cs b/Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugUI.Panel.cs index 8d506f78..fb77b880 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugUI.Panel.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugUI.Panel.cs @@ -53,6 +53,10 @@ namespace UnityEngine.Rendering /// Callback used when the panel is set dirty. /// public event Action onSetDirty = delegate { }; + +#if UNITY_EDITOR + public string documentationUrl { get; set; } +#endif /// /// Constructor. diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Debugging/VolumeDebugSettings.cs b/Packages/com.unity.render-pipelines.core/Runtime/Debugging/VolumeDebugSettings.cs index ca423bff..d2310ebd 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Debugging/VolumeDebugSettings.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Debugging/VolumeDebugSettings.cs @@ -73,7 +73,10 @@ namespace UnityEngine.Rendering if (camera.cameraType != CameraType.Preview && camera.cameraType != CameraType.Reflection) { - if (camera.TryGetComponent(out T additionalData)) + if (!camera.TryGetComponent(out T additionalData)) + additionalData = camera.gameObject.AddComponent(); + + if (additionalData != null) m_Cameras.Add(camera); } } @@ -262,21 +265,9 @@ namespace UnityEngine.Rendering /// The weight of the volume public float GetVolumeWeight(Volume volume) { - if (weights == null) - return 0; - - float total = 0f, weight = 0f; - for (int i = 0; i < volumes.Length; i++) - { - weight = weights[i]; - weight *= 1f - total; - total += weight; - - if (volumes[i] == volume) - return weight; - } - - return 0f; + // TODO: Store the calculated weight in the stack for the volumes that have influence and return it here + var triggerPos = selectedCameraPosition; + return ComputeWeight(volume, triggerPos); } /// @@ -286,14 +277,9 @@ namespace UnityEngine.Rendering /// If the volume has influence public bool VolumeHasInfluence(Volume volume) { - if (weights == null) - return false; - - int index = Array.IndexOf(volumes, volume); - if (index == -1) - return false; - - return weights[index] != 0f; + // TODO: Store the calculated weight in the stack for the volumes that have influence and return it here + var triggerPos = selectedCameraPosition; + return ComputeWeight(volume, triggerPos) > 0.0f; } } } diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Documentation.cs b/Packages/com.unity.render-pipelines.core/Runtime/Documentation.cs index 7ddace17..242fbc31 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Documentation.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Documentation.cs @@ -46,7 +46,7 @@ namespace UnityEngine.Rendering } /// - /// Use this attribute to define the help URP. + /// Use this attribute to define documentation url for the current Render Pipeline. /// /// /// [CoreRPHelpURLAttribute("Volume")] @@ -57,14 +57,18 @@ namespace UnityEngine.Rendering public class CurrentPipelineHelpURLAttribute : HelpURLAttribute { private string pageName { get; } + + private string pageHash { get; } /// /// The constructor of the attribute /// /// The name of the documentation page. - public CurrentPipelineHelpURLAttribute(string pageName) + /// The name of the section on the documentation page. + public CurrentPipelineHelpURLAttribute(string pageName, string pageHash = "") : base(null) { this.pageName = pageName; + this.pageHash = pageHash; } /// @@ -77,7 +81,7 @@ namespace UnityEngine.Rendering #if UNITY_EDITOR if (DocumentationUtils.TryGetPackageInfoForType(GraphicsSettings.currentRenderPipeline?.GetType() ?? typeof(DocumentationInfo), out var package, out var version)) { - return DocumentationInfo.GetPackageLink(package, version, this.pageName); + return DocumentationInfo.GetPackageLink(package, version, pageName, pageHash); } #endif return string.Empty; @@ -92,7 +96,8 @@ namespace UnityEngine.Rendering public class DocumentationInfo { const string fallbackVersion = "13.1"; - const string url = "https://docs.unity3d.com/Packages/{0}@{1}/manual/{2}.html#{3}"; + const string packageDocumentationUrl = "https://docs.unity3d.com/Packages/{0}@{1}/manual/"; + const string url = packageDocumentationUrl + "{2}.html{3}"; /// /// Current version of the documentation. @@ -117,6 +122,21 @@ namespace UnityEngine.Rendering /// The page name without the extension. /// The full URL of the page. public static string GetPackageLink(string packageName, string packageVersion, string pageName) => string.Format(url, packageName, packageVersion, pageName, ""); + + /// + /// Generates a help URL for the given package, page name and section name. + /// + /// The package name. + /// The package version. + /// The page name without the extension. + /// The section name on the documentation page. + /// The full URL of the page. + public static string GetPackageLink(string packageName, string packageVersion, string pageName, string pageHash) + { + if (!string.IsNullOrEmpty(pageHash) && !pageHash.StartsWith("#")) + pageHash = $"#{pageHash}"; + return string.Format(url, packageName, packageVersion, pageName, pageHash); + } /// /// Generates a help url for the given package and page name @@ -133,7 +153,27 @@ namespace UnityEngine.Rendering /// The page name without the extension. /// The page hash /// The full URL of the page. - public static string GetPageLink(string packageName, string pageName, string pageHash) => string.Format(url, packageName, version, pageName, pageHash); + public static string GetPageLink(string packageName, string pageName, string pageHash) + { + if (!string.IsNullOrEmpty(pageHash) && !pageHash.StartsWith("#")) + pageHash = $"#{pageHash}"; + return string.Format(url, packageName, version, pageName, pageHash); + } + + /// + /// Generates a help url to the index page for the provided package name and package version. + /// + /// The name of the package. + /// The version of the package. + /// The full URL to the default package documentation page. + public static string GetDefaultPackageLink(string packageName, string packageVersion) => string.Format(packageDocumentationUrl, packageName, packageVersion); + + /// + /// Generates a help url to the index page for the provided package name and package version. + /// + /// The name of the package. + /// The full URL to the default package documentation page. + public static string GetDefaultPackageLink(string packageName) => string.Format(packageDocumentationUrl, packageName, version); } /// @@ -173,12 +213,12 @@ namespace UnityEngine.Rendering #if UNITY_EDITOR /// - /// Obtain package informations from a specific type + /// Obtains package information for a specified type. /// - /// The type used to retrieve package information - /// The name of the package containing the given type - /// The version number of the package containing the given type. Only Major.Minor will be returned as fix is not used for documentation - /// + /// The type used to retrieve package information. + /// The name of the package containing the given type. + /// The version number of the package containing the given type. Only Major.Minor will be returned as fix is not used for documentation. + /// Returns true if the package information is found; otherwise, false. public static bool TryGetPackageInfoForType([DisallowNull] Type type, [NotNullWhen(true)] out string packageName, [NotNullWhen(true)] out string version) { var packageInfo = PackageInfo.FindForAssembly(type.Assembly); @@ -193,6 +233,20 @@ namespace UnityEngine.Rendering version = packageInfo.version.Substring(0, packageInfo.version.LastIndexOf('.')); return true; } + + /// + /// Obtains a help URL to the index page for the package documentation of a specified type. + /// + /// The type used to retrieve package information. + /// The generated help URL to the package's index documentation page. + /// Returns true if a valid help URL is retrieved; otherwise, false. + public static bool TryGetDefaultHelpURL([DisallowNull] Type type, [NotNullWhen(true)] out string url) + { + url = string.Empty; + if (TryGetPackageInfoForType(type, out var packageName, out var version)) + url = DocumentationInfo.GetDefaultPackageLink(packageName, version); + return !string.IsNullOrEmpty(url); + } #endif } } diff --git a/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/Debug/DebugDisplayGPUResidentDrawer.cs b/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/Debug/DebugDisplayGPUResidentDrawer.cs index 9b090d2c..1df80681 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/Debug/DebugDisplayGPUResidentDrawer.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/Debug/DebugDisplayGPUResidentDrawer.cs @@ -225,6 +225,7 @@ namespace UnityEngine.Rendering [DisplayInfo(name = "GPU Resident Drawer", order = 5)] + [CurrentPipelineHelpURL("gpu-resident-drawer")] private class SettingsPanel : DebugDisplaySettingsPanel { public override string PanelName => "GPU Resident Drawer"; diff --git a/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/GPUResidentBatcher.cs b/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/GPUResidentBatcher.cs index 3e2a04a9..dfc25d40 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/GPUResidentBatcher.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/GPUResidentBatcher.cs @@ -13,7 +13,8 @@ namespace UnityEngine.Rendering { private RenderersBatchersContext m_BatchersContext; private GPUDrivenProcessor m_GPUDrivenProcessor; - private GPUDrivenRendererDataCallback m_UpdateRendererDataCallback; + private GPUDrivenRendererDataCallback m_UpdateRendererInstancesAndBatchesCallback; + private GPUDrivenRendererDataCallback m_UpdateRendererBatchesCallback; internal RenderersBatchersContext batchersContext { get => m_BatchersContext; } internal OcclusionCullingCommon occlusionCullingCommon { get => m_BatchersContext.occlusionCullingCommon; } @@ -28,7 +29,8 @@ namespace UnityEngine.Rendering { m_BatchersContext = batcherContext; m_GPUDrivenProcessor = gpuDrivenProcessor; - m_UpdateRendererDataCallback = UpdateRendererData; + m_UpdateRendererInstancesAndBatchesCallback = UpdateRendererInstancesAndBatches; + m_UpdateRendererBatchesCallback = UpdateRendererBatches; m_InstanceCullingBatcher = new InstanceCullingBatcher(batcherContext, instanceCullerBatcherDesc, OnFinishedCulling); } @@ -74,9 +76,9 @@ namespace UnityEngine.Rendering m_InstanceCullingBatcher.DestroyMaterials(destroyedMaterials); } - public void DestroyInstances(NativeArray instances) + public void DestroyDrawInstances(NativeArray instances) { - m_InstanceCullingBatcher.DestroyInstances(instances); + m_InstanceCullingBatcher.DestroyDrawInstances(instances); } public void DestroyMeshes(NativeArray destroyedMeshes) @@ -91,7 +93,7 @@ namespace UnityEngine.Rendering var instances = new NativeList(rendererGroupIDs.Length, Allocator.TempJob); m_BatchersContext.ScheduleQueryRendererGroupInstancesJob(rendererGroupIDs, instances).Complete(); - DestroyInstances(instances.AsArray()); + DestroyDrawInstances(instances.AsArray()); instances.Dispose(); m_BatchersContext.FreeRendererGroupInstances(rendererGroupIDs); @@ -113,13 +115,14 @@ namespace UnityEngine.Rendering m_BatchersContext.occlusionCullingCommon.UpdateInstanceOccluders(renderGraph, occluderParams, occluderSubviewUpdates); } - public void UpdateRenderers(NativeArray renderersID) + public void UpdateRenderers(NativeArray renderersID, bool materialUpdateOnly = false) { if (renderersID.Length == 0) return; m_GPUDrivenProcessor.enablePartialRendering = false; - m_GPUDrivenProcessor.EnableGPUDrivenRenderingAndDispatchRendererData(renderersID, m_UpdateRendererDataCallback); + m_GPUDrivenProcessor.EnableGPUDrivenRenderingAndDispatchRendererData(renderersID, + materialUpdateOnly ? m_UpdateRendererBatchesCallback : m_UpdateRendererInstancesAndBatchesCallback, materialUpdateOnly); m_GPUDrivenProcessor.enablePartialRendering = false; } @@ -133,6 +136,12 @@ namespace UnityEngine.Rendering } #endif + public JobHandle SchedulePackedMaterialCacheUpdate(NativeArray materialIDs, + NativeArray packedMaterialDatas) + { + return m_InstanceCullingBatcher.SchedulePackedMaterialCacheUpdate(materialIDs, packedMaterialDatas); + } + public void PostCullBeginCameraRendering(RenderRequestBatcherContext context) { m_InstanceCullingBatcher.PostCullBeginCameraRendering(context); @@ -143,14 +152,14 @@ namespace UnityEngine.Rendering m_BatchersContext.UpdateAmbientProbeAndGpuBuffer(forceUpdate: false); } - private void UpdateRendererData(in GPUDrivenRendererGroupData rendererData, IList meshes, IList materials) + private void UpdateRendererInstancesAndBatches(in GPUDrivenRendererGroupData rendererData, IList meshes, IList materials) { FreeRendererGroupInstances(rendererData.invalidRendererGroupID); if (rendererData.rendererGroupID.Length == 0) return; - Profiler.BeginSample("GPUResidentInstanceBatcher.UpdateRendererData"); + Profiler.BeginSample("GPUResidentInstanceBatcher.UpdateRendererInstancesAndBatches"); { // -------------------------------------------------------------------------------------------------------------------------------------- // Allocate and Update CPU instance data @@ -191,7 +200,7 @@ namespace UnityEngine.Rendering instances, rendererData.materialID, rendererData.meshID, - rendererData); + rendererData, true); } Profiler.EndSample(); @@ -201,6 +210,43 @@ namespace UnityEngine.Rendering Profiler.EndSample(); } + private void UpdateRendererBatches(in GPUDrivenRendererGroupData rendererData, IList meshes, IList materials) + { + if (rendererData.rendererGroupID.Length == 0) + return; + + Profiler.BeginSample("GPUResidentInstanceBatcher.UpdateRendererBatches"); + { + // -------------------------------------------------------------------------------------------------------------------------------------- + // Get Instances + // -------------------------------------------------------------------------------------------------------------------------------------- + var instances = new NativeList(rendererData.localToWorldMatrix.Length, Allocator.TempJob); + + Profiler.BeginSample("QueryInstances"); + { + m_BatchersContext.ScheduleQueryRendererGroupInstancesJob(rendererData.rendererGroupID, instances).Complete(); + } + Profiler.EndSample(); + + // -------------------------------------------------------------------------------------------------------------------------------------- + // Instance culling batcher + // -------------------------------------------------------------------------------------------------------------------------------------- + + Profiler.BeginSample("InstanceCullingBatcher.BuildBatch"); + { + m_InstanceCullingBatcher.BuildBatch( + instances.AsArray(), + rendererData.materialID, + rendererData.meshID, + rendererData, false); + instances.Dispose(); + } + Profiler.EndSample(); + + } + Profiler.EndSample(); + } + private void OnFinishedCulling(IntPtr customCullingResult) { ProcessTrees(); diff --git a/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/GPUResidentDrawer.Validator.cs b/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/GPUResidentDrawer.Validator.cs index 91a5c2cf..f76c930b 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/GPUResidentDrawer.Validator.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/GPUResidentDrawer.Validator.cs @@ -81,6 +81,11 @@ namespace UnityEngine.Rendering message = Strings.allowInEditModeDisabled; return false; } + + // Disable GRD in any external AssetImporter child process. GRD isn't made for AssetImporter workflow/lifetime + // Avoid memory leak warning messages and also some future issues (UUM-90039) + if (AssetDatabase.IsAssetImportWorkerProcess()) + return false; #endif // If we are forcing the system, no need to perform further checks if (IsForcedOnViaCommandLine()) diff --git a/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/GPUResidentDrawer.cs b/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/GPUResidentDrawer.cs index 53adb4f5..666a7cb3 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/GPUResidentDrawer.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/GPUResidentDrawer.cs @@ -326,6 +326,7 @@ namespace UnityEngine.Rendering private ObjectDispatcher m_Dispatcher; + #if UNITY_EDITOR private static readonly bool s_IsForcedOnViaCommandLine; private static readonly bool s_IsOcclusionForcedOnViaCommandLine; @@ -540,7 +541,7 @@ namespace UnityEngine.Rendering { if (s_Instance is null) return; - + if (m_ContextIntPtr == context.Internal_GetPtr()) { m_ContextIntPtr = IntPtr.Zero; @@ -570,16 +571,18 @@ namespace UnityEngine.Rendering var rendererData = m_Dispatcher.GetTypeChangesAndClear(Allocator.TempJob, noScriptingArray: true); Profiler.EndSample(); - Profiler.BeginSample("GPUResidentDrawer.FindUnsupportedMaterials"); - NativeList unsupportedMaterials = FindUnsupportedMaterials(materialData.changedID); + Profiler.BeginSample("GPUResidentDrawer.ClassifyMaterials"); + ClassifyMaterials(materialData.changedID, out NativeList unsupportedChangedMaterials, + out NativeList supportedChangedMaterials, + out NativeList supportedChangedPackedMaterialDatas, Allocator.TempJob); Profiler.EndSample(); Profiler.BeginSample("GPUResidentDrawer.FindUnsupportedRenderers"); - NativeList unsupportedRenderers = FindUnsupportedRenderers(unsupportedMaterials.AsArray()); + NativeList unsupportedRenderers = FindUnsupportedRenderers(unsupportedChangedMaterials.AsArray()); Profiler.EndSample(); Profiler.BeginSample("GPUResidentDrawer.ProcessMaterials"); - ProcessMaterials(materialData.destroyedID, unsupportedMaterials.AsArray()); + ProcessMaterials(materialData.destroyedID, unsupportedChangedMaterials.AsArray()); Profiler.EndSample(); Profiler.BeginSample("GPUResidentDrawer.ProcessMeshes"); @@ -594,13 +597,19 @@ namespace UnityEngine.Rendering ProcessRenderers(rendererData, unsupportedRenderers.AsArray()); Profiler.EndSample(); + Profiler.BeginSample("GPUResidentDrawer.ProcessRendererMaterialChanges"); + ProcessRendererMaterialChanges(rendererData.changedID, supportedChangedMaterials.AsArray(), supportedChangedPackedMaterialDatas.AsArray()); + Profiler.EndSample(); + lodGroupTransformData.Dispose(); lodGroupData.Dispose(); meshDataSorted.Dispose(); materialData.Dispose(); rendererData.Dispose(); - unsupportedMaterials.Dispose(); + unsupportedChangedMaterials.Dispose(); unsupportedRenderers.Dispose(); + supportedChangedMaterials.Dispose(); + supportedChangedPackedMaterialDatas.Dispose(); m_BatchersContext.UpdateInstanceMotions(); @@ -627,7 +636,7 @@ namespace UnityEngine.Rendering var destroyedMeshInstances = new NativeList(Allocator.TempJob); ScheduleQueryMeshInstancesJob(destroyedID, destroyedMeshInstances).Complete(); - m_Batcher.DestroyInstances(destroyedMeshInstances.AsArray()); + m_Batcher.DestroyDrawInstances(destroyedMeshInstances.AsArray()); destroyedMeshInstances.Dispose(); //@ Check if we need to update instance bounds and light probe sampling positions after mesh is destroyed. @@ -641,13 +650,73 @@ namespace UnityEngine.Rendering m_BatchersContext.TransformLODGroups(transformedID); } + private void ProcessRendererMaterialChanges(NativeArray excludedRenderers, NativeArray changedMaterials, NativeArray changedPackedMaterialDatas) + { + if (changedMaterials.Length == 0) + return; + + Profiler.BeginSample("GPUResidentDrawer.GetMaterialsWithChangedPackedMaterial"); + + var filteredMaterials = GetMaterialsWithChangedPackedMaterial(changedMaterials, changedPackedMaterialDatas, Allocator.TempJob); + // Make sure we update the packed material cache AFTER filtering the materials as we need to compare the packed materials + // with their previous values. + var updatePackedMaterialCacheJob = m_Batcher.SchedulePackedMaterialCacheUpdate(changedMaterials, changedPackedMaterialDatas); + + Profiler.EndSample(); + + if (filteredMaterials.Count == 0) + { + filteredMaterials.Dispose(); + updatePackedMaterialCacheJob.Complete(); + return; + } + + var sortedExcludedRenderers = new NativeArray(excludedRenderers, Allocator.TempJob); + if (sortedExcludedRenderers.Length > 0) + { + Profiler.BeginSample("ProcessRendererMaterialChanges.Sort"); + sortedExcludedRenderers.ParallelSort().Complete(); + Profiler.EndSample(); + } + + Profiler.BeginSample("GPUResidentDrawer.FindRenderersFromMaterials"); + + NativeList renderersWithChangedMaterials = FindRenderersFromMaterials(sortedExcludedRenderers, filteredMaterials, Allocator.TempJob); + filteredMaterials.Dispose(); + + Profiler.EndSample(); + + sortedExcludedRenderers.Dispose(); + updatePackedMaterialCacheJob.Complete(); + + if (renderersWithChangedMaterials.Length == 0) + { + renderersWithChangedMaterials.Dispose(); + return; + } + + Profiler.BeginSample("GPUResidentDrawer.UpdateRenderers"); + { + var materialChangedInstances = new NativeArray(renderersWithChangedMaterials.Length, Allocator.TempJob, NativeArrayOptions.UninitializedMemory); + ScheduleQueryRendererGroupInstancesJob(renderersWithChangedMaterials.AsArray(), materialChangedInstances).Complete(); + + m_Batcher.DestroyDrawInstances(materialChangedInstances); + materialChangedInstances.Dispose(); + m_Batcher.UpdateRenderers(renderersWithChangedMaterials.AsArray(), true); + + renderersWithChangedMaterials.Dispose(); + } + Profiler.EndSample(); + } + private void ProcessRenderers(TypeDispatchData rendererChanges, NativeArray unsupportedRenderers) { Profiler.BeginSample("GPUResidentDrawer.ProcessRenderers"); var changedInstances = new NativeArray(rendererChanges.changedID.Length, Allocator.TempJob, NativeArrayOptions.UninitializedMemory); ScheduleQueryRendererGroupInstancesJob(rendererChanges.changedID, changedInstances).Complete(); - m_Batcher.DestroyInstances(changedInstances); + + m_Batcher.DestroyDrawInstances(changedInstances); changedInstances.Dispose(); m_Batcher.UpdateRenderers(rendererChanges.changedID); @@ -664,6 +733,7 @@ namespace UnityEngine.Rendering TransformInstances(transformedInstances, transformChanges.localToWorldMatrices); transformedInstances.Dispose(); transformChanges.Dispose(); + Profiler.EndSample(); } @@ -680,7 +750,7 @@ namespace UnityEngine.Rendering { Profiler.BeginSample("GPUResidentDrawer.FreeInstances"); - m_Batcher.DestroyInstances(instances); + m_Batcher.DestroyDrawInstances(instances); m_BatchersContext.FreeInstances(instances); Profiler.EndSample(); @@ -730,21 +800,24 @@ namespace UnityEngine.Rendering return m_BatchersContext.ScheduleQueryMeshInstancesJob(sortedMeshIDs, instances); } - private NativeList FindUnsupportedMaterials(NativeArray changedMaterialIDs) + private void ClassifyMaterials(NativeArray materials, out NativeList unsupportedMaterials, + out NativeList supportedMaterials, out NativeList supportedPackedMaterialDatas, Allocator allocator) { - NativeList unsupportedMaterials = new NativeList(Allocator.TempJob); + supportedMaterials = new NativeList(materials.Length, allocator); + unsupportedMaterials = new NativeList(materials.Length, allocator); + supportedPackedMaterialDatas = new NativeList(materials.Length, allocator); - if (changedMaterialIDs.Length > 0) + if (materials.Length > 0) { - new FindUnsupportedMaterialsJob + new ClassifyMaterialsJob { - changedMaterialIDs = changedMaterialIDs, - batchMaterialHash = m_Batcher.instanceCullingBatcher.batchMaterialHash, + materialIDs = materials.AsReadOnly(), + batchMaterialHash = m_Batcher.instanceCullingBatcher.batchMaterialHash.AsReadOnly(), unsupportedMaterialIDs = unsupportedMaterials, + supportedMaterialIDs = supportedMaterials, + supportedPackedMaterialDatas = supportedPackedMaterialDatas }.Run(); } - - return unsupportedMaterials; } private NativeList FindUnsupportedRenderers(NativeArray unsupportedMaterials) @@ -765,30 +838,76 @@ namespace UnityEngine.Rendering return unsupportedRenderers; } + private NativeHashSet GetMaterialsWithChangedPackedMaterial(NativeArray materials, NativeArray packedMaterialDatas, Allocator allocator) + { + NativeHashSet filteredMaterials = new NativeHashSet(materials.Length, allocator); + + new GetMaterialsWithChangedPackedMaterialJob + { + materialIDs = materials.AsReadOnly(), + packedMaterialDatas = packedMaterialDatas.AsReadOnly(), + packedMaterialHash = batcher.instanceCullingBatcher.packedMaterialHash.AsReadOnly(), + filteredMaterials = filteredMaterials + }.Run(); + + return filteredMaterials; + } + + private NativeList FindRenderersFromMaterials(NativeArray sortedExcludeRenderers, NativeHashSet materials, Allocator rendererListAllocator) + { + var sharedInstanceData = m_BatchersContext.sharedInstanceData; + NativeList renderers = new NativeList(sharedInstanceData.rendererGroupIDs.Length, rendererListAllocator); + + var jobHandle = new FindRenderersFromMaterialJob + { + materialIDs = materials.AsReadOnly(), + materialIDArrays = sharedInstanceData.materialIDArrays, + rendererGroupIDs = sharedInstanceData.rendererGroupIDs, + sortedExcludeRendererIDs = sortedExcludeRenderers.AsReadOnly(), + selectedRenderGroups = renderers.AsParallelWriter(), + }.ScheduleBatch(sharedInstanceData.rendererGroupIDs.Length, FindRenderersFromMaterialJob.k_BatchSize); + jobHandle.Complete(); + + return renderers; + } + [BurstCompile(DisableSafetyChecks = true, OptimizeFor = OptimizeFor.Performance)] - private struct FindUnsupportedMaterialsJob : IJob + private struct ClassifyMaterialsJob : IJob { - [ReadOnly] public NativeParallelHashMap batchMaterialHash; - [ReadOnly] public NativeArray changedMaterialIDs; + [ReadOnly] public NativeParallelHashMap.ReadOnly batchMaterialHash; + [ReadOnly] public NativeArray.ReadOnly materialIDs; + public NativeList supportedMaterialIDs; public NativeList unsupportedMaterialIDs; + public NativeList supportedPackedMaterialDatas; - public unsafe void Execute() + public void Execute() { - var changedUsedMaterialIDs = new NativeList(4, Allocator.Temp); + var usedMaterialIDs = new NativeList(4, Allocator.TempJob); - foreach (var materialID in changedMaterialIDs) + foreach (var materialID in materialIDs) { if (batchMaterialHash.ContainsKey(materialID)) - changedUsedMaterialIDs.Add(materialID); + usedMaterialIDs.Add(materialID); } - if (changedUsedMaterialIDs.IsEmpty) + if (usedMaterialIDs.IsEmpty) + { + usedMaterialIDs.Dispose(); return; + } + + unsupportedMaterialIDs.Resize(usedMaterialIDs.Length, NativeArrayOptions.UninitializedMemory); + supportedMaterialIDs.Resize(usedMaterialIDs.Length, NativeArrayOptions.UninitializedMemory); + supportedPackedMaterialDatas.Resize(usedMaterialIDs.Length, NativeArrayOptions.UninitializedMemory); + + int unsupportedMaterialCount = GPUDrivenProcessor.ClassifyMaterials(usedMaterialIDs.AsArray(), unsupportedMaterialIDs.AsArray(), supportedMaterialIDs.AsArray(), supportedPackedMaterialDatas.AsArray()); - unsupportedMaterialIDs.Resize(changedUsedMaterialIDs.Length, NativeArrayOptions.UninitializedMemory); - int unsupportedMaterialCount = GPUDrivenProcessor.FindUnsupportedMaterialIDs(changedUsedMaterialIDs.AsArray(), unsupportedMaterialIDs.AsArray()); unsupportedMaterialIDs.Resize(unsupportedMaterialCount, NativeArrayOptions.ClearMemory); + supportedMaterialIDs.Resize(usedMaterialIDs.Length - unsupportedMaterialCount, NativeArrayOptions.ClearMemory); + supportedPackedMaterialDatas.Resize(supportedMaterialIDs.Length, NativeArrayOptions.ClearMemory); + + usedMaterialIDs.Dispose(); } } @@ -824,5 +943,74 @@ namespace UnityEngine.Rendering } } } + + [BurstCompile(DisableSafetyChecks = true, OptimizeFor = OptimizeFor.Performance)] + private unsafe struct FindRenderersFromMaterialJob : IJobParallelForBatch + { + public const int k_BatchSize = 128; + + [ReadOnly] public NativeHashSet.ReadOnly materialIDs; + [ReadOnly] public NativeArray.ReadOnly materialIDArrays; + [ReadOnly] public NativeArray.ReadOnly rendererGroupIDs; + [ReadOnly] public NativeArray.ReadOnly sortedExcludeRendererIDs; + + [WriteOnly] public NativeList.ParallelWriter selectedRenderGroups; + + public void Execute(int startIndex, int count) + { + int* renderersToAddPtr = stackalloc int[k_BatchSize]; + var renderersToAdd = new UnsafeList(renderersToAddPtr, k_BatchSize); + renderersToAdd.Length = 0; + + for (int index = 0; index < count; index++) + { + var rendererIndex = startIndex + index; + var rendererID = rendererGroupIDs[rendererIndex]; + + // We ignore this renderer if it is in the excluded list. + if (sortedExcludeRendererIDs.BinarySearch(rendererID) >= 0) + continue; + + var rendererMaterials = materialIDArrays[rendererIndex]; + + for (int materialIndex = 0; materialIndex < rendererMaterials.Length; materialIndex++) + { + var materialID = rendererMaterials[materialIndex]; + if (materialIDs.Contains(materialID)) + { + renderersToAdd.AddNoResize(rendererID); + break; + } + } + } + + selectedRenderGroups.AddRangeNoResize(renderersToAddPtr, renderersToAdd.Length); + } + } + + [BurstCompile(DisableSafetyChecks = true, OptimizeFor = OptimizeFor.Performance)] + private struct GetMaterialsWithChangedPackedMaterialJob : IJob + { + [ReadOnly] public NativeArray.ReadOnly materialIDs; + [ReadOnly] public NativeArray.ReadOnly packedMaterialDatas; + [ReadOnly] public NativeParallelHashMap.ReadOnly packedMaterialHash; + + [WriteOnly] public NativeHashSet filteredMaterials; + + public void Execute() + { + for (int index = 0; index < materialIDs.Length ; index++) + { + var materialID = materialIDs[index]; + var newPackedMaterialData = packedMaterialDatas[index]; + + // Has its packed material changed? If the material isn't in the packed material cache, consider the material has changed. + if (packedMaterialHash.TryGetValue(materialID, out var packedMaterial) && packedMaterial.Equals(newPackedMaterialData)) + continue; + + filteredMaterials.Add(materialID); + } + } + } } } diff --git a/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceCullingBatcher.cs b/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceCullingBatcher.cs index 85fd783f..ff4cd2a3 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceCullingBatcher.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceCullingBatcher.cs @@ -301,14 +301,42 @@ namespace UnityEngine.Rendering } } + [BurstCompile(DisableSafetyChecks = true, OptimizeFor = OptimizeFor.Performance)] + internal struct UpdatePackedMaterialDataCacheJob : IJob + { + [ReadOnly] public NativeArray.ReadOnly materialIDs; + [ReadOnly] public NativeArray.ReadOnly packedMaterialDatas; + + public NativeParallelHashMap packedMaterialHash; + + private void ProcessMaterial(int i) + { + var materialID = materialIDs[i]; + var packedMaterialData = packedMaterialDatas[i]; + + if (materialID == 0) + return; + + // Cache the packed material so we can detect a change in material that would need to update the renderer data. + packedMaterialHash[materialID] = packedMaterialData; + } + + public void Execute() + { + for (int i = 0; i < materialIDs.Length; ++i) + ProcessMaterial(i); + } + } + [BurstCompile(DisableSafetyChecks = true, OptimizeFor = OptimizeFor.Performance)] internal struct CreateDrawBatchesJob : IJob { [ReadOnly] public bool implicitInstanceIndices; [ReadOnly] public NativeArray instances; [ReadOnly] public GPUDrivenRendererGroupData rendererData; - [ReadOnly] public NativeParallelHashMap batchMeshHash; - [ReadOnly] public NativeParallelHashMap batchMaterialHash; + [ReadOnly] public NativeParallelHashMap.ReadOnly batchMeshHash; + [ReadOnly] public NativeParallelHashMap.ReadOnly batchMaterialHash; + [ReadOnly] public NativeParallelHashMap.ReadOnly packedMaterialDataHash; public NativeParallelHashMap rangeHash; public NativeList drawRanges; @@ -375,7 +403,6 @@ namespace UnityEngine.Rendering var lightmapIndex = rendererData.lightmapIndex[i]; var packedRendererData = rendererData.packedRendererData[i]; var rendererPriority = rendererData.rendererPriority[i]; - var lodGroupID = rendererData.lodGroupID[i]; int instanceCount; int instanceOffset; @@ -419,6 +446,8 @@ namespace UnityEngine.Rendering } // Scan all materials once to retrieve whether this renderer is indirect-compatible or not (and store it in the RangeKey). + Span packedMaterialDatas = stackalloc GPUDrivenPackedMaterialData[materialsCount]; + var supportsIndirect = true; for (int matIndex = 0; matIndex < materialsCount; ++matIndex) { @@ -429,8 +458,21 @@ namespace UnityEngine.Rendering } var materialIndex = rendererData.materialIndex[materialsOffset + matIndex]; - var packedMaterialData = rendererData.packedMaterialData[materialIndex]; + GPUDrivenPackedMaterialData packedMaterialData; + + if (rendererData.packedMaterialData.Length > 0) + { + packedMaterialData = rendererData.packedMaterialData[materialIndex]; + } + else + { + var materialID = rendererData.materialID[materialIndex]; + bool isFound = packedMaterialDataHash.TryGetValue(materialID, out packedMaterialData); + Assert.IsTrue(isFound); + } supportsIndirect &= packedMaterialData.isIndirectSupported; + + packedMaterialDatas[matIndex] = packedMaterialData; } var rangeKey = new RangeKey @@ -456,7 +498,7 @@ namespace UnityEngine.Rendering var materialIndex = rendererData.materialIndex[materialsOffset + matIndex]; var materialID = rendererData.materialID[materialIndex]; - var packedMaterialData = rendererData.packedMaterialData[materialIndex]; + var packedMaterialData = packedMaterialDatas[matIndex]; if (materialID == 0) { @@ -520,10 +562,8 @@ namespace UnityEngine.Rendering public void Execute() { - { - for (int i = 0; i < rendererData.rendererGroupID.Length; ++i) - ProcessRenderer(i); - } + for (int i = 0; i < rendererData.rendererGroupID.Length; ++i) + ProcessRenderer(i); } } @@ -718,6 +758,7 @@ namespace UnityEngine.Rendering private NativeParallelHashMap m_GlobalBatchIDs; private InstanceCuller m_Culler; private NativeParallelHashMap m_BatchMaterialHash; + private NativeParallelHashMap m_PackedMaterialHash; private NativeParallelHashMap m_BatchMeshHash; private int m_CachedInstanceDataBufferLayoutVersion; @@ -725,6 +766,7 @@ namespace UnityEngine.Rendering private OnCullingCompleteCallback m_OnCompleteCallback; public NativeParallelHashMap batchMaterialHash => m_BatchMaterialHash; + public NativeParallelHashMap packedMaterialHash => m_PackedMaterialHash; public InstanceCullingBatcher(RenderersBatchersContext batcherContext, InstanceCullingBatcherDesc desc, BatchRendererGroup.OnFinishedCulling onFinishedCulling) { @@ -774,6 +816,7 @@ namespace UnityEngine.Rendering m_CachedInstanceDataBufferLayoutVersion = -1; m_OnCompleteCallback = desc.onCompleteCallback; m_BatchMaterialHash = new NativeParallelHashMap(64, Allocator.Persistent); + m_PackedMaterialHash = new NativeParallelHashMap(64, Allocator.Persistent); m_BatchMeshHash = new NativeParallelHashMap(64, Allocator.Persistent); m_GlobalBatchIDs = new NativeParallelHashMap(6, Allocator.Persistent); @@ -806,6 +849,7 @@ namespace UnityEngine.Rendering m_DrawInstanceData = null; m_BatchMaterialHash.Dispose(); + m_PackedMaterialHash.Dispose(); m_BatchMeshHash.Dispose(); } @@ -902,12 +946,12 @@ namespace UnityEngine.Rendering m_Culler.EnsureValidOcclusionTestResults(viewInstanceID); } - public void DestroyInstances(NativeArray instances) + public void DestroyDrawInstances(NativeArray instances) { if (instances.Length == 0) return; - Profiler.BeginSample("DestroyInstances"); + Profiler.BeginSample("DestroyDrawInstances"); m_DrawInstanceData.DestroyDrawInstances(instances); @@ -929,6 +973,7 @@ namespace UnityEngine.Rendering { destroyedBatchMaterials.Add(destroyedBatchMaterial.value); m_BatchMaterialHash.Remove(destroyedMaterial); + m_PackedMaterialHash.Remove(destroyedMaterial); m_BRG.UnregisterMaterial(destroyedBatchMaterial); } } @@ -1007,6 +1052,7 @@ namespace UnityEngine.Rendering int totalMaterialsNum = m_BatchMaterialHash.Count() + newMaterialIDs.Length; m_BatchMaterialHash.Capacity = Math.Max(m_BatchMaterialHash.Capacity, Mathf.CeilToInt(totalMaterialsNum / 1023.0f) * 1024); + m_PackedMaterialHash.Capacity = m_BatchMaterialHash.Capacity; new RegisterNewInstancesJob { @@ -1020,22 +1066,37 @@ namespace UnityEngine.Rendering newBatchMaterialIDs.Dispose(); } + public JobHandle SchedulePackedMaterialCacheUpdate(NativeArray materialIDs, NativeArray packedMaterialDatas) + { + return new UpdatePackedMaterialDataCacheJob + { + materialIDs = materialIDs.AsReadOnly(), + packedMaterialDatas = packedMaterialDatas.AsReadOnly(), + packedMaterialHash = m_PackedMaterialHash + }.Schedule(); + } + public void BuildBatch( NativeArray instances, NativeArray usedMaterialIDs, NativeArray usedMeshIDs, - in GPUDrivenRendererGroupData rendererData) + in GPUDrivenRendererGroupData rendererData, + bool registerMaterialsAndMeshes) { - RegisterBatchMaterials(usedMaterialIDs); - RegisterBatchMeshes(usedMeshIDs); + if (registerMaterialsAndMeshes) + { + RegisterBatchMaterials(usedMaterialIDs); + RegisterBatchMeshes(usedMeshIDs); + } new CreateDrawBatchesJob { implicitInstanceIndices = rendererData.instancesCount.Length == 0, instances = instances, rendererData = rendererData, - batchMeshHash = m_BatchMeshHash, - batchMaterialHash = m_BatchMaterialHash, + batchMeshHash = m_BatchMeshHash.AsReadOnly(), + batchMaterialHash = m_BatchMaterialHash.AsReadOnly(), + packedMaterialDataHash = m_PackedMaterialHash.AsReadOnly(), rangeHash = m_DrawInstanceData.rangeHash, drawRanges = m_DrawInstanceData.drawRanges, batchHash = m_DrawInstanceData.batchHash, diff --git a/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceData/InstanceAllocator.cs b/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceData/InstanceAllocator.cs index 25deef7d..fccae9c6 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceData/InstanceAllocator.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceData/InstanceAllocator.cs @@ -10,7 +10,7 @@ namespace UnityEngine.Rendering internal struct InstanceHandle : IEquatable, IComparable { // Don't use this index to reference GPU data. This index is to reference CPU data only. - // To reference GPU data convert InstahceHandle to GPUInstanceIndex. + // To reference GPU data convert InstanceHandle to GPUInstanceIndex. public int index { get; private set; } // This is unique instance index for each instance type. diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeAdjustmentVolume.cs b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeAdjustmentVolume.cs index 973a2356..7bc10677 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeAdjustmentVolume.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeAdjustmentVolume.cs @@ -5,7 +5,7 @@ namespace UnityEngine.Rendering /// /// A marker to adjust probes in an area of the scene. /// - [CoreRPHelpURL("probevolumes-settings#probe-adjustment-volume", "com.unity.render-pipelines.high-definition")] + [CoreRPHelpURL("probevolumes-adjustment-volume-component-reference", "com.unity.render-pipelines.high-definition")] [ExecuteAlways] [AddComponentMenu("Rendering/Probe Adjustment Volume")] public class ProbeAdjustmentVolume : MonoBehaviour, ISerializationCallbackReceiver diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.Streaming.cs b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.Streaming.cs index abb57ee3..87945b9c 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.Streaming.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.Streaming.cs @@ -114,6 +114,7 @@ namespace UnityEngine.Rendering public CellStreamingScratchBuffer(int chunkCount, int chunkSize, bool allocateGraphicsBuffers) { this.chunkCount = chunkCount; + this.chunkSize = chunkSize; // With a stride of 4 (one uint) // Number of elements for chunk data: chunkCount * chunkSize / 4 @@ -152,6 +153,7 @@ namespace UnityEngine.Rendering public GraphicsBuffer buffer => m_GraphicsBuffers[m_CurrentBuffer]; public NativeArray stagingBuffer; // Contains data streamed from disk. To be copied into the graphics buffer. public int chunkCount { get; } + public int chunkSize { get; } int m_CurrentBuffer; GraphicsBuffer[] m_GraphicsBuffers = new GraphicsBuffer[2]; diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.cs b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.cs index e32a7070..a9eadd77 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.cs @@ -1379,7 +1379,7 @@ namespace UnityEngine.Rendering { if (m_PendingScenesToBeLoaded.ContainsKey(sceneGUID)) m_PendingScenesToBeLoaded.Remove(sceneGUID); - if (m_ActiveScenes.Contains(sceneGUID)) + if (m_ActiveScenes.Contains(sceneGUID) && m_CurrentBakingSet != null) m_PendingScenesToBeUnloaded.TryAdd(sceneGUID, m_CurrentBakingSet.GetSceneCellIndexList(sceneGUID)); } @@ -1546,6 +1546,7 @@ namespace UnityEngine.Rendering /// public void PerformPendingOperations() { + #if UNITY_EDITOR checksDuringBakeAction?.Invoke(); #endif diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolume.cs b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolume.cs index 1a967f1d..a6a719f2 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolume.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolume.cs @@ -6,7 +6,7 @@ namespace UnityEngine.Rendering /// /// A marker to determine what area of the scene is considered by the Probe Volumes system /// - [CoreRPHelpURL("probevolumes-settings#probe-volume-properties", "com.unity.render-pipelines.high-definition")] + [CoreRPHelpURL("probevolumes-options-override-reference", "com.unity.render-pipelines.high-definition")] [ExecuteAlways] [AddComponentMenu("Rendering/Adaptive Probe Volume")] public partial class ProbeVolume : MonoBehaviour diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumePerSceneData.cs b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumePerSceneData.cs index a1132b5c..639f3087 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumePerSceneData.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumePerSceneData.cs @@ -76,6 +76,13 @@ namespace UnityEngine.Rendering if (serializedBakingSet == null) return; + #if UNITY_EDITOR + // Check if we are trying to load APV data for a scene which has not enabled APV (or it was removed) + var bakedData = serializedBakingSet.GetSceneBakeData(sceneGUID); + if (bakedData != null && bakedData.hasProbeVolume == false) + return; + #endif + var refVol = ProbeReferenceVolume.instance; refVol.AddPendingSceneLoading(sceneGUID, serializedBakingSet); } diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumeScratchBufferPool.cs b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumeScratchBufferPool.cs index bdee7c19..f5404a10 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumeScratchBufferPool.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumeScratchBufferPool.cs @@ -232,6 +232,12 @@ namespace UnityEngine.Rendering public void ReleaseScratchBuffer(CellStreamingScratchBuffer scratchBuffer) { + if (scratchBuffer.chunkSize != chunkSize) + { + scratchBuffer.Dispose(); + return; + } + s_ChunkCount = scratchBuffer.chunkCount; var pool = m_Pools.Find((o) => o.chunkCount == s_ChunkCount); Debug.Assert(pool != null); diff --git a/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Debug/DebugDisplaySettingsRenderGraph.cs b/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Debug/DebugDisplaySettingsRenderGraph.cs index b65e9c77..1e26f847 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Debug/DebugDisplaySettingsRenderGraph.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Debug/DebugDisplaySettingsRenderGraph.cs @@ -18,6 +18,7 @@ namespace UnityEngine.Rendering } [DisplayInfo(name = "Render Graph", order = 10)] + [CurrentPipelineHelpURL(pageName: "features/rendering-debugger-reference", pageHash: "render-graph")] private class SettingsPanel : DebugDisplaySettingsPanel { public override string PanelName => "Render Graph"; diff --git a/Packages/com.unity.render-pipelines.core/Runtime/RenderPipelineResources/Default Lens Flare (SRP).asset b/Packages/com.unity.render-pipelines.core/Runtime/RenderPipelineResources/Default Lens Flare (SRP).asset index d92183cc..4101ffb1 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/RenderPipelineResources/Default Lens Flare (SRP).asset +++ b/Packages/com.unity.render-pipelines.core/Runtime/RenderPipelineResources/Default Lens Flare (SRP).asset @@ -19,6 +19,13 @@ MonoBehaviour: positionOffset: {x: 0, y: 0} angularOffset: 0 translationScale: {x: 1, y: 1} + ringThickness: 0.25 + hoopFactor: 1 + noiseAmplitude: 1 + noiseFrequency: 1 + noiseSpeed: 0 + shapeCutOffSpeed: 0 + shapeCutOffRadius: 10 m_LocalIntensity: 1 lensFlareTexture: {fileID: 0} uniformScale: 15 @@ -27,9 +34,9 @@ MonoBehaviour: m_Count: 5 preserveAspectRatio: 0 rotation: 0 - tintConst: 1 + tintColorType: 0 tint: {r: 1, g: 1, b: 1, a: 0.5} - tintRadial: + tintGradient: k__BackingField: 4 m_Gradient: serializedVersion: 2 @@ -216,6 +223,13 @@ MonoBehaviour: positionOffset: {x: 0, y: 0} angularOffset: 0 translationScale: {x: 1, y: 1} + ringThickness: 0.25 + hoopFactor: 1 + noiseAmplitude: 1 + noiseFrequency: 1 + noiseSpeed: 0 + shapeCutOffSpeed: 0 + shapeCutOffRadius: 10 m_LocalIntensity: 0.05 lensFlareTexture: {fileID: 2800000, guid: da47326d6c6190a4e8793de9a26bf176, type: 3} uniformScale: 0.3 @@ -224,9 +238,9 @@ MonoBehaviour: m_Count: 5 preserveAspectRatio: 0 rotation: 0 - tintConst: 1 + tintColorType: 0 tint: {r: 0.49673662, g: 0.8679245, b: 0.55442125, a: 0.5} - tintRadial: + tintGradient: k__BackingField: 4 m_Gradient: serializedVersion: 2 @@ -431,6 +445,13 @@ MonoBehaviour: positionOffset: {x: 0, y: 0} angularOffset: 0 translationScale: {x: 1, y: 1} + ringThickness: 0.25 + hoopFactor: 1 + noiseAmplitude: 1 + noiseFrequency: 1 + noiseSpeed: 0 + shapeCutOffSpeed: 0 + shapeCutOffRadius: 10 m_LocalIntensity: 0.1 lensFlareTexture: {fileID: 2800000, guid: da47326d6c6190a4e8793de9a26bf176, type: 3} uniformScale: 0.35 @@ -439,9 +460,9 @@ MonoBehaviour: m_Count: 4 preserveAspectRatio: 0 rotation: 0 - tintConst: 1 + tintColorType: 0 tint: {r: 0.9245283, g: 0.6026995, b: 0.5552984, a: 0.5} - tintRadial: + tintGradient: k__BackingField: 4 m_Gradient: serializedVersion: 2 @@ -655,6 +676,13 @@ MonoBehaviour: positionOffset: {x: 0, y: 0} angularOffset: 0 translationScale: {x: 1, y: 1} + ringThickness: 0.25 + hoopFactor: 1 + noiseAmplitude: 1 + noiseFrequency: 1 + noiseSpeed: 0 + shapeCutOffSpeed: 0 + shapeCutOffRadius: 10 m_LocalIntensity: 0.1 lensFlareTexture: {fileID: 2800000, guid: da47326d6c6190a4e8793de9a26bf176, type: 3} uniformScale: 0.3 @@ -663,9 +691,9 @@ MonoBehaviour: m_Count: 2 preserveAspectRatio: 0 rotation: 0 - tintConst: 1 + tintColorType: 0 tint: {r: 0.9245283, g: 0.6026995, b: 0.5552984, a: 0.5} - tintRadial: + tintGradient: k__BackingField: 4 m_Gradient: serializedVersion: 2 @@ -852,6 +880,13 @@ MonoBehaviour: positionOffset: {x: 0, y: 0} angularOffset: 0 translationScale: {x: 1, y: 1} + ringThickness: 0.25 + hoopFactor: 1 + noiseAmplitude: 1 + noiseFrequency: 1 + noiseSpeed: 0 + shapeCutOffSpeed: 0 + shapeCutOffRadius: 10 m_LocalIntensity: 0.03 lensFlareTexture: {fileID: 2800000, guid: da47326d6c6190a4e8793de9a26bf176, type: 3} uniformScale: 1.5 @@ -860,9 +895,9 @@ MonoBehaviour: m_Count: 4 preserveAspectRatio: 0 rotation: 0 - tintConst: 1 + tintColorType: 0 tint: {r: 0.34509802, g: 0.65088975, b: 1, a: 0.5} - tintRadial: + tintGradient: k__BackingField: 4 m_Gradient: serializedVersion: 2 @@ -1049,6 +1084,13 @@ MonoBehaviour: positionOffset: {x: 0, y: 0} angularOffset: 2 translationScale: {x: 1, y: 1} + ringThickness: 0.25 + hoopFactor: 1 + noiseAmplitude: 1 + noiseFrequency: 1 + noiseSpeed: 0 + shapeCutOffSpeed: 0 + shapeCutOffRadius: 10 m_LocalIntensity: 0.015 lensFlareTexture: {fileID: 2800000, guid: da47326d6c6190a4e8793de9a26bf176, type: 3} uniformScale: 2 @@ -1057,9 +1099,9 @@ MonoBehaviour: m_Count: 3 preserveAspectRatio: 0 rotation: 0 - tintConst: 1 + tintColorType: 0 tint: {r: 0.34509802, g: 1, b: 0.7484353, a: 0.5} - tintRadial: + tintGradient: k__BackingField: 4 m_Gradient: serializedVersion: 2 @@ -1246,6 +1288,13 @@ MonoBehaviour: positionOffset: {x: 0, y: 0} angularOffset: 0 translationScale: {x: 1, y: 1} + ringThickness: 0.25 + hoopFactor: 1 + noiseAmplitude: 1 + noiseFrequency: 1 + noiseSpeed: 0 + shapeCutOffSpeed: 0 + shapeCutOffRadius: 10 m_LocalIntensity: 0.008 lensFlareTexture: {fileID: 2800000, guid: da47326d6c6190a4e8793de9a26bf176, type: 3} uniformScale: 2 @@ -1254,9 +1303,9 @@ MonoBehaviour: m_Count: 3 preserveAspectRatio: 0 rotation: 0 - tintConst: 1 + tintColorType: 0 tint: {r: 0.34509802, g: 1, b: 0.7484353, a: 0.5} - tintRadial: + tintGradient: k__BackingField: 4 m_Gradient: serializedVersion: 2 diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs b/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs index 70a4d89d..a1538fbd 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs @@ -164,6 +164,17 @@ namespace UnityEngine.Rendering if (filter?.Invoke(field) ?? true) { VolumeParameter volumeParameter = (VolumeParameter)field.GetValue(o); +#if UNITY_EDITOR || DEVELOPMENT_BUILD + var attr = (DisplayInfoAttribute[])field.GetCustomAttributes(typeof(DisplayInfoAttribute), true); + if (attr.Length != 0) + { + volumeParameter.debugId = attr[0].name; + } + else + { + volumeParameter.debugId = field.Name; + } +#endif parameters.Add(volumeParameter); } } diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeParameter.cs b/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeParameter.cs index 110e5c7e..b8fc6b90 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeParameter.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeParameter.cs @@ -18,6 +18,10 @@ namespace UnityEngine.Rendering /// public abstract class VolumeParameter : ICloneable { +#if UNITY_EDITOR || DEVELOPMENT_BUILD + internal string debugId { get; set; } +#endif + /// /// A beautified string for debugger output. This is set on a DebuggerDisplay on every /// parameter types. diff --git a/Packages/com.unity.render-pipelines.core/ShaderLibrary/Shadow/ShadowSamplingTent.hlsl b/Packages/com.unity.render-pipelines.core/ShaderLibrary/Shadow/ShadowSamplingTent.hlsl index 507635aa..53ad393b 100644 --- a/Packages/com.unity.render-pipelines.core/ShaderLibrary/Shadow/ShadowSamplingTent.hlsl +++ b/Packages/com.unity.render-pipelines.core/ShaderLibrary/Shadow/ShadowSamplingTent.hlsl @@ -1,5 +1,6 @@ #ifndef SHADOW_SAMPLING_TENT_INCLUDED #define SHADOW_SAMPLING_TENT_INCLUDED + // ------------------------------------------------------------------ // PCF Filtering Tent Functions // ------------------------------------------------------------------ @@ -140,108 +141,121 @@ void SampleShadow_ComputeSamples_Tent_3x3(real4 shadowMapTexture_TexelSize, real } // 5x5 Tent filter (45 degree sloped triangles in U and V) +#define SampleShadow_ComputeSamples_Tent_Filter_5x5(Type, shadowMapTexelSize, coord, fetchesWeights, fetchesUV) \ +{ \ + /* Tent base is 5x5 base thus covering from 25 to 36 texels, thus we need 9 bilinear PCF fetches */ \ + Type##2 tentCenterInTexelSpace = (coord).xy * (shadowMapTexelSize).zw; \ + Type##2 centerOfFetchesInTexelSpace = floor(tentCenterInTexelSpace + 0.5); \ + Type##2 offsetFromTentCenterToCenterOfFetches = tentCenterInTexelSpace - centerOfFetchesInTexelSpace; \ + \ + /* Find the weight of each texel based on the area of a 45-degree sloped tent above each of them */ \ + Type##3 texelsWeightsU_A, texelsWeightsU_B; \ + Type##3 texelsWeightsV_A, texelsWeightsV_B; \ + SampleShadow_GetTexelWeights_Tent_5x5(offsetFromTentCenterToCenterOfFetches.x, texelsWeightsU_A, texelsWeightsU_B); \ + SampleShadow_GetTexelWeights_Tent_5x5(offsetFromTentCenterToCenterOfFetches.y, texelsWeightsV_A, texelsWeightsV_B); \ + \ + /* Each fetch will cover a group of 2x2 texels, the weight of each group is the sum of the weights of the texels */ \ + Type##3 fetchesWeightsU = Type##3(texelsWeightsU_A.xz, texelsWeightsU_B.y) + Type##3(texelsWeightsU_A.y, texelsWeightsU_B.xz); \ + Type##3 fetchesWeightsV = Type##3(texelsWeightsV_A.xz, texelsWeightsV_B.y) + Type##3(texelsWeightsV_A.y, texelsWeightsV_B.xz); \ + \ + /* Move the PCF bilinear fetches to respect texels weights */ \ + Type##3 fetchesOffsetsU = Type##3(texelsWeightsU_A.y, texelsWeightsU_B.xz) / fetchesWeightsU.xyz + Type##3(-2.5, -0.5, 1.5); \ + Type##3 fetchesOffsetsV = Type##3(texelsWeightsV_A.y, texelsWeightsV_B.xz) / fetchesWeightsV.xyz + Type##3(-2.5, -0.5, 1.5); \ + fetchesOffsetsU *= (shadowMapTexelSize).xxx; \ + fetchesOffsetsV *= (shadowMapTexelSize).yyy; \ + \ + Type##2 bilinearFetchOrigin = centerOfFetchesInTexelSpace * (shadowMapTexelSize).xy; \ + (fetchesUV)[0] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.x, fetchesOffsetsV.x); \ + (fetchesUV)[1] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.y, fetchesOffsetsV.x); \ + (fetchesUV)[2] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.z, fetchesOffsetsV.x); \ + (fetchesUV)[3] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.x, fetchesOffsetsV.y); \ + (fetchesUV)[4] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.y, fetchesOffsetsV.y); \ + (fetchesUV)[5] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.z, fetchesOffsetsV.y); \ + (fetchesUV)[6] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.x, fetchesOffsetsV.z); \ + (fetchesUV)[7] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.y, fetchesOffsetsV.z); \ + (fetchesUV)[8] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.z, fetchesOffsetsV.z); \ + \ + (fetchesWeights)[0] = fetchesWeightsU.x * fetchesWeightsV.x; \ + (fetchesWeights)[1] = fetchesWeightsU.y * fetchesWeightsV.x; \ + (fetchesWeights)[2] = fetchesWeightsU.z * fetchesWeightsV.x; \ + (fetchesWeights)[3] = fetchesWeightsU.x * fetchesWeightsV.y; \ + (fetchesWeights)[4] = fetchesWeightsU.y * fetchesWeightsV.y; \ + (fetchesWeights)[5] = fetchesWeightsU.z * fetchesWeightsV.y; \ + (fetchesWeights)[6] = fetchesWeightsU.x * fetchesWeightsV.z; \ + (fetchesWeights)[7] = fetchesWeightsU.y * fetchesWeightsV.z; \ + (fetchesWeights)[8] = fetchesWeightsU.z * fetchesWeightsV.z; \ +} + void SampleShadow_ComputeSamples_Tent_5x5(real4 shadowMapTexture_TexelSize, real2 coord, out real fetchesWeights[9], out real2 fetchesUV[9]) { - // tent base is 5x5 base thus covering from 25 to 36 texels, thus we need 9 bilinear PCF fetches - real2 tentCenterInTexelSpace = coord.xy * shadowMapTexture_TexelSize.zw; - real2 centerOfFetchesInTexelSpace = floor(tentCenterInTexelSpace + 0.5); - real2 offsetFromTentCenterToCenterOfFetches = tentCenterInTexelSpace - centerOfFetchesInTexelSpace; + SampleShadow_ComputeSamples_Tent_Filter_5x5(real, shadowMapTexture_TexelSize, coord, fetchesWeights, fetchesUV); +} - // find the weight of each texel based on the area of a 45 degree slop tent above each of them. - real3 texelsWeightsU_A, texelsWeightsU_B; - real3 texelsWeightsV_A, texelsWeightsV_B; - SampleShadow_GetTexelWeights_Tent_5x5(offsetFromTentCenterToCenterOfFetches.x, texelsWeightsU_A, texelsWeightsU_B); - SampleShadow_GetTexelWeights_Tent_5x5(offsetFromTentCenterToCenterOfFetches.y, texelsWeightsV_A, texelsWeightsV_B); - // each fetch will cover a group of 2x2 texels, the weight of each group is the sum of the weights of the texels - real3 fetchesWeightsU = real3(texelsWeightsU_A.xz, texelsWeightsU_B.y) + real3(texelsWeightsU_A.y, texelsWeightsU_B.xz); - real3 fetchesWeightsV = real3(texelsWeightsV_A.xz, texelsWeightsV_B.y) + real3(texelsWeightsV_A.y, texelsWeightsV_B.xz); +// 7x7 Tent filter (45 degree sloped triangles in U and V) +#define SampleShadow_ComputeSamples_Tent_Filter_7x7(Type, shadowMapTexelSize, coord, fetchesWeights, fetchesUV) \ +{ \ + /* Tent base is 7x7 base thus covering from 49 to 64 texels, thus we need 16 bilinear PCF fetches */ \ + Type##2 tentCenterInTexelSpace = (coord).xy * (shadowMapTexelSize).zw; \ + Type##2 centerOfFetchesInTexelSpace = floor(tentCenterInTexelSpace + 0.5); \ + Type##2 offsetFromTentCenterToCenterOfFetches = tentCenterInTexelSpace - centerOfFetchesInTexelSpace; \ + \ + /* Find the weight of each texel based on the area of a 45 degree slop tent above each of them. */ \ + Type##4 texelsWeightsU_A, texelsWeightsU_B; \ + Type##4 texelsWeightsV_A, texelsWeightsV_B; \ + SampleShadow_GetTexelWeights_Tent_7x7(offsetFromTentCenterToCenterOfFetches.x, texelsWeightsU_A, texelsWeightsU_B); \ + SampleShadow_GetTexelWeights_Tent_7x7(offsetFromTentCenterToCenterOfFetches.y, texelsWeightsV_A, texelsWeightsV_B); \ + \ + /* Each fetch will cover a group of 2x2 texels, the weight of each group is the sum of the weights of the texels */ \ + Type##4 fetchesWeightsU = Type##4(texelsWeightsU_A.xz, texelsWeightsU_B.xz) + Type##4(texelsWeightsU_A.yw, texelsWeightsU_B.yw); \ + Type##4 fetchesWeightsV = Type##4(texelsWeightsV_A.xz, texelsWeightsV_B.xz) + Type##4(texelsWeightsV_A.yw, texelsWeightsV_B.yw); \ + \ + /* Move the PCF bilinear fetches to respect texels weights */ \ + Type##4 fetchesOffsetsU = Type##4(texelsWeightsU_A.yw, texelsWeightsU_B.yw) / fetchesWeightsU.xyzw + Type##4(-3.5, -1.5, 0.5, 2.5); \ + Type##4 fetchesOffsetsV = Type##4(texelsWeightsV_A.yw, texelsWeightsV_B.yw) / fetchesWeightsV.xyzw + Type##4(-3.5, -1.5, 0.5, 2.5); \ + fetchesOffsetsU *= (shadowMapTexelSize).xxxx; \ + fetchesOffsetsV *= (shadowMapTexelSize).yyyy; \ + \ + Type##2 bilinearFetchOrigin = centerOfFetchesInTexelSpace * (shadowMapTexelSize).xy; \ + (fetchesUV)[0] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.x, fetchesOffsetsV.x); \ + (fetchesUV)[1] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.y, fetchesOffsetsV.x); \ + (fetchesUV)[2] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.z, fetchesOffsetsV.x); \ + (fetchesUV)[3] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.w, fetchesOffsetsV.x); \ + (fetchesUV)[4] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.x, fetchesOffsetsV.y); \ + (fetchesUV)[5] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.y, fetchesOffsetsV.y); \ + (fetchesUV)[6] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.z, fetchesOffsetsV.y); \ + (fetchesUV)[7] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.w, fetchesOffsetsV.y); \ + (fetchesUV)[8] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.x, fetchesOffsetsV.z); \ + (fetchesUV)[9] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.y, fetchesOffsetsV.z); \ + (fetchesUV)[10] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.z, fetchesOffsetsV.z); \ + (fetchesUV)[11] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.w, fetchesOffsetsV.z); \ + (fetchesUV)[12] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.x, fetchesOffsetsV.w); \ + (fetchesUV)[13] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.y, fetchesOffsetsV.w); \ + (fetchesUV)[14] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.z, fetchesOffsetsV.w); \ + (fetchesUV)[15] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.w, fetchesOffsetsV.w); \ + \ + (fetchesWeights)[0] = fetchesWeightsU.x * fetchesWeightsV.x; \ + (fetchesWeights)[1] = fetchesWeightsU.y * fetchesWeightsV.x; \ + (fetchesWeights)[2] = fetchesWeightsU.z * fetchesWeightsV.x; \ + (fetchesWeights)[3] = fetchesWeightsU.w * fetchesWeightsV.x; \ + (fetchesWeights)[4] = fetchesWeightsU.x * fetchesWeightsV.y; \ + (fetchesWeights)[5] = fetchesWeightsU.y * fetchesWeightsV.y; \ + (fetchesWeights)[6] = fetchesWeightsU.z * fetchesWeightsV.y; \ + (fetchesWeights)[7] = fetchesWeightsU.w * fetchesWeightsV.y; \ + (fetchesWeights)[8] = fetchesWeightsU.x * fetchesWeightsV.z; \ + (fetchesWeights)[9] = fetchesWeightsU.y * fetchesWeightsV.z; \ + (fetchesWeights)[10] = fetchesWeightsU.z * fetchesWeightsV.z; \ + (fetchesWeights)[11] = fetchesWeightsU.w * fetchesWeightsV.z; \ + (fetchesWeights)[12] = fetchesWeightsU.x * fetchesWeightsV.w; \ + (fetchesWeights)[13] = fetchesWeightsU.y * fetchesWeightsV.w; \ + (fetchesWeights)[14] = fetchesWeightsU.z * fetchesWeightsV.w; \ + (fetchesWeights)[15] = fetchesWeightsU.w * fetchesWeightsV.w; \ +} - // move the PCF bilinear fetches to respect texels weights - real3 fetchesOffsetsU = real3(texelsWeightsU_A.y, texelsWeightsU_B.xz) / fetchesWeightsU.xyz + real3(-2.5,-0.5,1.5); - real3 fetchesOffsetsV = real3(texelsWeightsV_A.y, texelsWeightsV_B.xz) / fetchesWeightsV.xyz + real3(-2.5,-0.5,1.5); - fetchesOffsetsU *= shadowMapTexture_TexelSize.xxx; - fetchesOffsetsV *= shadowMapTexture_TexelSize.yyy; - real2 bilinearFetchOrigin = centerOfFetchesInTexelSpace * shadowMapTexture_TexelSize.xy; - fetchesUV[0] = bilinearFetchOrigin + real2(fetchesOffsetsU.x, fetchesOffsetsV.x); - fetchesUV[1] = bilinearFetchOrigin + real2(fetchesOffsetsU.y, fetchesOffsetsV.x); - fetchesUV[2] = bilinearFetchOrigin + real2(fetchesOffsetsU.z, fetchesOffsetsV.x); - fetchesUV[3] = bilinearFetchOrigin + real2(fetchesOffsetsU.x, fetchesOffsetsV.y); - fetchesUV[4] = bilinearFetchOrigin + real2(fetchesOffsetsU.y, fetchesOffsetsV.y); - fetchesUV[5] = bilinearFetchOrigin + real2(fetchesOffsetsU.z, fetchesOffsetsV.y); - fetchesUV[6] = bilinearFetchOrigin + real2(fetchesOffsetsU.x, fetchesOffsetsV.z); - fetchesUV[7] = bilinearFetchOrigin + real2(fetchesOffsetsU.y, fetchesOffsetsV.z); - fetchesUV[8] = bilinearFetchOrigin + real2(fetchesOffsetsU.z, fetchesOffsetsV.z); - fetchesWeights[0] = fetchesWeightsU.x * fetchesWeightsV.x; - fetchesWeights[1] = fetchesWeightsU.y * fetchesWeightsV.x; - fetchesWeights[2] = fetchesWeightsU.z * fetchesWeightsV.x; - fetchesWeights[3] = fetchesWeightsU.x * fetchesWeightsV.y; - fetchesWeights[4] = fetchesWeightsU.y * fetchesWeightsV.y; - fetchesWeights[5] = fetchesWeightsU.z * fetchesWeightsV.y; - fetchesWeights[6] = fetchesWeightsU.x * fetchesWeightsV.z; - fetchesWeights[7] = fetchesWeightsU.y * fetchesWeightsV.z; - fetchesWeights[8] = fetchesWeightsU.z * fetchesWeightsV.z; -} - -// 7x7 Tent filter (45 degree sloped triangles in U and V) void SampleShadow_ComputeSamples_Tent_7x7(real4 shadowMapTexture_TexelSize, real2 coord, out real fetchesWeights[16], out real2 fetchesUV[16]) { - // tent base is 7x7 base thus covering from 49 to 64 texels, thus we need 16 bilinear PCF fetches - real2 tentCenterInTexelSpace = coord.xy * shadowMapTexture_TexelSize.zw; - real2 centerOfFetchesInTexelSpace = floor(tentCenterInTexelSpace + 0.5); - real2 offsetFromTentCenterToCenterOfFetches = tentCenterInTexelSpace - centerOfFetchesInTexelSpace; - - // find the weight of each texel based on the area of a 45 degree slop tent above each of them. - real4 texelsWeightsU_A, texelsWeightsU_B; - real4 texelsWeightsV_A, texelsWeightsV_B; - SampleShadow_GetTexelWeights_Tent_7x7(offsetFromTentCenterToCenterOfFetches.x, texelsWeightsU_A, texelsWeightsU_B); - SampleShadow_GetTexelWeights_Tent_7x7(offsetFromTentCenterToCenterOfFetches.y, texelsWeightsV_A, texelsWeightsV_B); - - // each fetch will cover a group of 2x2 texels, the weight of each group is the sum of the weights of the texels - real4 fetchesWeightsU = real4(texelsWeightsU_A.xz, texelsWeightsU_B.xz) + real4(texelsWeightsU_A.yw, texelsWeightsU_B.yw); - real4 fetchesWeightsV = real4(texelsWeightsV_A.xz, texelsWeightsV_B.xz) + real4(texelsWeightsV_A.yw, texelsWeightsV_B.yw); - - // move the PCF bilinear fetches to respect texels weights - real4 fetchesOffsetsU = real4(texelsWeightsU_A.yw, texelsWeightsU_B.yw) / fetchesWeightsU.xyzw + real4(-3.5,-1.5,0.5,2.5); - real4 fetchesOffsetsV = real4(texelsWeightsV_A.yw, texelsWeightsV_B.yw) / fetchesWeightsV.xyzw + real4(-3.5,-1.5,0.5,2.5); - fetchesOffsetsU *= shadowMapTexture_TexelSize.xxxx; - fetchesOffsetsV *= shadowMapTexture_TexelSize.yyyy; - - real2 bilinearFetchOrigin = centerOfFetchesInTexelSpace * shadowMapTexture_TexelSize.xy; - fetchesUV[0] = bilinearFetchOrigin + real2(fetchesOffsetsU.x, fetchesOffsetsV.x); - fetchesUV[1] = bilinearFetchOrigin + real2(fetchesOffsetsU.y, fetchesOffsetsV.x); - fetchesUV[2] = bilinearFetchOrigin + real2(fetchesOffsetsU.z, fetchesOffsetsV.x); - fetchesUV[3] = bilinearFetchOrigin + real2(fetchesOffsetsU.w, fetchesOffsetsV.x); - fetchesUV[4] = bilinearFetchOrigin + real2(fetchesOffsetsU.x, fetchesOffsetsV.y); - fetchesUV[5] = bilinearFetchOrigin + real2(fetchesOffsetsU.y, fetchesOffsetsV.y); - fetchesUV[6] = bilinearFetchOrigin + real2(fetchesOffsetsU.z, fetchesOffsetsV.y); - fetchesUV[7] = bilinearFetchOrigin + real2(fetchesOffsetsU.w, fetchesOffsetsV.y); - fetchesUV[8] = bilinearFetchOrigin + real2(fetchesOffsetsU.x, fetchesOffsetsV.z); - fetchesUV[9] = bilinearFetchOrigin + real2(fetchesOffsetsU.y, fetchesOffsetsV.z); - fetchesUV[10] = bilinearFetchOrigin + real2(fetchesOffsetsU.z, fetchesOffsetsV.z); - fetchesUV[11] = bilinearFetchOrigin + real2(fetchesOffsetsU.w, fetchesOffsetsV.z); - fetchesUV[12] = bilinearFetchOrigin + real2(fetchesOffsetsU.x, fetchesOffsetsV.w); - fetchesUV[13] = bilinearFetchOrigin + real2(fetchesOffsetsU.y, fetchesOffsetsV.w); - fetchesUV[14] = bilinearFetchOrigin + real2(fetchesOffsetsU.z, fetchesOffsetsV.w); - fetchesUV[15] = bilinearFetchOrigin + real2(fetchesOffsetsU.w, fetchesOffsetsV.w); - - fetchesWeights[0] = fetchesWeightsU.x * fetchesWeightsV.x; - fetchesWeights[1] = fetchesWeightsU.y * fetchesWeightsV.x; - fetchesWeights[2] = fetchesWeightsU.z * fetchesWeightsV.x; - fetchesWeights[3] = fetchesWeightsU.w * fetchesWeightsV.x; - fetchesWeights[4] = fetchesWeightsU.x * fetchesWeightsV.y; - fetchesWeights[5] = fetchesWeightsU.y * fetchesWeightsV.y; - fetchesWeights[6] = fetchesWeightsU.z * fetchesWeightsV.y; - fetchesWeights[7] = fetchesWeightsU.w * fetchesWeightsV.y; - fetchesWeights[8] = fetchesWeightsU.x * fetchesWeightsV.z; - fetchesWeights[9] = fetchesWeightsU.y * fetchesWeightsV.z; - fetchesWeights[10] = fetchesWeightsU.z * fetchesWeightsV.z; - fetchesWeights[11] = fetchesWeightsU.w * fetchesWeightsV.z; - fetchesWeights[12] = fetchesWeightsU.x * fetchesWeightsV.w; - fetchesWeights[13] = fetchesWeightsU.y * fetchesWeightsV.w; - fetchesWeights[14] = fetchesWeightsU.z * fetchesWeightsV.w; - fetchesWeights[15] = fetchesWeightsU.w * fetchesWeightsV.w; + SampleShadow_ComputeSamples_Tent_Filter_7x7(real, shadowMapTexture_TexelSize, coord, fetchesWeights, fetchesUV); } #endif diff --git a/Packages/com.unity.render-pipelines.core/Tests/Editor/GPUDriven/GPUDrivenRenderingTests.cs b/Packages/com.unity.render-pipelines.core/Tests/Editor/GPUDriven/GPUDrivenRenderingTests.cs index 8cbefad9..15002f73 100644 --- a/Packages/com.unity.render-pipelines.core/Tests/Editor/GPUDriven/GPUDrivenRenderingTests.cs +++ b/Packages/com.unity.render-pipelines.core/Tests/Editor/GPUDriven/GPUDrivenRenderingTests.cs @@ -137,7 +137,7 @@ namespace UnityEngine.Rendering.Tests Assert.IsTrue(brg.instanceCullingBatcher.GetDrawInstanceData().drawInstances.Length == 3); brgContext.ScheduleQueryRendererGroupInstancesJob(objIDs.AsArray(), instances).Complete(); - brg.DestroyInstances(instances); + brg.DestroyDrawInstances(instances); Assert.IsTrue(brg.instanceCullingBatcher.GetDrawInstanceData().drawInstances.Length == 0); } @@ -234,7 +234,7 @@ namespace UnityEngine.Rendering.Tests GameObject.DestroyImmediate(cameraObject); brgContext.ScheduleQueryRendererGroupInstancesJob(objIDs.AsArray(), instances).Complete(); - brg.DestroyInstances(instances); + brg.DestroyDrawInstances(instances); } } @@ -300,7 +300,7 @@ namespace UnityEngine.Rendering.Tests GameObject.DestroyImmediate(cameraObject); brgContext.ScheduleQueryRendererGroupInstancesJob(objIDs, instances).Complete(); - brg.DestroyInstances(instances); + brg.DestroyDrawInstances(instances); } } @@ -381,7 +381,7 @@ namespace UnityEngine.Rendering.Tests GameObject.DestroyImmediate(cameraObject); brgContext.ScheduleQueryRendererGroupInstancesJob(objIDs.AsArray(), instances).Complete(); - brg.DestroyInstances(instances); + brg.DestroyDrawInstances(instances); } } @@ -532,7 +532,7 @@ namespace UnityEngine.Rendering.Tests GameObject.DestroyImmediate(cameraObject); brgContext.ScheduleQueryRendererGroupInstancesJob(objIDs.AsArray(), instances).Complete(); - brg.DestroyInstances(instances); + brg.DestroyDrawInstances(instances); } } @@ -688,7 +688,7 @@ namespace UnityEngine.Rendering.Tests GameObject.DestroyImmediate(cameraObject); brgContext.ScheduleQueryRendererGroupInstancesJob(objIDs.AsArray(), instances).Complete(); - brg.DestroyInstances(instances); + brg.DestroyDrawInstances(instances); } } @@ -805,7 +805,7 @@ namespace UnityEngine.Rendering.Tests GameObject.DestroyImmediate(cameraObject); brgContext.ScheduleQueryRendererGroupInstancesJob(objIDs.AsArray(), instances).Complete(); - brg.DestroyInstances(instances); + brg.DestroyDrawInstances(instances); } } @@ -1148,7 +1148,7 @@ namespace UnityEngine.Rendering.Tests { Assert.IsTrue(rendererData.rendererGroupID.Length == 2); dispatched = true; - }); + }, true); Assert.IsTrue(dispatched); @@ -1162,7 +1162,7 @@ namespace UnityEngine.Rendering.Tests Assert.IsTrue(rendererData.invalidRendererGroupID.Length == 1); Assert.IsTrue(rendererData.invalidRendererGroupID[0] == renderer0.GetInstanceID()); dispatched = true; - }); + }, true); Assert.IsTrue(dispatched); @@ -1173,7 +1173,7 @@ namespace UnityEngine.Rendering.Tests { Assert.IsTrue(rendererData.invalidRendererGroupID.Length == 2); dispatched = true; - }); + }, true); Assert.IsTrue(dispatched); @@ -1217,9 +1217,13 @@ namespace UnityEngine.Rendering.Tests gpuDrivenProcessor.EnableGPUDrivenRenderingAndDispatchRendererData(rendererIDs, (in GPUDrivenRendererGroupData rendererData, IList meshes, IList materials) => { + Assert.IsTrue(rendererData.localBounds.Length == 0); + Assert.IsTrue(rendererData.localToWorldMatrix.Length == 0); + Assert.IsTrue(rendererData.prevLocalToWorldMatrix.Length == 0); + Assert.IsTrue(rendererData.lodGroupID.Length == 0); Assert.IsTrue(rendererData.rendererGroupID.Length == 4); dispatched = true; - }); + }, true); Assert.IsTrue(dispatched); @@ -1233,7 +1237,7 @@ namespace UnityEngine.Rendering.Tests { Assert.IsTrue(rendererData.rendererGroupID.Length == 1); dispatched = true; - }); + }, true); Assert.IsTrue(dispatched); @@ -1275,7 +1279,7 @@ namespace UnityEngine.Rendering.Tests { Assert.IsTrue(rendererData.rendererGroupID.Length == 1); dispatched = true; - }); + }, true); Assert.IsTrue(dispatched); diff --git a/Packages/com.unity.render-pipelines.core/Tests/Editor/RenderGraphViewerTests.cs b/Packages/com.unity.render-pipelines.core/Tests/Editor/RenderGraphViewerTests.cs index 1ee84a66..ecfa37ce 100644 --- a/Packages/com.unity.render-pipelines.core/Tests/Editor/RenderGraphViewerTests.cs +++ b/Packages/com.unity.render-pipelines.core/Tests/Editor/RenderGraphViewerTests.cs @@ -25,7 +25,7 @@ namespace UnityEditor.Rendering.Tests // Script in project ( "Assets/File.cs", "Assets/File.cs" ), - // Script in package (this will work regardless of where the package is located, + // Script in package (this will work regardless of where the package is located, // i.e. in Library, embedded in Packages folder, via "file:" dependency or Git URL) ( $"{relativePackagePath}/File.cs".Replace(@"\", "/"), $"{packageInfo.assetPath}/File.cs" ), @@ -52,7 +52,7 @@ namespace UnityEditor.Rendering.Tests yield return new TestCaseData($"./{inputPath}".Replace("/", @"\"), expectedResult); // Absolute paths, Windows separators - yield return new TestCaseData($"{projectPath}/{inputPath}".Replace("/", @"\"), expectedResult); + yield return new TestCaseData($"{projectPath}/{inputPath}".Replace("/", @"\"), expectedResult); #endif } } diff --git a/Packages/com.unity.render-pipelines.core/package.json b/Packages/com.unity.render-pipelines.core/package.json index c6b3df68..95eb1599 100644 --- a/Packages/com.unity.render-pipelines.core/package.json +++ b/Packages/com.unity.render-pipelines.core/package.json @@ -1,7 +1,7 @@ { "name": "com.unity.render-pipelines.core", "description": "SRP Core makes it easier to create or customize a Scriptable Render Pipeline (SRP). SRP Core contains reusable code, including boilerplate code for working with platform-specific graphics APIs, utility functions for common rendering operations, and shader libraries. The code in SRP Core is use by the High Definition Render Pipeline (HDRP) and Universal Render Pipeline (URP). If you are creating a custom SRP from scratch or customizing a prebuilt SRP, using SRP Core will save you time.", - "version": "17.0.3", + "version": "17.0.4", "unity": "6000.0", "displayName": "Core RP Library", "dependencies": { @@ -14,5 +14,5 @@ "com.unity.modules.jsonserialize": "1.0.0", "com.unity.rendering.light-transport": "1.0.1" }, - "_fingerprint": "668d69e61fc4f03c821b6a3e669d05e3cf380460" + "_fingerprint": "481f548ebf36dd66c48f9774f47850ae22390918" } diff --git a/Packages/com.unity.render-pipelines.high-definition-config/CHANGELOG.md b/Packages/com.unity.render-pipelines.high-definition-config/CHANGELOG.md index 5f061ba7..0e324f92 100644 --- a/Packages/com.unity.render-pipelines.high-definition-config/CHANGELOG.md +++ b/Packages/com.unity.render-pipelines.high-definition-config/CHANGELOG.md @@ -10,6 +10,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. Version Updated The version number for this package has increased due to a version update of a related graphics package. +## [17.0.3] - 2025-02-13 + +This version is compatible with Unity 6000.0.39f1. + +Version Updated +The version number for this package has increased due to a version update of a related graphics package. + ## [17.0.2] - 2024-04-02 This version is compatible with Unity 6000.0.0b15. diff --git a/Packages/com.unity.render-pipelines.high-definition-config/package.json b/Packages/com.unity.render-pipelines.high-definition-config/package.json index f085a777..c931e037 100644 --- a/Packages/com.unity.render-pipelines.high-definition-config/package.json +++ b/Packages/com.unity.render-pipelines.high-definition-config/package.json @@ -1,11 +1,11 @@ { "name": "com.unity.render-pipelines.high-definition-config", "description": "Configuration files for the High Definition Render Pipeline.", - "version": "17.0.3", + "version": "17.0.4", "unity": "6000.0", "displayName": "High Definition RP Config", "dependencies": { - "com.unity.render-pipelines.core": "17.0.3" + "com.unity.render-pipelines.core": "17.0.4" }, - "_fingerprint": "d45858853e614916d0e96df55a30b8c69d642992" + "_fingerprint": "88d6678364c971316dc9885a738d3462b1306ad0" } diff --git a/Packages/com.unity.render-pipelines.high-definition/CHANGELOG.md b/Packages/com.unity.render-pipelines.high-definition/CHANGELOG.md index 50c15881..206189f8 100644 --- a/Packages/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/Packages/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -10,6 +10,126 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. Version Updated The version number for this package has increased due to a version update of a related graphics package. +## [17.0.3] - 2025-02-13 + +This version is compatible with Unity 6000.0.39f1. + +### Changed +- Added SG custom refraction example to Transparency sample. +- Added environment samples showcasing environment effects together. +- Optimised the water vertex shader. +- Improved decal region resolution on non-infinite surfaces. +- Reduced memory usage when foam is disabled. +- Improved the batching of the Lit shaders in HDRP. +- Allow using Solid Angle Culling Mode in Ray Tracing Settings volume override. This ray tracing culling mode rejects objects that are small enough or that are far away from the camera position based on their projected solid angle. These will not be added to the ray tracing acceleration structure. +- Added the option to compose hair before color pyramid but after clouds. +- Added a slider to High Quality Line Rendering Volume Component to specify when to omit depth and motion vector write if alpha is too low. +- Simplified the list of validations for `IRenderPipelineGraphicsSettings`. +- Improved water sample by adding a cave scene using caustics and deformation texture. + +### Fixed +- Added framesettings to render volumetric clouds in half resolution to reduce jittering. +- Fixed invalid AABB errors for some projects. +- Fixed an issuse with viewport flickering when multi-frame rendering API is used with certain parameters. +- Optimized water foam reprojection when it's unused. +- Fixed `materialValidatorDebugModeEnumIndex` so that it does not get stuck in the Rendering Debugger when enabling another mode. +- Fixed a corruption issue when using a non square atlas and improve blit performance. +- Improved the Rendering Debugger to allow changing the mat cap values. +- Added a shortcut to modify the Advanced properties within the Water System Inspector: +- Fixed inconsistent text capitalizations in various parts of the Editor. +- Fixed reflection probe baking exception when fog multiple scattering is enabled in certain conditions. +- Fixed a potentially deadlocking StageRasterBin kernel in Hair system. +- Fixed Alpha missing from HQ line rendering. +- Fixed an icons used by the HDRP wizard issue. +- Fixed shader warnings from TAA shader on Metal. +- Fixed format error in public documentation. +- Fixed an issue where the default terrain shader for HDRP was outputting incorrect albedo values to the lightmapper. +- Fixed missing API to sync clouds over network. +- Fixed issue when directional light dimmer is set to 0. +- Fixed eye dropper not showing on the PBR sky inspector. +- XRMultipass - RenderPipelineManager.beginCameraRendering and RenderPipelineManager.endCameraRendering was called 1 time for each pass instead of 1 time for each camera. +- Fixed static lighting sky used when baking multiple scenes. +- Fixed artefacts on borders between volumetric clouds and geometry. +- Fixed perceptual blending option on volumetric clouds. +- Fixed graphical issue when resizing Reflection Probe sizes on macOS. +- Fixed an issue where Terrains with 4 layers or less displayed a checker texture when using debug views. +- Fixed volumetric fog samples broken link. +- Fixed material samples broken link. +- Fixed a crash when creating renderers in a Custom Pass (HDRP). +- Fixed volumetric fog reprojection buffers allocated even if the denoising mode is not set to Reprojection. +- Fixed world space UI not outputting motion vectors. +- Fixed an out of range exception in HDRP when reaching the max amount of shadows on screen. +- Fixed a crash in HDRP when reaching the max amount of shadows on screen. +- Fixed lens flare screen space and bloom frame settings confusion. +- Fixed range remap for decal materials. +- Fixed water mask applied before deformation. +- Fixed error when drawing water excluder gizmo. +- Cull water decals based on distance to camera. +- Fixed water decals not affecting simulation mask. +- Fixed foam and deformation using separate regions. +- Fixed deformation offset when water surface is rotated. +- Fixed water decal gizmo when scale is non uniform. +- Fixed decals not updated in atlas when ShaderGraph is saved. +- Changed `ProbeSettings.cubeResolution` field from internal to public. +- Fixed time of day script in environement sample. +- Fixed light culling for raytracing. +- Fixed a disc area light calculation used for light unit conversion, which was previously incorrect by a factor of Pi. +- Fixed clouds rendering on top of geometry. +- Fixed clouds interaction with thin geometry. +- Allowed TAAU, CAS, and STP to execute after the DoF or after all the post-processes like the other advanced upsamplers. +- Fixed broken link in fullscreen samples. +- Fixed missing UNITY_MATRIX_IT_MV define in HDRP shaders. +- Fixed an issue where UI images using render textures would not render properly with HDR enabled. +- Fixed an issue where reimporting ShaderGraph trigged a UnityVCS/Perfoce local checkout. +- Fixed SSMS slider not showing when volumetric fog was disabled. +- Fixed offscreen UI rendering when HDR is enabled. +- Set the 'Maximum Shadows on Screen' limit to 65536 in order not to exceed the maximum size of the buffer. +- Fixed an issue that caused the Disable Color Tint setting in a shader graph to have no effect. +- Fixed TAA Contrast Adaptive Sharpening when no upsampling was enabled. +- Fixed an issue with EndCameraRendering being called before renderContext submission. +- Fixed depth issues that occurred during transparent object rendering when dynamic scaling was used with fractional values. +- Fixed an issue to push the correct cascade shadow matrix for each cascade. +- Fixed an issue so light intensity now correctly increases when 'Lux at Distance' increases and vice versa. +- Fixed depth of field blocky artifacts when using a high blur radius. +- Fixed some depth of field jittering with objects in the near field and TAA enabled. +- PBR depth of field now has a bokeh shape that corresponds better to the aperture settings of the camera. +- Fixed an issue where alpha clamping to BloomPrefilter.compute was missing. +- Fixed volumetric cloud clipping through geometry. +- Fixed an issue where HDProbes created depth resources that were never used, leading to unnecessary GPU memory usage. +- Fixed an issue where HDRP CustomPass created an unnecessary color resource, leading to unnecessary GPU memory usage. +- Fixed a sun flicker where the sun is close to cloud boundaries. +- Fixed an issue where cascade shadows and distance shadowmask were not blended properly. +- Updated HDRP to use the new TextureDesc field format instead of colorFormat and depthBufferBits to avoid a performance regression and subtle issues. +- Fixed distortion in Unlit Shader Graph. +- Fixed the artifact of non-physical DOF if it's used with TAA and dynamic resolution; The artifacts appear for a frame after the screen resolution changes. +- Fixed UI overflow and stencil based effects not working in HDRP. +- Fixed uninitalized/unused shader warnings. +- Fixed `WorldLightManager.Collect` so it no longer has poor performance when a large amount of GameObjects are present in the scene. +- Fixed an issue that would cause volumetric shadow clipping issues in some camera angles. +- Fixed the option to edit advanced upsampling that aren't visible on platforms when they're not supported. +- Ensure custom post-processing effects are disabled when post-processing is disabled. +- Ignore material variants with log message. +- Fixed HairVertex instancing-related shader-compilation issues. +- Fixed cloud layers not being drawn behind transparent refractive objects. +- Fixed an issue that caused HDAdditionalLightData with preserveCachedShadow to be evicted from the cachedShadowManager. +- Fixed an issue with shader error when using water excluder with entities. +- Fixed to avoid calling the Cleanup method twice so the celestial data remains. +- Fixed errors when building XR player with Water System enabled. +- Removed 'Setting MRTs without a depth buffer is not supported' error in Volumetric Clouds Combine pass. +- Fixed an issue by adding clamp to HairAngleWorld to prevent nan from FastASin. +- Fixed layer index out of range in LayeredLitGUI. +- Fixed HDRP wizard to not show FixAll button anymore when no automated fix is available. +- Fixes the bug where DebugDisplay Camera list grew beyond number of active cameras, every time a camera was registered or unregistered. +- Fixed black line artifacts on top of the screen with DRS and downsampled SSAO +- Fixed invalid global state pushed when using override camera rendering in the CustomPassUtils functions. +- Fixed an issue that caused an inability to change the Shadow Map resolution for HDAdditionalLightData with preserveCachedShadow. +- Fixed HDRP sky rendering when Camera Relative Rendering is disabled. +- High Definition Render Pipeline's Wizard will no longer assume a check fail while waiting a reply from the Package Manager and will display a specific pending icon. +- Fixed wrong SSR when using a shader graph with a clear coat value of 0. +- Fixed artifacts when blending cascade shadows and distance shadowmask. +- Fixed an issue by adding a condition to the Receiver Motion Rejection function(feature) to check that the pixel has actually moved. +- Fixed an issue where the padding in the Lighting window was different between tabs. + ## [17.0.2] - 2024-04-02 This version is compatible with Unity 6000.0.0b15. diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Compositor/CompositorWindow.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Compositor/CompositorWindow.cs index 68bd33e3..adc52560 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Compositor/CompositorWindow.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Compositor/CompositorWindow.cs @@ -7,7 +7,7 @@ using UnityEngine.Rendering.HighDefinition.Compositor; namespace UnityEditor.Rendering.HighDefinition.Compositor { - [HDRPHelpURLAttribute("Compositor-User-Guide")] + [HDRPHelpURLAttribute("understand-the-graphics-compositor")] internal class CompositorWindow : EditorWindowWithHelpButton { static class Styles diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDScreenSpaceReflectionEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDScreenSpaceReflectionEditor.cs index 06809f17..d2d32589 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDScreenSpaceReflectionEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDScreenSpaceReflectionEditor.cs @@ -188,7 +188,7 @@ namespace UnityEditor.Rendering.HighDefinition { HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset; - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing, "RayTracing"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing); if (RenderPipelineManager.currentPipeline is not HDRenderPipeline { rayTracingSupported: true }) HDRenderPipelineUI.DisplayRayTracingSupportBox(); @@ -261,7 +261,7 @@ namespace UnityEditor.Rendering.HighDefinition PropertyField(m_Enable, k_EnabledOpaque); if (!notSupported) - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.SSR, "Screen Space Reflection"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.SSR); bool transparentSSRSupported = currentAsset.currentPlatformRenderPipelineSettings.supportSSR && currentAsset.currentPlatformRenderPipelineSettings.supportSSRTransparent @@ -269,7 +269,7 @@ namespace UnityEditor.Rendering.HighDefinition if (transparentSSRSupported) { PropertyField(m_EnableTransparent, k_EnabledTransparent); - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.TransparentSSR, "Transparent"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.TransparentSSR); } else { diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/ScreenSpaceRefractionEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/ScreenSpaceRefractionEditor.cs index 65682667..1764e5b5 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/ScreenSpaceRefractionEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/ScreenSpaceRefractionEditor.cs @@ -17,7 +17,7 @@ namespace UnityEditor.Rendering.HighDefinition public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Refraction, "Refraction"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Refraction); PropertyField(m_ScreenFadeDistance, k_ScreenFadeDistance); } diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/ScreenSpaceAmbientOcclusionEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/ScreenSpaceAmbientOcclusionEditor.cs index 1d6326ee..1167d5e3 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/ScreenSpaceAmbientOcclusionEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/ScreenSpaceAmbientOcclusionEditor.cs @@ -122,7 +122,7 @@ namespace UnityEditor.Rendering.HighDefinition public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.SSAO, "Screen Space Ambient Occlusion"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.SSAO); HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset; bool notSupported = currentAsset != null && !currentAsset.currentPlatformRenderPipelineSettings.supportSSAO; if (notSupported) @@ -139,7 +139,7 @@ namespace UnityEditor.Rendering.HighDefinition if (m_RayTracing.overrideState.boolValue && m_RayTracing.value.boolValue) { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing, "RayTracing"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing); // If ray tracing is supported display the content of the volume component if (RenderPipelineManager.currentPipeline is not HDRenderPipeline { rayTracingSupported: true }) HDRenderPipelineUI.DisplayRayTracingSupportBox(); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/ContactShadowsEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/ContactShadowsEditor.cs index c18e5fd0..aca2b43d 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/ContactShadowsEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/ContactShadowsEditor.cs @@ -40,7 +40,7 @@ namespace UnityEditor.Rendering.HighDefinition public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.ContactShadows, "Contact Shadows"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.ContactShadows); PropertyField(m_Enable, EditorGUIUtility.TrTextContent("State", "When enabled, HDRP processes Contact Shadows for this Volume.")); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/HDShadowSettingsEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/HDShadowSettingsEditor.cs index 25f96f97..68d02832 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/HDShadowSettingsEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/HDShadowSettingsEditor.cs @@ -45,7 +45,7 @@ namespace UnityEditor.Rendering.HighDefinition public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.ShadowMaps, "Shadow Maps"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.ShadowMaps); PropertyField(m_MaxShadowDistance, EditorGUIUtility.TrTextContent("Max Distance", "In Meter")); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/VolumetricClouds/VolumetricCloudsEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/VolumetricClouds/VolumetricCloudsEditor.cs index b7d9ba1d..9dd5d931 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/VolumetricClouds/VolumetricCloudsEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/VolumetricClouds/VolumetricCloudsEditor.cs @@ -523,7 +523,7 @@ namespace UnityEditor.Rendering.HighDefinition PropertyField(m_Enable, EditorGUIUtility.TrTextContent("State")); if (m_Enable.value.boolValue && !notSupported) - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.VolumetricClouds, "Volumetric Clouds"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.VolumetricClouds); EditorGUILayout.Space(); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/BloomEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/BloomEditor.cs index a6bff21b..0c580275 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/BloomEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/BloomEditor.cs @@ -39,7 +39,7 @@ namespace UnityEditor.Rendering.HighDefinition public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Bloom, "Bloom"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Bloom); base.OnInspectorGUI(); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ChromaticAberrationEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ChromaticAberrationEditor.cs index eb057b82..f5ec8755 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ChromaticAberrationEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ChromaticAberrationEditor.cs @@ -24,7 +24,7 @@ namespace UnityEditor.Rendering.HighDefinition public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.ChromaticAberration, "Chromatic Aberration"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.ChromaticAberration); PropertyField(m_SpectralLUT); PropertyField(m_Intensity); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/DepthOfFieldEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/DepthOfFieldEditor.cs index 1e8d19c6..31654108 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/DepthOfFieldEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/DepthOfFieldEditor.cs @@ -86,7 +86,7 @@ namespace UnityEditor.Rendering.HighDefinition public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.DepthOfField, "Depth Of Field"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.DepthOfField); PropertyField(m_FocusMode, Styles.k_DepthOfFieldMode); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/FilmGrainEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/FilmGrainEditor.cs index d54b478d..edeec55e 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/FilmGrainEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/FilmGrainEditor.cs @@ -24,7 +24,7 @@ namespace UnityEditor.Rendering.HighDefinition public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.FilmGrain, "Film Grain"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.FilmGrain); PropertyField(m_Type); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/MotionBlurEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/MotionBlurEditor.cs index 648275af..b7cc830d 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/MotionBlurEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/MotionBlurEditor.cs @@ -41,7 +41,7 @@ namespace UnityEditor.Rendering.HighDefinition public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.MotionBlur, "Motion Blur"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.MotionBlur); PropertyField(m_Intensity); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/PaniniProjectionEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/PaniniProjectionEditor.cs index 85f32a97..4424309d 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/PaniniProjectionEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/PaniniProjectionEditor.cs @@ -22,7 +22,7 @@ namespace UnityEditor.Rendering.HighDefinition public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.PaniniProjection, "Panini Projection"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.PaniniProjection); PropertyField(m_Distance); PropertyField(m_CropToFit); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ScreenSpaceLensFlareEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ScreenSpaceLensFlareEditor.cs index 141cccf6..e7b9023d 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ScreenSpaceLensFlareEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ScreenSpaceLensFlareEditor.cs @@ -78,18 +78,9 @@ namespace UnityEditor.Rendering.HighDefinition public override void OnInspectorGUI() { - // We loop through each camera and displaying a message if there's any bloom intensity = 0 preventing lens flare to render. - foreach (HDCamera hdCamera in HDEditorUtils.GetAllCameras()) - { - var bloomComponent = hdCamera.volumeStack.GetComponent(); - if (bloomComponent != null && !bloomComponent.IsActive()) - { - EditorGUILayout.HelpBox("One or more Bloom override has an intensity set to 0. This prevents Screen Space Lens Flare to render.", MessageType.Warning); - break; - } - } - - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.LensFlareScreenSpace, "Screen Space Lens Flare"); + // We loop through each camera and displaying a message if there's any bloom intensity = 0 preventing lens flare to render. + HDEditorUtils.EnsureVolume((Bloom bloom) => !bloom.IsActive() ? "One or more Bloom override has an intensity set to 0. This prevents Screen Space Lens Flare to render." : null); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.LensFlareScreenSpace); if (!HDRenderPipeline.currentAsset?.currentPlatformRenderPipelineSettings.supportScreenSpaceLensFlare ?? false) { diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/TonemappingEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/TonemappingEditor.cs index 6ce8e473..8ca9b7c0 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/TonemappingEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/TonemappingEditor.cs @@ -85,7 +85,7 @@ namespace UnityEditor.Rendering.HighDefinition public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Tonemapping, "Tonemapping"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Tonemapping); bool hdrInPlayerSettings = UnityEditor.PlayerSettings.allowHDRDisplaySupport; diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/VignetteEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/VignetteEditor.cs index eac7d7e3..970dd53f 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/VignetteEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/VignetteEditor.cs @@ -39,7 +39,7 @@ namespace UnityEditor.Rendering.HighDefinition public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Vignette, "Vignette"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Vignette); PropertyField(m_Mode); PropertyField(m_Color); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs index 9d31cc4b..348d8273 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs @@ -8,7 +8,7 @@ namespace UnityEditor.Rendering.HighDefinition static partial class HDCameraUI { /// Enum to store know the expanded state of a expandable section on the camera inspector - [HDRPHelpURL("HDRP-Camera")] + [HDRPHelpURL("hdrp-camera-component-reference")] public enum Expandable { /// Projection diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDEditorUtils.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDEditorUtils.cs index 9d2f7122..d0162da1 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDEditorUtils.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDEditorUtils.cs @@ -321,7 +321,7 @@ namespace UnityEditor.Rendering.HighDefinition return false; } - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.LensFlareDataDriven, "Lens Flare Data Driven"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.LensFlareDataDriven); return true; } @@ -336,76 +336,76 @@ namespace UnityEditor.Rendering.HighDefinition } } - static void HighlightInDebugger(HDCamera hdCamera, FrameSettingsField field, string displayName) + static void HighlightInDebugger(Camera camera, FrameSettingsField field, string displayName) { - OpenRenderingDebugger(hdCamera.camera.name); + OpenRenderingDebugger(camera.name); // Doesn't work for some reason //CoreEditorUtils.Highlight("Rendering Debugger", displayName, HighlightSearchMode.Auto); //GUIUtility.ExitGUI(); } - internal static void FrameSettingsHelpBox(HDCamera hdCamera, FrameSettingsField field, string displayName) + static IEnumerable GetAllCameras() { - var data = HDUtils.TryGetAdditionalCameraDataOrDefault(hdCamera.camera); - var defaults = GraphicsSettings.GetRenderPipelineSettings().GetDefaultFrameSettings(FrameSettingsRenderType.Camera); - - var type = MessageType.Warning; - var attribute = FrameSettingsExtractedDatas.GetFieldAttribute(field); - - bool disabledInGlobal = !defaults.IsEnabled(field); - bool disabledByCamera = data.renderingPathCustomFrameSettingsOverrideMask.mask[(uint)field] && - !data.renderingPathCustomFrameSettings.IsEnabled(field); - bool disabledByDependency = !attribute.dependencies.All(hdCamera.frameSettings.IsEnabled); - - var historyContainer = hdCamera.camera.cameraType == CameraType.SceneView - ? FrameSettingsHistory.sceneViewFrameSettingsContainer - : HDUtils.TryGetAdditionalCameraDataOrDefault(hdCamera.camera); - bool disabledByDebug = FrameSettingsHistory.enabled && !historyContainer.frameSettingsHistory.debug.IsEnabled(field) && historyContainer.frameSettingsHistory.sanitazed.IsEnabled(field); - - var textBase = $"The FrameSetting required to render this effect in the {(hdCamera.camera.cameraType == CameraType.SceneView ? "Scene" : "Game")} view "; - - if (disabledByDebug) - CoreEditorUtils.DrawFixMeBox(textBase + "is disabled in the Rendering Debugger.", type, "Open", () => HighlightInDebugger(hdCamera, field, displayName)); - else if (disabledByCamera) - CoreEditorUtils.DrawFixMeBox(textBase + "is disabled on a Camera.", type, "Open", () => EditorUtility.OpenPropertyEditor(hdCamera.camera)); - else if (disabledInGlobal) - GlobalSettingsHelpBox(textBase + "is disabled in the HDRP Global Settings.", type, field, displayName); - else if (disabledByDependency) - GlobalSettingsHelpBox(textBase + "depends on a disabled FrameSetting.", type, field, displayName); + foreach (SceneView sceneView in SceneView.sceneViews) + yield return sceneView.camera; + foreach (Camera camera in Camera.allCameras) + if (camera.cameraType == CameraType.Game) + yield return camera; } - - internal static HDCamera[] GetAllCameras() + + static IEnumerable<(Camera camera, FrameSettings @default, IFrameSettingsHistoryContainer historyContainer)> SelectFrameSettingsStages(IEnumerable cameras) { - HashSet cameras = new(); + var supportedFeatures = HDRenderPipeline.currentAsset.currentPlatformRenderPipelineSettings; + var defaultSettings = GraphicsSettings.GetRenderPipelineSettings().GetDefaultFrameSettings(FrameSettingsRenderType.Camera); - // Looping through all the scene views - foreach (SceneView sceneView in SceneView.sceneViews) + foreach (var camera in cameras) { - if (!sceneView.hasFocus) continue; - cameras.Add(HDCamera.GetOrCreate(sceneView.camera)); + var additionalCameraData = HDUtils.TryGetAdditionalCameraDataOrDefault(camera); + var historyContainer = camera.cameraType == CameraType.SceneView ? FrameSettingsHistory.sceneViewFrameSettingsContainer : additionalCameraData; + + FrameSettings dummy = default; + FrameSettingsHistory.AggregateFrameSettings(ref dummy, camera, historyContainer, ref defaultSettings, supportedFeatures); + yield return (camera, defaultSettings, historyContainer); } + } + + static void FrameSettingsHelpBox(Camera camera, FrameSettingsField field, FrameSettings @default, IFrameSettingsHistoryContainer historyContainer) + { + FrameSettingsHistory history = historyContainer.frameSettingsHistory; + bool finalValue = history.debug.IsEnabled(field); + if (finalValue) return; //must be false to call this method - // Looping through all the game views - foreach (var camera in HDCamera.GetHDCameras()) - { - if (camera == null || camera.camera == null) - continue; + bool defaultValue = @default.IsEnabled(field); + bool cameraOverrideState = historyContainer.hasCustomFrameSettings && history.customMask.mask[(uint)field]; + bool cameraOverridenValue = history.overridden.IsEnabled(field); + bool cameraSanitizedValue = history.sanitazed.IsEnabled(field); - if (camera.camera.cameraType == CameraType.Game) - cameras.Add(camera); - } + var attribute = FrameSettingsExtractedDatas.GetFieldAttribute(field); + bool dependenciesSanitizedValueOk = attribute.dependencies.All(fs => attribute.IsNegativeDependency(fs) ? !history.sanitazed.IsEnabled(fs) : history.sanitazed.IsEnabled(fs)); + + bool disabledByDefault = !defaultValue && !cameraOverrideState; + bool disabledByCameraOverride = cameraOverrideState && !cameraOverridenValue; - return cameras.ToArray(); + var textBase = $"The FrameSetting required to render this effect in the {(camera.cameraType == CameraType.SceneView ? "Scene" : "Game")} view (by {camera.name}) "; + + if (disabledByDefault) + GlobalSettingsHelpBox(textBase + "is disabled in the HDRP Global Settings.", MessageType.Warning, field, attribute.displayedName); + else if (disabledByCameraOverride) + CoreEditorUtils.DrawFixMeBox(textBase + $"is disabled on the Camera.", MessageType.Warning, "Open", () => EditorUtility.OpenPropertyEditor(camera)); + else if (!dependenciesSanitizedValueOk) + GlobalSettingsHelpBox(textBase + "depends on a disabled FrameSetting.", MessageType.Warning, field, attribute.displayedName); + else if (!finalValue) + CoreEditorUtils.DrawFixMeBox(textBase + "is disabled in the Rendering Debugger.", MessageType.Warning, "Open", () => HighlightInDebugger(camera, field, attribute.displayedName)); } - internal static bool EnsureFrameSetting(FrameSettingsField field, string displayName) + internal static bool EnsureFrameSetting(FrameSettingsField field) { - foreach (var camera in GetAllCameras()) + foreach ((Camera camera, FrameSettings @default, IFrameSettingsHistoryContainer historyContainer) in SelectFrameSettingsStages(GetAllCameras())) { - if (!camera.frameSettings.IsEnabled(field)) + if (!historyContainer.frameSettingsHistory.debug.IsEnabled(field)) { - FrameSettingsHelpBox(camera, field, displayName); + FrameSettingsHelpBox(camera, field, @default, historyContainer); EditorGUILayout.Space(); return false; } @@ -413,31 +413,34 @@ namespace UnityEditor.Rendering.HighDefinition return true; } - - internal static bool EnsureVolumeAndFrameSetting(Func volumeValidator, FrameSettingsField field, string displayName) where T : UnityEngine.Rendering.VolumeComponent + + static IEnumerable<(Camera camera, T component)> SelectVolumeComponent(IEnumerable cameras) where T : VolumeComponent { // Wait for volume system to be initialized if (VolumeManager.instance.baseComponentTypeArray == null) - return true; - - var cameras = GetAllCameras(); + yield break; - foreach (var camera in cameras) + foreach (var camera in GetAllCameras()) { - var errorString = volumeValidator(camera.volumeStack.GetComponent()); - if (!string.IsNullOrEmpty(errorString)) - { - EditorGUILayout.HelpBox(errorString, MessageType.Warning); - EditorGUILayout.Space(); - return false; - } + if (!HDCamera.TryGet(camera, out var hdCamera)) + continue; + + T component = hdCamera.volumeStack.GetComponent(); + if (component == null) + continue; + + yield return (camera, component); } + } - foreach (var camera in cameras) + internal static bool EnsureVolume(Func volumeValidator) where T : VolumeComponent + { + foreach ((Camera camera, T component) in SelectVolumeComponent(GetAllCameras())) { - if (!camera.frameSettings.IsEnabled(field)) + var errorString = volumeValidator(component); + if (!string.IsNullOrEmpty(errorString)) { - FrameSettingsHelpBox(camera, field, displayName); + EditorGUILayout.HelpBox(errorString, MessageType.Warning); EditorGUILayout.Space(); return false; } diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/LineRendering/HDRenderPipeline.LineRendering.VolumeComponentEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/LineRendering/HDRenderPipeline.LineRendering.VolumeComponentEditor.cs index 9557052b..f7589519 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/LineRendering/HDRenderPipeline.LineRendering.VolumeComponentEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/LineRendering/HDRenderPipeline.LineRendering.VolumeComponentEditor.cs @@ -30,7 +30,7 @@ namespace UnityEditor.Rendering.HighDefinition public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.HighQualityLineRendering, "High Quality Line Rendering"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.HighQualityLineRendering); HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset; bool notSupported = currentAsset != null && !currentAsset.currentPlatformRenderPipelineSettings.supportHighQualityLineRendering; diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/PathTracing/PathTracingEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/PathTracing/PathTracingEditor.cs index d6f8e249..6dfee7b9 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/PathTracing/PathTracingEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/PathTracing/PathTracingEditor.cs @@ -58,7 +58,7 @@ namespace UnityEditor.Experimental.Rendering.HighDefinition public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing, "Path tracing"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing); HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset; bool notSupported = currentAsset != null && !currentAsset.currentPlatformRenderPipelineSettings.supportRayTracing; diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/GlobalIlluminationEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/GlobalIlluminationEditor.cs index 2a519601..12a4573e 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/GlobalIlluminationEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/GlobalIlluminationEditor.cs @@ -167,7 +167,7 @@ namespace UnityEditor.Rendering.HighDefinition public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.SSGI, "Screen Space Global Illumination"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.SSGI); HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset; bool notSupported = !currentAsset?.currentPlatformRenderPipelineSettings.supportSSGI ?? false; @@ -197,7 +197,7 @@ namespace UnityEditor.Rendering.HighDefinition { if (rayTracingSettingsDisplayed) { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing, "RayTracing"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing); if (RenderPipelineManager.currentPipeline is not HDRenderPipeline { rayTracingSupported: true }) HDRenderPipelineUI.DisplayRayTracingSupportBox(); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/LightClusterEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/LightClusterEditor.cs index 68c5333c..db48e44a 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/LightClusterEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/LightClusterEditor.cs @@ -10,7 +10,7 @@ namespace UnityEditor.Rendering.HighDefinition { public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing, "Raytracing"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing); HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset; bool notSupported = currentAsset != null && !currentAsset.currentPlatformRenderPipelineSettings.supportRayTracing; diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RayTracingSettingsEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RayTracingSettingsEditor.cs index 8538075a..1ad4ed61 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RayTracingSettingsEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RayTracingSettingsEditor.cs @@ -40,7 +40,7 @@ namespace UnityEditor.Rendering.HighDefinition public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing, "Raytracing"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing); HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset; bool notSupported = currentAsset != null && !currentAsset.currentPlatformRenderPipelineSettings.supportRayTracing; diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RecursiveRenderingEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RecursiveRenderingEditor.cs index 476e16a5..a1235987 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RecursiveRenderingEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RecursiveRenderingEditor.cs @@ -37,7 +37,7 @@ namespace UnityEditor.Experimental.Rendering.HighDefinition public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing, "Raytracing"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing); HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset; bool notSupported = currentAsset != null && !currentAsset.currentPlatformRenderPipelineSettings.supportRayTracing; diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/SubSurfaceScatteringEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/SubSurfaceScatteringEditor.cs index ce2b3974..88e690d4 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/SubSurfaceScatteringEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/SubSurfaceScatteringEditor.cs @@ -20,7 +20,7 @@ namespace UnityEditor.Rendering.HighDefinition public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing, "Raytracing"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing); HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset; bool notSupported = currentAsset != null && !currentAsset.currentPlatformRenderPipelineSettings.supportRayTracing; diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Sky/AtmosphericScattering/FogEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Sky/AtmosphericScattering/FogEditor.cs index f0ac7f77..8f4a2a82 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Sky/AtmosphericScattering/FogEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Sky/AtmosphericScattering/FogEditor.cs @@ -82,7 +82,7 @@ namespace UnityEditor.Rendering.HighDefinition public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.AtmosphericScattering, "Fog"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.AtmosphericScattering); PropertyField(m_Enabled, s_Enabled); @@ -124,7 +124,7 @@ namespace UnityEditor.Rendering.HighDefinition { PropertyField(m_EnableVolumetricFog, s_EnableVolumetricFog); - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Volumetrics, "Volumetric Fog"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Volumetrics); using (new IndentLevelScope()) { diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Sky/HDLightingWindowEnvironmentSection.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Sky/HDLightingWindowEnvironmentSection.cs index 3a38e910..64a0878a 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Sky/HDLightingWindowEnvironmentSection.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Sky/HDLightingWindowEnvironmentSection.cs @@ -8,6 +8,7 @@ using UnityEditor.SceneManagement; using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; namespace UnityEditor.Rendering.HighDefinition { @@ -16,16 +17,7 @@ namespace UnityEditor.Rendering.HighDefinition { class Styles { - public static GUIStyle headerStyle; - static Styles() - { - headerStyle = new GUIStyle(EditorStyles.foldoutHeader); - headerStyle.fontStyle = FontStyle.Bold; - headerStyle.fontSize = 12; - headerStyle.margin = new RectOffset(17, 0, 0, 0); - headerStyle.padding = new RectOffset(16, 1, 0, 0); - headerStyle.fixedHeight = 21; - } + public static readonly GUIStyle inspectorTitle = "IN Title"; } class SerializedStaticLightingSky @@ -81,6 +73,8 @@ namespace UnityEditor.Rendering.HighDefinition } } + static MethodInfo k_FoldoutTitlebar; + public override void OnEnable() { m_SerializedActiveSceneLightingSky = new SerializedStaticLightingSky(GetStaticLightingSkyForScene(EditorSceneManager.GetActiveScene())); @@ -151,35 +145,20 @@ namespace UnityEditor.Rendering.HighDefinition void DrawGUI() { - Rect mainSeparator = EditorGUILayout.GetControlRect(GUILayout.Height(1)); - mainSeparator.xMin -= 3; - mainSeparator.xMax += 4; - EditorGUI.DrawRect(mainSeparator, EditorGUIUtility.isProSkin - ? new Color32(26, 26, 26, 255) - : new Color32(127, 127, 127, 255)); - - Rect line = EditorGUILayout.GetControlRect(); - line.xMin -= 3; - line.xMax += 4; - line.y -= 2; - line.yMax += 4; + if (k_FoldoutTitlebar == null) + { + var flags = BindingFlags.NonPublic | BindingFlags.Static; + Type[] args = new Type[] { typeof(Rect), typeof(GUIContent), typeof(bool), typeof(bool) }; + k_FoldoutTitlebar = typeof(EditorGUI).GetMethod("FoldoutTitlebar", flags, null, args, null); + } - toggleValue = EditorGUI.Foldout(line, toggleValue, EditorGUIUtility.TrTextContent("Environment (HDRP)", "Sky lighting environment for active Scene"), Styles.headerStyle); + var labelRect = GUILayoutUtility.GetRect(GUIContent.none, Styles.inspectorTitle, GUILayout.ExpandWidth(true)); + var label = EditorGUIUtility.TrTextContent("Environment (HDRP)", "Sky lighting environment for active Scene"); - EditorGUI.DrawRect(line, EditorGUIUtility.isProSkin - ? new Color(1f, 1f, 1f, 0.03f) - : new Color(1f, 1f, 1f, 0.2f)); + toggleValue = (bool)k_FoldoutTitlebar.Invoke(null, new object[] { labelRect, label, toggleValue, true }); if (m_ToggleValue) { - Rect separator = EditorGUILayout.GetControlRect(GUILayout.Height(1)); - separator.xMin -= 3; - separator.xMax += 4; - separator.y -= 1; - EditorGUI.DrawRect(separator, EditorGUIUtility.isProSkin - ? new Color32(48, 48, 48, 255) - : new Color32(186, 186, 186, 255)); - ++EditorGUI.indentLevel; //cannot use SerializeProperty due to logic in the property diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/VFXGraph/Outputs/VFXDecalHDRPOutput.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/VFXGraph/Outputs/VFXDecalHDRPOutput.cs index da95e5c8..52bbfcfc 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/VFXGraph/Outputs/VFXDecalHDRPOutput.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/VFXGraph/Outputs/VFXDecalHDRPOutput.cs @@ -260,7 +260,7 @@ namespace UnityEditor.VFX.HDRP yield return "AFFECT_AMBIENT_OCCLUSION"; if (affectSmoothness) yield return "AFFECT_SMOOTHNESS"; - if (useEmissiveColor || useEmissiveMap) + if (useEmissiveColor || useEmissiveMap || (colorMode & ColorMode.Emissive) != 0) yield return "NEEDS_FORWARD_EMISSIVE_PASS"; } } diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Water/WaterRenderingEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Water/WaterRenderingEditor.cs index 46b468e3..6852e809 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Water/WaterRenderingEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Water/WaterRenderingEditor.cs @@ -33,7 +33,7 @@ namespace UnityEditor.Rendering.HighDefinition public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Water, "Water"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Water); HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset; bool notSupported = currentAsset != null && !currentAsset.currentPlatformRenderPipelineSettings.supportWater; if (notSupported) diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Water/WaterSurface/WaterSurfaceEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Water/WaterSurface/WaterSurfaceEditor.cs index c1862aa4..d1425cbf 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Water/WaterSurface/WaterSurfaceEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Water/WaterSurface/WaterSurfaceEditor.cs @@ -292,8 +292,8 @@ namespace UnityEditor.Rendering.HighDefinition return; } - Func validator = (water) => !water.enable.value ? "Water Surface Rendering is not enabled in the Volume System." : null; - HDEditorUtils.EnsureVolumeAndFrameSetting(validator, FrameSettingsField.Water, "Water"); + HDEditorUtils.EnsureVolume((WaterRendering water) => !water.enable.value ? "Water Surface Rendering is not enabled in the Volume System." : null); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Water); if (target is WaterSurface surface && surface.surfaceIndex == -1) { diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.Configuration.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.Configuration.cs index 494b89b5..94db4490 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.Configuration.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.Configuration.cs @@ -24,6 +24,13 @@ namespace UnityEditor.Rendering.HighDefinition enum QualityScope { Global, CurrentQuality } + enum Result + { + Failed, + OK, + Pending, + } + static class InclusiveScopeExtention { public static bool Contains(this InclusiveMode thisScope, InclusiveMode scope) @@ -109,14 +116,14 @@ namespace UnityEditor.Rendering.HighDefinition public readonly QualityScope scope; public readonly InclusiveMode inclusiveScope; public readonly Style.ConfigStyle configStyle; - public readonly Func check; + public readonly Func check; public readonly Action fix; public readonly int indent; public readonly bool forceDisplayCheck; public readonly bool skipErrorIcon; public readonly bool displayAssetName; - public Entry(QualityScope scope, InclusiveMode mode, Style.ConfigStyle configStyle, Func check, + public Entry(QualityScope scope, InclusiveMode mode, Style.ConfigStyle configStyle, Func check, Action fix, int indent = 0, bool forceDisplayCheck = false, bool skipErrorIcon = false, bool displayAssetName = false) { this.scope = scope; @@ -125,7 +132,21 @@ namespace UnityEditor.Rendering.HighDefinition this.check = check; this.fix = fix; this.forceDisplayCheck = forceDisplayCheck; - this.indent = mode == InclusiveMode.XRManagement ? 1 : indent; + this.indent = indent; + this.skipErrorIcon = skipErrorIcon; + this.displayAssetName = displayAssetName; + } + + public Entry(QualityScope scope, InclusiveMode mode, Style.ConfigStyle configStyle, Func check, + Action fix, int indent = 0, bool forceDisplayCheck = false, bool skipErrorIcon = false, bool displayAssetName = false) + { + this.scope = scope; + this.inclusiveScope = mode; + this.configStyle = configStyle; + this.check = () => check() ? Result.OK : Result.Failed; + this.fix = fix; + this.forceDisplayCheck = forceDisplayCheck; + this.indent = indent; this.skipErrorIcon = skipErrorIcon; this.displayAssetName = displayAssetName; } @@ -177,8 +198,8 @@ namespace UnityEditor.Rendering.HighDefinition new Entry(QualityScope.Global, InclusiveMode.HDRP, Style.hdrpShadowmask, IsShadowmaskCorrect, FixShadowmask), new Entry(QualityScope.Global, InclusiveMode.HDRP, Style.hdrpMigratableAssets, IsMigratableAssetsCorrect, FixMigratableAssets), new Entry(QualityScope.Global, InclusiveMode.VR, Style.vrXRManagementPackage, IsVRXRManagementPackageInstalledCorrect, FixVRXRManagementPackageInstalled), - new Entry(QualityScope.Global, InclusiveMode.XRManagement, Style.vrOculusPlugin, () => false, null), - new Entry(QualityScope.Global, InclusiveMode.XRManagement, Style.vrSinglePassInstancing, () => false, null), + new Entry(QualityScope.Global, InclusiveMode.XRManagement, Style.vrOculusPlugin, () => false, null, indent: 1), + new Entry(QualityScope.Global, InclusiveMode.XRManagement, Style.vrSinglePassInstancing, () => false, null, indent: 1), new Entry(QualityScope.Global, InclusiveMode.VR, Style.vrLegacyHelpersPackage, IsVRLegacyHelpersCorrect, FixVRLegacyHelpers), new Entry(QualityScope.CurrentQuality, InclusiveMode.HDRP, Style.hdrpAssetQualityAssigned, IsHdrpAssetQualityUsedCorrect, FixHdrpAssetQualityUsed), new Entry(QualityScope.CurrentQuality, InclusiveMode.HDRP, Style.hdrpBatcher, IsSRPBatcherCorrect, FixSRPBatcher), @@ -255,7 +276,7 @@ namespace UnityEditor.Rendering.HighDefinition { if (!scope.Contains(e.inclusiveScope) || e.check == null || e.fix == null) continue; - if (!e.check()) + if (e.check() == Result.Failed) return false; } @@ -272,7 +293,7 @@ namespace UnityEditor.Rendering.HighDefinition m_Fixer.Add(() => { - if (!e.check()) + if (e.check() == Result.Failed) e.fix(true); }); } @@ -621,13 +642,14 @@ namespace UnityEditor.Rendering.HighDefinition #region HDRP_VR_FIXES - bool vrXRManagementInstalledCheck = false; - bool IsVRXRManagementPackageInstalledCorrect() + Result m_vrXRManagementInstalledCheck = Result.Pending; + Result IsVRXRManagementPackageInstalledCorrect() => m_vrXRManagementInstalledCheck; + void UpdateVRXRManagementInstalledCheck() { + m_vrXRManagementInstalledCheck = Result.Pending; m_UsedPackageRetriever.ProcessAsync( k_XRanagementPackageName, - (installed, info) => vrXRManagementInstalledCheck = installed); - return vrXRManagementInstalledCheck; + (installed, info) => m_vrXRManagementInstalledCheck = installed ? Result.OK : Result.Failed); } void FixVRXRManagementPackageInstalled(bool fromAsync) @@ -637,13 +659,14 @@ namespace UnityEditor.Rendering.HighDefinition m_PackageInstaller.ProcessAsync(k_XRanagementPackageName, null); } - bool vrLegacyHelpersInstalledCheck = false; - bool IsVRLegacyHelpersCorrect() + Result m_vrLegacyHelpersInstalledCheck = Result.Pending; + Result IsVRLegacyHelpersCorrect() => m_vrLegacyHelpersInstalledCheck; + void UpdateVRLegacyHelpersInstalledCheck() { + m_vrLegacyHelpersInstalledCheck = Result.Pending; m_UsedPackageRetriever.ProcessAsync( k_LegacyInputHelpersPackageName, - (installed, info) => vrLegacyHelpersInstalledCheck = installed); - return vrLegacyHelpersInstalledCheck; + (installed, info) => m_vrLegacyHelpersInstalledCheck = installed ? Result.OK : Result.Failed); } void FixVRLegacyHelpers(bool fromAsync) @@ -926,26 +949,25 @@ namespace UnityEditor.Rendering.HighDefinition void InstallLocalConfigurationPackage(Action onCompletion) { m_UsedPackageRetriever.ProcessAsync( - k_HdrpConfigPackageName, - (installed, info) => - { - // Embedding a package requires it to be an explicit direct dependency in the manifest. - // If it's not, we add it first. - if (!info.isDirectDependency) + k_HdrpConfigPackageName, + (installed, info) => { - m_PackageInstaller.ProcessAsync(k_HdrpConfigPackageName, () => m_UsedPackageRetriever.ProcessAsync( - k_HdrpConfigPackageName, - (installed, info) => - { - EmbedConfigPackage(installed, info.name, onCompletion); - - })); - } - else - { - EmbedConfigPackage(installed, info.name, onCompletion); - } - }); + // Embedding a package requires it to be an explicit direct dependency in the manifest. + // If it's not, we add it first. + if (!info.isDirectDependency) + { + m_PackageInstaller.ProcessAsync(k_HdrpConfigPackageName, () => m_UsedPackageRetriever.ProcessAsync( + k_HdrpConfigPackageName, + (installed, info) => + { + EmbedConfigPackage(installed, info.name, onCompletion); + })); + } + else + { + EmbedConfigPackage(installed, info.name, onCompletion); + } + }); } @@ -963,6 +985,16 @@ namespace UnityEditor.Rendering.HighDefinition IsLocalConfigurationPackageEmbeddedAsync(present => UpdateDisplayOfConfigPackageArea(present ? ConfigPackageState.Present : ConfigPackageState.Missing)); } + static void CheckPackages(PackageRegistrationEventArgs args) + { + if (EditorWindow.HasOpenInstances() && !EditorApplication.isPlayingOrWillChangePlaymode) + { + HDWizard window = EditorWindow.GetWindow(Style.title.text); + window.UpdateVRXRManagementInstalledCheck(); + window.UpdateVRLegacyHelpersInstalledCheck(); + } + } + class UsedPackageRetriever { PackageManager.Requests.ListRequest m_CurrentRequest; diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.UIElement.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.UIElement.cs index d6c6d116..a4cab89d 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.UIElement.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.UIElement.cs @@ -169,11 +169,11 @@ namespace UnityEditor.Rendering.HighDefinition abstract class VisualElementUpdatable : VisualElement { - protected Func m_Tester; + protected Func m_Tester; bool m_HaveFixer; - public bool currentStatus { get; private set; } + public Result currentStatus { get; private set; } - protected VisualElementUpdatable(Func tester, bool haveFixer) + protected VisualElementUpdatable(Func tester, bool haveFixer) { m_Tester = tester; m_HaveFixer = haveFixer; @@ -181,7 +181,7 @@ namespace UnityEditor.Rendering.HighDefinition public virtual void CheckUpdate() { - bool wellConfigured = m_Tester(); + var wellConfigured = m_Tester(); if (wellConfigured != currentStatus) currentStatus = wellConfigured; @@ -190,27 +190,7 @@ namespace UnityEditor.Rendering.HighDefinition public void Init() => UpdateDisplay(currentStatus, m_HaveFixer); - public abstract void UpdateDisplay(bool statusOK, bool haveFixer); - } - - class HiddableUpdatableContainer : VisualElementUpdatable - { - public HiddableUpdatableContainer(Func tester, bool haveFixer = false) : base(tester, haveFixer) { } - - public override void CheckUpdate() - { - base.CheckUpdate(); - if (currentStatus) - { - foreach (VisualElementUpdatable updatable in Children().Where(e => e is VisualElementUpdatable)) - updatable.CheckUpdate(); - } - } - - new public void Init() => base.Init(); - - public override void UpdateDisplay(bool visible, bool haveFixer) - => style.display = visible ? DisplayStyle.Flex : DisplayStyle.None; + public abstract void UpdateDisplay(Result status, bool haveFixer); } class ConfigInfoLine : VisualElementUpdatable @@ -224,6 +204,7 @@ namespace UnityEditor.Rendering.HighDefinition readonly bool m_SkipErrorIcon; private Image m_StatusOk; private Image m_StatusKO; + private Image m_StatusPending; private Button m_Resolver; private HelpBox m_HelpBox; public ConfigInfoLine(Entry entry) @@ -232,7 +213,7 @@ namespace UnityEditor.Rendering.HighDefinition m_VisibleStatus = entry.configStyle.messageType == MessageType.Error || entry.forceDisplayCheck; m_SkipErrorIcon = entry.skipErrorIcon; - var testLabel = new UnityEngine.UIElements.Label(entry.configStyle.label) + var testLabel = new Label(entry.configStyle.label) { name = "TestLabel", style = @@ -271,8 +252,19 @@ namespace UnityEditor.Rendering.HighDefinition width = 16 } }; + m_StatusPending = new Image() + { + image = CoreEditorStyles.iconPending, + name = "StatusPending", + style = + { + height = 16, + width = 16 + } + }; testRow.Add(m_StatusOk); testRow.Add(m_StatusKO); + testRow.Add(m_StatusPending); Add(testRow); var kind = entry.configStyle.messageType switch @@ -293,7 +285,7 @@ namespace UnityEditor.Rendering.HighDefinition } m_HelpBox = new HelpBox(error, kind); - m_HelpBox.Q().style.flexGrow = 1; + m_HelpBox.Q [Serializable, VolumeComponentMenu("Fog")] [SupportedOnRenderPipeline(typeof(HDRenderPipelineAsset))] - [HDRPHelpURL("Override-Fog")] + [HDRPHelpURL("fog")] public class Fog : VolumeComponentWithQuality { /// Enable fog. diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs index 2342bb73..1c8481e8 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs @@ -2314,7 +2314,8 @@ namespace UnityEngine.Rendering.HighDefinition void OnDisable() { // If it is within the cached system we need to evict it, unless user explicitly requires not to. - if (!preserveCachedShadow && hasShadowCache) + // If the shadow was pending placement in the atlas, we also evict it, even if the user wants to preserve it. + if ((!preserveCachedShadow || HDShadowManager.cachedShadowManager.LightIsPendingPlacement(lightIdxForCachedShadows, shadowMapType)) && hasShadowCache) { HDShadowManager.cachedShadowManager.EvictLight(this, legacyLight.type); } @@ -3347,7 +3348,7 @@ namespace UnityEngine.Rendering.HighDefinition internal void RefreshCachedShadow() { bool wentThroughCachedShadowSystem = lightIdxForCachedShadows >= 0; - if (!preserveCachedShadow && wentThroughCachedShadowSystem) + if (wentThroughCachedShadowSystem) HDShadowManager.cachedShadowManager.EvictLight(this, legacyLight.type); RegisterCachedShadowLightOptional(); diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl index d1fb561e..1b8a20ce 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl @@ -323,12 +323,7 @@ SHADOW_TYPE EvaluateShadow_Directional( LightLoopContext lightLoopContext, Posit } else if (shadowSplitIndex == int(_CascadeShadowCount) - 1) { - // float fade = lightLoopContext.shadowContext.fade; - float3 camToPixel = posInput.positionWS - GetPrimaryCameraPosition(); - float distanceCamToPixel2 = dot(camToPixel, camToPixel); - - HDDirectionalShadowData dsd = lightLoopContext.shadowContext.directionalShadowData; - float fade = saturate(distanceCamToPixel2 * dsd.fadeScale + dsd.fadeBias); + float fade = lightLoopContext.shadowContext.fade; // In the transition code (both dithering and blend) we use shadow = lerp( shadow, 1.0, fade ) for last transition // mean if we expend the code we have (shadow * (1 - fade) + fade). Here to make transition with shadow mask // we will remove fade and add fade * shadowMask which mean we do a lerp with shadow mask @@ -336,7 +331,20 @@ SHADOW_TYPE EvaluateShadow_Directional( LightLoopContext lightLoopContext, Posit } // See comment in EvaluateBSDF_Punctual - shadow = light.nonLightMappedOnly ? min(shadowMask, shadow) : shadow; + if (light.nonLightMappedOnly) + { + shadow = min(shadowMask, shadow); + } + else + { + // Use shadowmask when shadow value ​​cannot be retrieved due to shadow caster culling. + float3 camToPixel = posInput.positionWS - GetPrimaryCameraPosition(); + float distanceCamToPixel2 = dot(camToPixel, camToPixel); + + HDDirectionalShadowData dsd = lightLoopContext.shadowContext.directionalShadowData; + float alpha = saturate(distanceCamToPixel2 * dsd.fadeScale + dsd.fadeBias); + shadow = min(shadow, lerp(1.0, shadowMask, alpha * alpha)); + } #endif shadow = lerp(shadowMask.SHADOW_TYPE_REPLICATE, shadow, light.shadowDimmer); diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricClouds/VolumetricClouds.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricClouds/VolumetricClouds.cs index ac5aa578..0a68cb72 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricClouds/VolumetricClouds.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricClouds/VolumetricClouds.cs @@ -8,7 +8,7 @@ namespace UnityEngine.Rendering.HighDefinition /// [Serializable, VolumeComponentMenu("Sky/Volumetric Clouds")] [SupportedOnRenderPipeline(typeof(HDRenderPipelineAsset))] - [HDRPHelpURL("Override-Volumetric-Clouds")] + [HDRPHelpURL("create-realistic-clouds-volumetric-clouds")] public sealed partial class VolumetricClouds : VolumeComponent { /// diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/LocalVolumetricFog.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/LocalVolumetricFog.cs index de0343f1..33f0cc97 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/LocalVolumetricFog.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/LocalVolumetricFog.cs @@ -179,7 +179,7 @@ namespace UnityEngine.Rendering.HighDefinition } // class LocalVolumetricFogParameters /// Local Volumetric Fog class. - [HDRPHelpURLAttribute("Local-Volumetric-Fog")] + [HDRPHelpURLAttribute("create-a-local-fog-effect")] [ExecuteAlways] [AddComponentMenu("Rendering/Local Volumetric Fog")] public partial class LocalVolumetricFog : MonoBehaviour diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalProjector.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalProjector.cs index 29d49756..1b0a8722 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalProjector.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalProjector.cs @@ -21,7 +21,7 @@ namespace UnityEngine.Rendering.HighDefinition /// /// Decal Projector component. /// - [HDRPHelpURLAttribute("Decal-Projector")] + [HDRPHelpURLAttribute("understand-decals")] [ExecuteAlways] #if UNITY_EDITOR [CanEditMultipleObjects] diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/DiffusionProfile/DiffusionProfileSettings.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/DiffusionProfile/DiffusionProfileSettings.cs index c9e63dab..25dad9ac 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/DiffusionProfile/DiffusionProfileSettings.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/DiffusionProfile/DiffusionProfileSettings.cs @@ -237,7 +237,7 @@ namespace UnityEngine.Rendering.HighDefinition /// /// Class for Diffusion Profile settings /// - [HDRPHelpURLAttribute("Diffusion-Profile")] + [HDRPHelpURLAttribute("diffusion-profile-reference")] [Icon("Packages/com.unity.render-pipelines.high-definition/Editor/Icons/Processed/DiffusionProfile Icon.asset")] public partial class DiffusionProfileSettings : ScriptableObject { diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl b/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl index 463123a6..305b47e6 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl @@ -1791,7 +1791,7 @@ IndirectLighting EvaluateBSDF_ScreenSpaceReflection(PositionInputs posInput, // // Note that the SSR with clear coat is a binary state, which means we should never enter the if condition if we don't have an active // clear coat (which is not guaranteed by the HasFlag condition in deferred mode in some cases). We then need to make sure that coatMask is actually non zero. - if (HasFlag(bsdfData.materialFeatures, MATERIALFEATUREFLAGS_LIT_CLEAR_COAT) && bsdfData.coatMask > 0.0) + if (HasFlag(bsdfData.materialFeatures, MATERIALFEATUREFLAGS_LIT_CLEAR_COAT) && bsdfData.coatMask >= 0.0) { // We use the coat-traced light according to how similar the base lobe roughness is to the coat roughness // (we can assume the coat is always smoother): diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/TerrainLit/TerrainLitData.hlsl b/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/TerrainLit/TerrainLitData.hlsl index c69afedb..16363110 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/TerrainLit/TerrainLitData.hlsl +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/TerrainLit/TerrainLitData.hlsl @@ -152,8 +152,10 @@ void GetSurfaceAndBuiltinData(inout FragInputs input, float3 V, inout PositionIn GENERIC_ALPHA_TEST(hole, 0.5); #endif +#ifndef EDITOR_VISUALIZATION // terrain lightmap uvs are always taken from uv0 input.texCoord1 = input.texCoord2 = input.texCoord0; +#endif TerrainLitSurfaceData terrainLitSurfaceData; InitializeTerrainLitSurfaceData(terrainLitSurfaceData); diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/ScreenSpaceLensFlare.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/ScreenSpaceLensFlare.cs index 58773535..b468979e 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/ScreenSpaceLensFlare.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/ScreenSpaceLensFlare.cs @@ -28,7 +28,7 @@ namespace UnityEngine.Rendering.HighDefinition /// [Serializable, VolumeComponentMenu("Post-processing/Screen Space Lens Flare")] [SupportedOnRenderPipeline(typeof(HDRenderPipelineAsset))] - [HDRPHelpURL("Screen-Space-Lens-Flare")] + [HDRPHelpURL("shared/lens-flare/Override-Screen-Space-Lens-Flare")] public class ScreenSpaceLensFlare : VolumeComponent, IPostProcessComponent { /// diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDAdditionalCameraData.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDAdditionalCameraData.cs index f6f339b5..1e03a638 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDAdditionalCameraData.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDAdditionalCameraData.cs @@ -154,7 +154,7 @@ namespace UnityEngine.Rendering.HighDefinition /// /// Additional component that holds HDRP specific parameters for Cameras. /// - [HDRPHelpURLAttribute("HDRP-Camera")] + [HDRPHelpURLAttribute("hdrp-camera-component-reference")] [AddComponentMenu("")] // Hide in menu [DisallowMultipleComponent, ExecuteAlways] [RequireComponent(typeof(Camera))] diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs index fac6b25c..d46d9f6c 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs @@ -206,6 +206,10 @@ namespace UnityEngine.Rendering.HighDefinition return hdCamera; } + //access for editor helpbox checks + internal static bool TryGet(Camera camera, out HDCamera hdCamera, int xrMultipassId = 0, HistoryChannel historyChannel = HistoryChannel.RenderLoopHistory) + => s_Cameras.TryGetValue((camera, xrMultipassId, historyChannel), out hdCamera); + // internal only for now, to be publicly available when history API is implemented in SRP Core /// /// Check if a given history channel is already existing for a pair of camera and XR multi-pass Id. @@ -1472,12 +1476,12 @@ namespace UnityEngine.Rendering.HighDefinition { for (int viewIndex = 0; viewIndex < viewCount; ++viewIndex) { - transforms[viewIndex] = ComputePixelCoordToWorldSpaceViewDirectionMatrix(m_XRViewConstants[viewIndex], resolution, aspect); + transforms[viewIndex] = ComputePixelCoordToWorldSpaceViewDirectionMatrix(m_XRViewConstants[viewIndex], resolution, aspect, ShaderConfig.s_CameraRelativeRendering); } } else { - transforms[0] = ComputePixelCoordToWorldSpaceViewDirectionMatrix(mainViewConstants, resolution, aspect); + transforms[0] = ComputePixelCoordToWorldSpaceViewDirectionMatrix(mainViewConstants, resolution, aspect, ShaderConfig.s_CameraRelativeRendering); } } @@ -2102,7 +2106,7 @@ namespace UnityEngine.Rendering.HighDefinition viewConstants.viewProjectionNoCameraTrans = gpuVPNoTrans; var gpuProjAspect = HDUtils.ProjectionMatrixAspect(gpuProj); - viewConstants.pixelCoordToViewDirWS = ComputePixelCoordToWorldSpaceViewDirectionMatrix(viewConstants, screenSize, gpuProjAspect); + viewConstants.pixelCoordToViewDirWS = ComputePixelCoordToWorldSpaceViewDirectionMatrix(viewConstants, screenSize, gpuProjAspect, ShaderConfig.s_CameraRelativeRendering); if (updatePreviousFrameConstants) { @@ -2358,8 +2362,9 @@ namespace UnityEngine.Rendering.HighDefinition /// /// It is different from the aspect ratio of for anamorphic projections. /// + /// If non-zero, then assume Camera Relative Rendering is enabled. /// - Matrix4x4 ComputePixelCoordToWorldSpaceViewDirectionMatrix(ViewConstants viewConstants, Vector4 resolution, float aspect = -1) + internal Matrix4x4 ComputePixelCoordToWorldSpaceViewDirectionMatrix(ViewConstants viewConstants, Vector4 resolution, float aspect = -1, int cameraRelativeRendering = 1) { // In XR mode, or if explicitely required, use a more generic matrix to account for asymmetry in the projection var useGenericMatrix = xr.enabled || frameSettings.IsEnabled(FrameSettingsField.AsymmetricProjection); @@ -2378,7 +2383,20 @@ namespace UnityEngine.Rendering.HighDefinition new Vector4(0.0f, 0.0f, 1.0f, 0.0f), new Vector4(0.0f, 0.0f, 0.0f, 1.0f)); - var transformT = viewConstants.invViewProjMatrix.transpose * Matrix4x4.Scale(new Vector3(-1.0f, -1.0f, -1.0f)); + Matrix4x4 transformT; + if (cameraRelativeRendering == 0) + { + // In case we are not camera relative, the view matrix used to calculate viewConstants.invViewProjMatrix + // contains translation component, so we need to remove it. + var viewNoTrans = viewConstants.viewMatrix; + viewNoTrans.SetColumn(3, new Vector4(0, 0, 0, 1)); + var invViewProj = (viewConstants.projMatrix * viewNoTrans).inverse; + transformT = invViewProj.transpose * Matrix4x4.Scale(new Vector3(-1.0f, -1.0f, -1.0f)); + } + else + { + transformT = viewConstants.invViewProjMatrix.transpose * Matrix4x4.Scale(new Vector3(-1.0f, -1.0f, -1.0f)); + } return viewSpaceRasterTransform * transformT; } @@ -2443,7 +2461,7 @@ namespace UnityEngine.Rendering.HighDefinition name: string.Format("{0}_CameraColorBufferMipChain{1}", viewName, frameIndex)); } - void ReleaseHistoryBuffer() + public void ReleaseHistoryBuffer() //WW1MOD : Make public { m_HistoryRTSystem.ReleaseAll(); diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs index d022a6c9..06c598e7 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs @@ -291,6 +291,12 @@ namespace UnityEngine.Rendering.HighDefinition }); GenerateColorPyramid(m_RenderGraph, hdCamera, colorBuffer, distortionColorPyramid, FullScreenDebugMode.PreRefractionColorPyramid, distortionRendererList); currentColorPyramid = distortionColorPyramid; + + + // The color pyramid for distortion is not an history, so it need to be sampled appropriate RT handle scale. Thus we need to update it + var newScale = new Vector4(RTHandles.rtHandleProperties.rtHandleScale.x, RTHandles.rtHandleProperties.rtHandleScale.y, 0, 0); + m_ShaderVariablesGlobalCB._ColorPyramidUvScaleAndLimitCurrentFrame = newScale; + PushGlobalCameraParams(m_RenderGraph, hdCamera); } using (new RenderGraphProfilingScope(m_RenderGraph, ProfilingSampler.Get(HDProfileId.Distortion))) diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index b1fed9fd..6583da32 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -1166,7 +1166,7 @@ namespace UnityEngine.Rendering.HighDefinition m_ShaderVariablesGlobalCB._SpecularOcclusionBlend = 1.0f; } - m_ShaderVariablesGlobalCB._ColorPyramidUvScaleAndLimitCurrentFrame = HDUtils.ComputeViewportScaleAndLimit(hdCamera.historyRTHandleProperties.currentViewportSize, hdCamera.historyRTHandleProperties.currentRenderTargetSize); // WW1MOD fixed + m_ShaderVariablesGlobalCB._ColorPyramidUvScaleAndLimitCurrentFrame = HDUtils.ComputeViewportScaleAndLimit(hdCamera.historyRTHandleProperties.currentViewportSize, hdCamera.historyRTHandleProperties.currentRenderTargetSize); m_ShaderVariablesGlobalCB._ColorPyramidUvScaleAndLimitPrevFrame = HDUtils.ComputeViewportScaleAndLimit(hdCamera.historyRTHandleProperties.previousViewportSize, hdCamera.historyRTHandleProperties.previousRenderTargetSize); ConstantBuffer.PushGlobal(cmd, m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal); diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/LineRendering/Core/LineRendering.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/LineRendering/Core/LineRendering.cs index 80cfc28f..abbfedf4 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/LineRendering/Core/LineRendering.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/LineRendering/Core/LineRendering.cs @@ -101,6 +101,9 @@ namespace UnityEngine.Rendering CleanupShadingAtlas(); + m_ShaderVariablesBuffer?.Release(); + m_ShaderVariablesBuffer = null; + m_IsInitialized = false; } diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Denoising/TemporalFilter.compute b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Denoising/TemporalFilter.compute index 81c7ebff..d062e3a9 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Denoising/TemporalFilter.compute +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Denoising/TemporalFilter.compute @@ -139,7 +139,7 @@ void ValidateHistory(uint3 dispatchThreadId : SV_DispatchThreadID, uint2 groupTh // Was the object of this pixel moving? uint stencilValue = GetStencilValue(LOAD_TEXTURE2D_X(_StencilTexture, centerCoord)); - if ((stencilValue & _ObjectMotionStencilBit) != 0) + if ((stencilValue & _ObjectMotionStencilBit) != 0 && any(abs(velocity) > 0)) historyRejectionResult = historyRejectionResult | HISTORYREJECTIONFLAGS_MOTION; // If none of the previous conditions have failed, the the history is valid diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR2/Fsr2Context.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR2/Fsr2Context.cs index 7da17920..f878608b 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR2/Fsr2Context.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR2/Fsr2Context.cs @@ -34,10 +34,10 @@ namespace FidelityFX.FSR2 public class Fsr2Context { private const int MaxQueuedFrames = 16; - + private Fsr2.ContextDescription _contextDescription; private CommandBuffer _commandBuffer; - + private Fsr2Pass _computeLuminancePyramidPass; private Fsr2Pass _reconstructPreviousDepthPass; private Fsr2Pass _depthClipPass; @@ -56,7 +56,7 @@ namespace FidelityFX.FSR2 private ComputeBuffer _spdConstantsBuffer; private readonly Fsr2.SpdConstants[] _spdConstantsArray = { new Fsr2.SpdConstants() }; private ref Fsr2.SpdConstants SpdConsts => ref _spdConstantsArray[0]; - + private ComputeBuffer _rcasConstantsBuffer; private readonly Fsr2.RcasConstants[] _rcasConstantsArray = new Fsr2.RcasConstants[1]; private ref Fsr2.RcasConstants RcasConsts => ref _rcasConstantsArray[0]; @@ -77,7 +77,7 @@ namespace FidelityFX.FSR2 { _contextDescription = contextDescription; _commandBuffer = new CommandBuffer { name = "FSR2" }; - + _upscalerConstantsBuffer = CreateConstantBuffer(); _spdConstantsBuffer = CreateConstantBuffer(); _rcasConstantsBuffer = CreateConstantBuffer(); @@ -87,9 +87,9 @@ namespace FidelityFX.FSR2 // Set defaults _firstExecution = true; _resourceFrameIndex = 0; - + UpscalerConsts.displaySize = _contextDescription.DisplaySize; - + _resources.Create(_contextDescription); CreatePasses(); } @@ -105,7 +105,7 @@ namespace FidelityFX.FSR2 _generateReactivePass = new Fsr2GenerateReactivePass(_contextDescription, _resources, _generateReactiveConstantsBuffer); _tcrAutogeneratePass = new Fsr2TcrAutogeneratePass(_contextDescription, _resources, _upscalerConstantsBuffer, _tcrAutogenerateConstantsBuffer); } - + public void Destroy() { DestroyPass(ref _tcrAutogeneratePass); @@ -116,9 +116,9 @@ namespace FidelityFX.FSR2 DestroyPass(ref _depthClipPass); DestroyPass(ref _reconstructPreviousDepthPass); DestroyPass(ref _computeLuminancePyramidPass); - + _resources.Destroy(); - + DestroyConstantBuffer(ref _tcrAutogenerateConstantsBuffer); DestroyConstantBuffer(ref _generateReactiveConstantsBuffer); DestroyConstantBuffer(ref _rcasConstantsBuffer); @@ -138,17 +138,17 @@ namespace FidelityFX.FSR2 Dispatch(dispatchParams, _commandBuffer); Graphics.ExecuteCommandBuffer(_commandBuffer); } - + public void Dispatch(Fsr2.DispatchDescription dispatchParams, CommandBuffer commandBuffer) { if ((_contextDescription.Flags & Fsr2.InitializationFlags.EnableDebugChecking) != 0) { DebugCheckDispatch(dispatchParams); } - + if (dispatchParams.UseTextureArrays) commandBuffer.EnableShaderKeyword("UNITY_FSR_TEXTURE2D_X_ARRAY"); - + if (_firstExecution) { commandBuffer.SetRenderTarget(_resources.LockStatus[0]); @@ -156,7 +156,7 @@ namespace FidelityFX.FSR2 commandBuffer.SetRenderTarget(_resources.LockStatus[1]); commandBuffer.ClearRenderTarget(false, true, Color.clear); } - + int frameIndex = _resourceFrameIndex % 2; bool resetAccumulation = dispatchParams.Reset || _firstExecution; _firstExecution = false; @@ -164,7 +164,7 @@ namespace FidelityFX.FSR2 // If auto exposure is enabled use the auto exposure SRV, otherwise what the app sends if ((_contextDescription.Flags & Fsr2.InitializationFlags.EnableAutoExposure) != 0) dispatchParams.Exposure = new ResourceView(_resources.AutoExposure); - else if (!dispatchParams.Exposure.IsValid) + else if (!dispatchParams.Exposure.IsValid) dispatchParams.Exposure = new ResourceView(_resources.DefaultExposure); if (dispatchParams.EnableAutoReactive) @@ -181,16 +181,16 @@ namespace FidelityFX.FSR2 } else if (_resources.AutoReactive != null) { - // Destroy the auto-TCR resources if we don't use the feature + // Destroy the auto-TCR resources if we don't use the feature _resources.DestroyTcrAutogenResources(); } - + if (!dispatchParams.Reactive.IsValid) dispatchParams.Reactive = new ResourceView(_resources.DefaultReactive); if (!dispatchParams.TransparencyAndComposition.IsValid) dispatchParams.TransparencyAndComposition = new ResourceView(_resources.DefaultReactive); Fsr2Resources.CreateAliasableResources(commandBuffer, _contextDescription, dispatchParams); - + SetupConstants(dispatchParams, resetAccumulation); - + // Reactive mask bias const int threadGroupWorkRegionDim = 8; int dispatchSrcX = (UpscalerConsts.renderSize.x + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; @@ -203,7 +203,7 @@ namespace FidelityFX.FSR2 { commandBuffer.SetRenderTarget(_resources.LockStatus[frameIndex ^ 1]); commandBuffer.ClearRenderTarget(false, true, Color.clear); - + commandBuffer.SetRenderTarget(_resources.InternalUpscaled[frameIndex ^ 1]); commandBuffer.ClearRenderTarget(false, true, Color.clear); @@ -213,7 +213,7 @@ namespace FidelityFX.FSR2 commandBuffer.SetRenderTarget(_resources.SceneLuminance); commandBuffer.ClearRenderTarget(false, true, Color.clear); - + // Auto exposure always used to track luma changes in locking logic commandBuffer.SetRenderTarget(_resources.AutoExposure); commandBuffer.ClearRenderTarget(false, true, new Color(0f, 1f, 0f, 0f)); @@ -222,15 +222,15 @@ namespace FidelityFX.FSR2 commandBuffer.SetRenderTarget(_resources.SpdAtomicCounter); commandBuffer.ClearRenderTarget(false, true, Color.clear); } - + // FSR3: need to clear here since we need the content of this surface for frame interpolation, so clearing in the lock pass is not an option bool depthInverted = (_contextDescription.Flags & Fsr2.InitializationFlags.EnableDepthInverted) == Fsr2.InitializationFlags.EnableDepthInverted; commandBuffer.SetRenderTarget(Fsr2ShaderIDs.UavReconstructedPrevNearestDepth); commandBuffer.ClearRenderTarget(false, true, depthInverted ? Color.clear : Color.white); - + // Auto exposure SetupSpdConstants(dispatchParams, out var dispatchThreadGroupCount); - + // Initialize constant buffers data commandBuffer.SetBufferData(_upscalerConstantsBuffer, _upscalerConstantsArray); commandBuffer.SetBufferData(_spdConstantsBuffer, _spdConstantsArray); @@ -242,7 +242,7 @@ namespace FidelityFX.FSR2 dispatchParams.Reactive = new ResourceView(_resources.AutoReactive); dispatchParams.TransparencyAndComposition = new ResourceView(_resources.AutoComposition); } - + // Compute luminance pyramid _computeLuminancePyramidPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchThreadGroupCount.x, dispatchThreadGroupCount.y); @@ -263,18 +263,18 @@ namespace FidelityFX.FSR2 // Compute the constants SetupRcasConstants(dispatchParams); commandBuffer.SetBufferData(_rcasConstantsBuffer, _rcasConstantsArray); - + // Dispatch RCAS const int threadGroupWorkRegionDimRcas = 16; - int threadGroupsX = (Screen.width + threadGroupWorkRegionDimRcas - 1) / threadGroupWorkRegionDimRcas; - int threadGroupsY = (Screen.height + threadGroupWorkRegionDimRcas - 1) / threadGroupWorkRegionDimRcas; + int threadGroupsX = (_contextDescription.DisplaySize.x + threadGroupWorkRegionDimRcas - 1) / threadGroupWorkRegionDimRcas; + int threadGroupsY = (_contextDescription.DisplaySize.y + threadGroupWorkRegionDimRcas - 1) / threadGroupWorkRegionDimRcas; _sharpenPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, threadGroupsX, threadGroupsY); } _resourceFrameIndex = (_resourceFrameIndex + 1) % MaxQueuedFrames; Fsr2Resources.DestroyAliasableResources(commandBuffer); - + commandBuffer.DisableShaderKeyword("UNITY_FSR_TEXTURE2D_X_ARRAY"); } @@ -296,7 +296,7 @@ namespace FidelityFX.FSR2 GenReactiveConsts.binaryValue = dispatchParams.BinaryValue; GenReactiveConsts.flags = (uint)dispatchParams.Flags; commandBuffer.SetBufferData(_generateReactiveConstantsBuffer, _generateReactiveConstantsArray); - + ((Fsr2GenerateReactivePass)_generateReactivePass).ScheduleDispatch(commandBuffer, dispatchParams, dispatchSrcX, dispatchSrcY); } @@ -311,14 +311,14 @@ namespace FidelityFX.FSR2 TcrAutoGenConsts.autoReactiveScale = dispatchParams.AutoReactiveScale; TcrAutoGenConsts.autoReactiveMax = dispatchParams.AutoReactiveMax; commandBuffer.SetBufferData(_tcrAutogenerateConstantsBuffer, _tcrAutogenerateConstantsArray); - + _tcrAutogeneratePass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchSrcX, dispatchSrcY); } private void SetupConstants(Fsr2.DispatchDescription dispatchParams, bool resetAccumulation) { ref Fsr2.UpscalerConstants constants = ref UpscalerConsts; - + constants.jitterOffset = dispatchParams.JitterOffset; constants.renderSize = dispatchParams.RenderSize; constants.maxRenderSize = _contextDescription.MaxRenderSize; @@ -332,16 +332,16 @@ namespace FidelityFX.FSR2 // Compute params to enable device depth to view space depth computation in shader constants.deviceToViewDepth = SetupDeviceDepthToViewSpaceDepthParams(dispatchParams); - + // To be updated if resource is larger than the actual image size constants.downscaleFactor = new Vector2((float)constants.renderSize.x / _contextDescription.DisplaySize.x, (float)constants.renderSize.y / _contextDescription.DisplaySize.y); constants.previousFramePreExposure = constants.preExposure; constants.preExposure = (dispatchParams.PreExposure != 0) ? dispatchParams.PreExposure : 1.0f; - + // Motion vector data Vector2Int motionVectorsTargetSize = (_contextDescription.Flags & Fsr2.InitializationFlags.EnableDisplayResolutionMotionVectors) != 0 ? constants.displaySize : constants.renderSize; constants.motionVectorScale = dispatchParams.MotionVectorScale / motionVectorsTargetSize; - + // Compute jitter cancellation if ((_contextDescription.Flags & Fsr2.InitializationFlags.EnableMotionVectorsJitterCancellation) != 0) { @@ -362,7 +362,7 @@ namespace FidelityFX.FSR2 else if (jitterPhaseCountDelta < 0) constants.jitterPhaseCount--; } - + // Convert delta time to seconds and clamp to [0, 1] constants.deltaTime = Mathf.Clamp01(dispatchParams.FrameTimeDelta); @@ -378,7 +378,7 @@ namespace FidelityFX.FSR2 constants.lumaMipDimensions.x = (int)(constants.maxRenderSize.x / mipDiv); constants.lumaMipDimensions.y = (int)(constants.maxRenderSize.y / mipDiv); } - + private Vector4 SetupDeviceDepthToViewSpaceDepthParams(Fsr2.DispatchDescription dispatchParams) { bool inverted = (_contextDescription.Flags & Fsr2.InitializationFlags.EnableDepthInverted) != 0; @@ -399,7 +399,7 @@ namespace FidelityFX.FSR2 Vector4 matrixElemC = new Vector4(q, -1.0f - Mathf.Epsilon, q, 0.0f + Mathf.Epsilon); Vector4 matrixElemE = new Vector4(q * min, -min - Mathf.Epsilon, q * min, max); - + // Revert x and y coords float aspect = (float)dispatchParams.RenderSize.x / dispatchParams.RenderSize.y; float cotHalfFovY = Mathf.Cos(0.5f * dispatchParams.CameraFovAngleVertical) / Mathf.Sin(0.5f * dispatchParams.CameraFovAngleVertical); @@ -422,7 +422,7 @@ namespace FidelityFX.FSR2 { RectInt rectInfo = new RectInt(0, 0, dispatchParams.RenderSize.x, dispatchParams.RenderSize.y); SpdSetup(rectInfo, out dispatchThreadGroupCount, out var workGroupOffset, out var numWorkGroupsAndMips); - + // Downsample ref Fsr2.SpdConstants spdConstants = ref SpdConsts; spdConstants.numWorkGroups = (uint)numWorkGroupsAndMips.x; @@ -456,22 +456,22 @@ namespace FidelityFX.FSR2 { Debug.LogError("Color resource is null"); } - + if (!dispatchParams.Depth.IsValid) { Debug.LogError("Depth resource is null"); } - + if (!dispatchParams.MotionVectors.IsValid) { Debug.LogError("MotionVectors resource is null"); } - + if (!dispatchParams.Output.IsValid) { Debug.LogError("Output resource is null"); } - + if (dispatchParams.Exposure.IsValid && (_contextDescription.Flags & Fsr2.InitializationFlags.EnableAutoExposure) != 0) { Debug.LogWarning("Exposure resource provided, however auto exposure flag is present"); @@ -529,7 +529,7 @@ namespace FidelityFX.FSR2 Debug.LogWarning("EnableDepthInfinite and EnableDepthInverted present, yet CameraNear != float.MaxValue"); } } - + if (dispatchParams.CameraFar < 0.075f) { Debug.LogWarning("EnableDepthInverted present, CameraFar value is very low which may result in depth separation artefacting"); @@ -595,17 +595,17 @@ namespace FidelityFX.FSR2 new Fsr2.RcasConstants(1064229695u, 997604214u), new Fsr2.RcasConstants(1065353216u, 1006648320), }; - + private static ComputeBuffer CreateConstantBuffer() where TConstants: struct { return new ComputeBuffer(1, Marshal.SizeOf(), ComputeBufferType.Constant); } - + private static void DestroyConstantBuffer(ref ComputeBuffer bufferRef) { if (bufferRef == null) return; - + bufferRef.Release(); bufferRef = null; } @@ -614,7 +614,7 @@ namespace FidelityFX.FSR2 { if (pass == null) return; - + pass.Dispose(); pass = null; } diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerContext.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerContext.cs index a54d9e76..e8775667 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerContext.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerContext.cs @@ -185,7 +185,7 @@ namespace FidelityFX.FSR3 // If auto exposure is enabled use the auto exposure SRV, otherwise what the app sends if ((_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableAutoExposure) != 0) - dispatchParams.Exposure = new ResourceView(_resources.FrameInfo); + dispatchParams.Exposure = new ResourceView(_resources.FrameInfo[frameIndex]); else if (!dispatchParams.Exposure.IsValid) dispatchParams.Exposure = new ResourceView(_resources.DefaultExposure); @@ -236,8 +236,8 @@ namespace FidelityFX.FSR3 commandBuffer.ClearRenderTarget(false, true, Color.clear); // Auto exposure always used to track luma changes in locking logic - commandBuffer.SetRenderTarget(_resources.FrameInfo); - commandBuffer.ClearRenderTarget(false, true, new Color(0f, 1f, 0f, 0f)); + commandBuffer.SetRenderTarget(_resources.FrameInfo[frameIndex ^ 1]); + commandBuffer.ClearRenderTarget(false, true, new Color(0f, 1e8f, 0f, 0f)); // Reset atomic counter to 0 commandBuffer.SetRenderTarget(_resources.SpdAtomicCounter); @@ -249,6 +249,9 @@ namespace FidelityFX.FSR3 commandBuffer.SetRenderTarget(_resources.ReconstructedPrevNearestDepth); commandBuffer.ClearRenderTarget(false, true, depthInverted ? Color.clear : Color.white); + commandBuffer.SetRenderTarget(Fsr3ShaderIDs.UavNewLocks); + commandBuffer.ClearRenderTarget(false, true, Color.clear); + // Auto exposure SetupSpdConstants(dispatchParams, out var dispatchThreadGroupCount); diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerPass.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerPass.cs index 00a634e2..5ebfa0cf 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerPass.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerPass.cs @@ -155,9 +155,10 @@ namespace FidelityFX.FSR3 { commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvCurrentLuma, Resources.Luma[frameIndex]); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvFarthestDepth, Fsr3ShaderIDs.UavIntermediate); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvFrameInfo, Resources.FrameInfo[frameIndex ^ 1]); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdAtomicCount, Resources.SpdAtomicCounter); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavFrameInfo, Resources.FrameInfo); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavFrameInfo, Resources.FrameInfo[frameIndex]); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdMip0, Resources.SpdMips, 0); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdMip1, Resources.SpdMips, 1); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdMip2, Resources.SpdMips, 2); @@ -273,7 +274,7 @@ namespace FidelityFX.FSR3 commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedReactiveMasks, Fsr3ShaderIDs.UavDilatedReactiveMasks); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedMotionVectors, Resources.DilatedVelocity); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvFrameInfo, Resources.FrameInfo); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvFrameInfo, Resources.FrameInfo[frameIndex]); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvLumaHistory, Resources.LumaHistory[frameIndex ^ 1]); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvFarthestDepthMip1, Fsr3ShaderIDs.UavFarthestDepthMip1); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvCurrentLuma, Resources.Luma[frameIndex]); diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerResources.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerResources.cs index d10bd96b..b894ba25 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerResources.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerResources.cs @@ -40,10 +40,10 @@ namespace FidelityFX.FSR3 public RenderTexture DilatedVelocity; public RenderTexture DilatedDepth; public RenderTexture ReconstructedPrevNearestDepth; - public RenderTexture FrameInfo; public RenderTexture AutoReactive; public RenderTexture AutoComposition; + public readonly RenderTexture[] FrameInfo = new RenderTexture[2]; public readonly RenderTexture[] Accumulation = new RenderTexture[2]; public readonly RenderTexture[] Luma = new RenderTexture[2]; public readonly RenderTexture[] InternalUpscaled = new RenderTexture[2]; @@ -107,8 +107,7 @@ namespace FidelityFX.FSR3 ReconstructedPrevNearestDepth.Create(); // Resource FSR3UPSCALER_FrameInfo: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32G32B32A32_FLOAT, FFX_RESOURCE_FLAGS_NONE - FrameInfo = new RenderTexture(1, 1, 0, GraphicsFormat.R32G32B32A32_SFloat) { name = "FSR3UPSCALER_FrameInfo", enableRandomWrite = true }; - FrameInfo.Create(); + CreateDoubleBufferedResource(FrameInfo, "FSR3UPSCALER_FrameInfo", Vector2Int.one, GraphicsFormat.R32G32B32A32_SFloat); // Resources FSR3UPSCALER_Accumulation1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_NONE CreateDoubleBufferedResource(Accumulation, "FSR3UPSCALER_Accumulation", maxRenderSize, GraphicsFormat.R8_UNorm); @@ -194,8 +193,8 @@ namespace FidelityFX.FSR3 DestroyResource(InternalUpscaled); DestroyResource(Luma); DestroyResource(Accumulation); + DestroyResource(FrameInfo); - DestroyResource(ref FrameInfo); DestroyResource(ref ReconstructedPrevNearestDepth); DestroyResource(ref DilatedDepth); DestroyResource(ref DilatedVelocity); diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/ffx_fsr3upscaler_luma_pyramid_pass.hlsl b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/ffx_fsr3upscaler_luma_pyramid_pass.hlsl index 0d6b67df..dd678b0c 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/ffx_fsr3upscaler_luma_pyramid_pass.hlsl +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/ffx_fsr3upscaler_luma_pyramid_pass.hlsl @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. // // Copyright (C) 2024 Advanced Micro Devices, Inc. -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files(the "Software"), to deal // in the Software without restriction, including without limitation the rights @@ -22,6 +22,7 @@ #define FSR3UPSCALER_BIND_SRV_CURRENT_LUMA 0 #define FSR3UPSCALER_BIND_SRV_FARTHEST_DEPTH 1 +#define FSR3UPSCALER_BIND_SRV_FRAME_INFO 2 #define FSR3UPSCALER_BIND_UAV_SPD_GLOBAL_ATOMIC 0 #define FSR3UPSCALER_BIND_UAV_FRAME_INFO 1 diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h index 084d4d37..73b5ad69 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. // // Copyright (C) 2024 Advanced Micro Devices, Inc. -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files(the "Software"), to deal // in the Software without restriction, including without limitation the rights @@ -52,7 +52,7 @@ void RectifyHistory( const FfxFloat32 fReactiveFactor = ffxPow(params.fReactiveMask, 1.0f / 2.0f); const FfxFloat32 fShadingChangeFactor = params.fShadingChange; const FfxFloat32 fBoxScaleT = ffxMax(fVecolityFactor, ffxMax(fDistanceFactor, ffxMax(fAccumulationFactor, ffxMax(fReactiveFactor, fShadingChangeFactor)))); - + const FfxFloat32 fBoxScale = ffxLerp(3.0f, 1.0f, fBoxScaleT); const FfxFloat32x3 fScaledBoxVec = data.clippingBox.boxVec * FfxFloat32x3(1.7f, 1.0f, 1.0f) * fBoxScale; @@ -148,7 +148,7 @@ void Accumulate(FfxInt32x2 iPxHrPos) if (params.bIsExistingSample && !params.bIsNewSample) { ReprojectHistoryColor(params, data); } - + UpdateLockStatus(params, data); ComputeBaseAccumulationWeight(params, data); @@ -169,5 +169,5 @@ void Accumulate(FfxInt32x2 iPxHrPos) #if FFX_FSR3UPSCALER_OPTION_APPLY_SHARPENING == 0 StoreUpscaledOutput(iPxHrPos, data.fHistoryColor); #endif - StoreNewLocks(iPxHrPos, 0); + //StoreNewLocks(iPxHrPos, 0); } diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_luma_pyramid.h b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_luma_pyramid.h index c545579e..e86e41e4 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_luma_pyramid.h +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_luma_pyramid.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. // // Copyright (C) 2024 Advanced Micro Devices, Inc. -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files(the "Software"), to deal // in the Software without restriction, including without limitation the rights @@ -95,7 +95,7 @@ void SpdStore(FfxInt32x2 pix, FfxFloat32x4 outValue, FfxUInt32 index, FfxUInt32 if (all(FFX_EQUAL(pix, FfxInt32x2(0, 0)))) { - FfxFloat32x4 frameInfo = LoadFrameInfo(); + FfxFloat32x4 frameInfo = FrameInfo(); const FfxFloat32 fSceneAvgLuma = outValue[LUMA]; const FfxFloat32 fPrevLogLuma = frameInfo[FRAME_INFO_LOG_LUMA]; FfxFloat32 fLogLuma = outValue[LOG_LUMA]; diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR2UpscalerPlugin.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR2UpscalerPlugin.cs index 4fc4d953..ffce7e2c 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR2UpscalerPlugin.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR2UpscalerPlugin.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using FidelityFX; using FidelityFX.FSR2; +using UnityEngine.Experimental.Rendering; namespace UnityEngine.Rendering.HighDefinition.AMD.FSR2 { @@ -63,6 +64,8 @@ namespace UnityEngine.Rendering.HighDefinition.AMD.FSR2 private readonly Fsr2.DispatchDescription _dispatchDescription = new(); private readonly FSR2CommandInitializationData _initData; + private Texture2DArray _clearTextureArray; + internal FSR2UpscalerContext(in FSR2CommandInitializationData initSettings) { _initData = initSettings; @@ -88,21 +91,30 @@ namespace UnityEngine.Rendering.HighDefinition.AMD.FSR2 Flags = flags, Shaders = assets.shaders, }); + + _clearTextureArray = new Texture2DArray(1, 1, TextureXR.slices, GraphicsFormat.R32G32_SFloat, TextureCreationFlags.None); + for (int i = 0; i < TextureXR.slices; ++i) _clearTextureArray.SetPixels(new[] { Color.clear, }, i); + _clearTextureArray.Apply(); } internal void Destroy() { + CoreUtils.Destroy(_clearTextureArray); + _context.Destroy(); } public override void Execute(CommandBuffer cmd, in FSR2CommandExecutionData executeData, in FSR2TextureTable textures) { + bool useTextureArrays = TextureXR.useTexArray && textures.colorInput.dimension == TextureDimension.Tex2DArray; + ResourceView clearTexture = useTextureArrays ? new ResourceView(_clearTextureArray) : new ResourceView(); + _dispatchDescription.Color = new ResourceView(textures.colorInput); _dispatchDescription.Depth = new ResourceView(textures.depth); _dispatchDescription.MotionVectors = new ResourceView(textures.motionVectors); - _dispatchDescription.Exposure = new ResourceView(textures.exposureTexture); - _dispatchDescription.Reactive = new ResourceView(textures.biasColorMask); - _dispatchDescription.TransparencyAndComposition = new ResourceView(textures.transparencyMask); + _dispatchDescription.Exposure = textures.exposureTexture != null ? new ResourceView(textures.exposureTexture) : new ResourceView(); + _dispatchDescription.Reactive = textures.biasColorMask != null ? new ResourceView(textures.biasColorMask) : clearTexture; + _dispatchDescription.TransparencyAndComposition = textures.transparencyMask != null ? new ResourceView(textures.transparencyMask) : clearTexture; _dispatchDescription.Output = new ResourceView(textures.colorOutput); _dispatchDescription.JitterOffset = new Vector2(executeData.jitterOffsetX, executeData.jitterOffsetY); @@ -118,7 +130,7 @@ namespace UnityEngine.Rendering.HighDefinition.AMD.FSR2 _dispatchDescription.CameraFar = executeData.cameraFar; _dispatchDescription.CameraFovAngleVertical = executeData.cameraFovAngleVertical; _dispatchDescription.ViewSpaceToMetersFactor = 1.0f; // 1 unit is 1 meter in Unity - _dispatchDescription.UseTextureArrays = TextureXR.useTexArray && textures.colorInput.dimension == TextureDimension.Tex2DArray; + _dispatchDescription.UseTextureArrays = useTextureArrays; _context.Dispatch(_dispatchDescription, cmd); } diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR3UpscalerPlugin.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR3UpscalerPlugin.cs index 77f55b64..5f43217b 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR3UpscalerPlugin.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR3UpscalerPlugin.cs @@ -1,6 +1,11 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using FidelityFX; using FidelityFX.FSR3; +using UnityEngine.Experimental.Rendering; +#if UNITY_STANDALONE_WIN +using AMDUP = UnityEngine.AMD; +#endif namespace UnityEngine.Rendering.HighDefinition.AMD.FSR3 { @@ -13,6 +18,7 @@ namespace UnityEngine.Rendering.HighDefinition.AMD.FSR3 public static bool EnableDebugView { get; set; } = false; private Fsr3UpscalerAssets _assets; + private bool _nativePluginLoaded; public override string name => "FSR 3.1"; @@ -20,10 +26,33 @@ namespace UnityEngine.Rendering.HighDefinition.AMD.FSR3 public override bool includesSharpening => true; - public override bool supportsAlpha => true; + public override bool supportsAlpha => !_nativePluginLoaded; // Managed Unity port has alpha upscaling built-in, the native AMD implementation doesn't public override bool Load() { + // Guess we're using native plugins after all! + // On Windows with supported graphics APIs, we use a drop-in replacement for Unity's plugin that implements FSR 3.1 through AMD's upgradable FidelityFX API. + // This allows AMD's GPU driver to hijack the plugin and transparently upgrade our implementation to FSR4 on supported graphics cards! + _nativePluginLoaded = false; +#if UNITY_STANDALONE_WIN + if (!Application.isEditor && SystemInfo.operatingSystemFamily == OperatingSystemFamily.Windows && SystemInfo.graphicsDeviceType is GraphicsDeviceType.Direct3D12 or GraphicsDeviceType.Vulkan) + { + try + { + if (AMDUP.AMDUnityPlugin.IsLoaded() || AMDUP.AMDUnityPlugin.Load()) + { + _nativePluginLoaded = AMDUP.GraphicsDevice.device != null || AMDUP.GraphicsDevice.CreateGraphicsDevice() != null; + if (_nativePluginLoaded) + return true; + } + } + catch (DllNotFoundException) + { + _nativePluginLoaded = false; + } + } +#endif + if (_assets != null) return true; @@ -31,18 +60,39 @@ namespace UnityEngine.Rendering.HighDefinition.AMD.FSR3 return _assets != null; } - public override bool IsLoaded() => _assets != null; + public override bool IsLoaded() => _nativePluginLoaded || _assets != null; public override UpscalerContext CreateContext(in FSR2CommandInitializationData initSettings) { - var context = new FSR3UpscalerContext(in initSettings); - context.Init(_assets); - return context; +#if UNITY_STANDALONE_WIN + if (_nativePluginLoaded) + { + var context = new FSR3NativeUpscalerContext(in initSettings); + context.Init(); + return context; + } + else +#endif + { + var context = new FSR3UpscalerContext(in initSettings); + context.Init(_assets); + return context; + } } public override void DestroyContext(UpscalerContext context) { - ((FSR3UpscalerContext)context).Destroy(); + switch (context) + { +#if UNITY_STANDALONE_WIN + case FSR3NativeUpscalerContext nativeContext: + nativeContext.Destroy(); + break; +#endif + case FSR3UpscalerContext managedContext: + managedContext.Destroy(); + break; + } } public override bool GetRenderResolutionFromQualityMode(FSR2Quality qualityMode, uint displayWidth, uint displayHeight, out uint renderWidth, out uint renderHeight) @@ -65,6 +115,8 @@ namespace UnityEngine.Rendering.HighDefinition.AMD.FSR3 private readonly Fsr3Upscaler.DispatchDescription _dispatchDescription = new(); private readonly FSR2CommandInitializationData _initData; + private Texture2DArray _clearTextureArray; + internal FSR3UpscalerContext(in FSR2CommandInitializationData initSettings) { _initData = initSettings; @@ -90,21 +142,30 @@ namespace UnityEngine.Rendering.HighDefinition.AMD.FSR3 Flags = flags, Shaders = assets.shaders, }); + + _clearTextureArray = new Texture2DArray(1, 1, TextureXR.slices, GraphicsFormat.R32G32_SFloat, TextureCreationFlags.None); + for (int i = 0; i < TextureXR.slices; ++i) _clearTextureArray.SetPixels(new[] { Color.clear, }, i); + _clearTextureArray.Apply(); } internal void Destroy() { + CoreUtils.Destroy(_clearTextureArray); + _context.Destroy(); } public override void Execute(CommandBuffer cmd, in FSR2CommandExecutionData executeData, in FSR2TextureTable textures) { + bool useTextureArrays = TextureXR.useTexArray && textures.colorInput.dimension == TextureDimension.Tex2DArray; + ResourceView clearTexture = useTextureArrays ? new ResourceView(_clearTextureArray) : new ResourceView(); + _dispatchDescription.Color = new ResourceView(textures.colorInput); _dispatchDescription.Depth = new ResourceView(textures.depth); _dispatchDescription.MotionVectors = new ResourceView(textures.motionVectors); - _dispatchDescription.Exposure = new ResourceView(textures.exposureTexture); - _dispatchDescription.Reactive = new ResourceView(textures.biasColorMask); - _dispatchDescription.TransparencyAndComposition = new ResourceView(textures.transparencyMask); + _dispatchDescription.Exposure = textures.exposureTexture != null ? new ResourceView(textures.exposureTexture) : new ResourceView(); + _dispatchDescription.Reactive = textures.biasColorMask != null ? new ResourceView(textures.biasColorMask) : clearTexture; + _dispatchDescription.TransparencyAndComposition = textures.transparencyMask != null ? new ResourceView(textures.transparencyMask) : clearTexture; _dispatchDescription.Output = new ResourceView(textures.colorOutput); _dispatchDescription.JitterOffset = new Vector2(executeData.jitterOffsetX, executeData.jitterOffsetY); @@ -122,9 +183,85 @@ namespace UnityEngine.Rendering.HighDefinition.AMD.FSR3 _dispatchDescription.CameraFovAngleVertical = executeData.cameraFovAngleVertical; _dispatchDescription.ViewSpaceToMetersFactor = 1.0f; // 1 unit is 1 meter in Unity _dispatchDescription.Flags = FSR3UpscalerPlugin.EnableDebugView ? Fsr3Upscaler.DispatchFlags.DrawDebugView : 0; - _dispatchDescription.UseTextureArrays = TextureXR.useTexArray && textures.colorInput.dimension == TextureDimension.Tex2DArray; + _dispatchDescription.UseTextureArrays = useTextureArrays; _context.Dispatch(_dispatchDescription, cmd); } } + +#if UNITY_STANDALONE_WIN + public class FSR3NativeUpscalerContext : UpscalerContext + { + private AMDUP.FSR2Context _nativeContext; + private readonly FSR2CommandInitializationData _initData; + + internal FSR3NativeUpscalerContext(in FSR2CommandInitializationData initSettings) + { + _initData = initSettings; + } + + internal void Init() + { + AMDUP.FSR2CommandInitializationData initSettings = new() + { + maxRenderSizeWidth = _initData.maxRenderSizeWidth, + maxRenderSizeHeight = _initData.maxRenderSizeHeight, + displaySizeWidth = _initData.displaySizeWidth, + displaySizeHeight = _initData.displaySizeHeight, + ffxFsrFlags = (AMDUP.FfxFsr2InitializationFlags)_initData.ffxFsrFlags, + }; + + CommandBuffer cmd = new(); + _nativeContext = AMDUP.GraphicsDevice.device.CreateFeature(cmd, in initSettings); + Graphics.ExecuteCommandBuffer(cmd); + cmd.Release(); + } + + internal void Destroy() + { + if (_nativeContext == null) + return; + + CommandBuffer cmd = new(); + AMDUP.GraphicsDevice.device.DestroyFeature(cmd, _nativeContext); + Graphics.ExecuteCommandBuffer(cmd); + cmd.Release(); + + _nativeContext = null; + } + + public override void Execute(CommandBuffer cmd, in FSR2CommandExecutionData executeData, in FSR2TextureTable textures) + { + ref var execData = ref _nativeContext.executeData; + execData.jitterOffsetX = executeData.jitterOffsetX; + execData.jitterOffsetY = executeData.jitterOffsetY; + execData.MVScaleX = executeData.MVScaleX; + execData.MVScaleY = executeData.MVScaleY; + execData.renderSizeWidth = executeData.renderSizeWidth; + execData.renderSizeHeight = executeData.renderSizeHeight; + execData.enableSharpening = executeData.enableSharpening; + execData.sharpness = executeData.sharpness; + execData.frameTimeDelta = executeData.frameTimeDelta; + execData.preExposure = executeData.preExposure; + execData.reset = executeData.reset; + execData.cameraNear = executeData.cameraNear; + execData.cameraFar = executeData.cameraFar; + execData.cameraFovAngleVertical = executeData.cameraFovAngleVertical; + + AMDUP.FSR2TextureTable textureTable = new() + { + colorInput = textures.colorInput, + depth = textures.depth, + motionVectors = textures.motionVectors, + exposureTexture = textures.exposureTexture, + biasColorMask = textures.biasColorMask, + reactiveMask = textures.reactiveMask, + transparencyMask = textures.transparencyMask, + colorOutput = textures.colorOutput, + }; + + AMDUP.GraphicsDevice.device.ExecuteFSR2(cmd, _nativeContext, in textureTable); + } + } +#endif } diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs index 9c30a04f..1554e621 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs @@ -234,7 +234,7 @@ namespace UnityEngine.Rendering.HighDefinition [FrameSettingsField(0, autoName: Bloom, positiveDependencies: new[] { Postprocess }, customOrderInGroup: 19, tooltip: "When enabled, HDRP adds bloom to Cameras affected by a Volume containing the Bloom override.")] Bloom = 84, /// When enabled, HDRP adds Screen Space lens flare post process to Cameras affected by a Volume containing the Screen Space Lens Flare override. - [FrameSettingsField(0, autoName: LensFlareScreenSpace, positiveDependencies: new[] { Postprocess, Bloom }, customOrderInGroup: 19, tooltip: "When enabled, HDRP adds Screen Space Lens Flare post process to Cameras affected by a Volume containing the Screen Space Lens Flare override.")] + [FrameSettingsField(0, displayedName: "Screen Space Lens Flare", positiveDependencies: new[] { Postprocess, Bloom }, customOrderInGroup: 19, tooltip: "When enabled, HDRP adds Screen Space Lens Flare post process to Cameras affected by a Volume containing the Screen Space Lens Flare override.")] LensFlareScreenSpace = 104, /// When enabled, HDRP adds lens flare to Cameras. [FrameSettingsField(0, autoName: LensFlareDataDriven, positiveDependencies: new[] { Postprocess }, customOrderInGroup: 20, tooltip: "When enabled, HDRP adds lens flare to Cameras.")] @@ -353,7 +353,7 @@ namespace UnityEngine.Rendering.HighDefinition [FrameSettingsField(1, displayedName: "Fog", tooltip: "When enabled, Cameras using these Frame Settings render fog effects.")] AtmosphericScattering = 27, /// When enabled, Cameras using these Frame Settings render volumetric effects such as volumetric fog and lighting. - [FrameSettingsField(1, autoName: Volumetrics, positiveDependencies: new[] { AtmosphericScattering }, tooltip: "When enabled, Cameras using these Frame Settings render volumetric effects such as volumetric fog and lighting (Depends on \"Volumetrics\" in current HDRP Asset).")] + [FrameSettingsField(1, displayedName: "Volumetric Fog", positiveDependencies: new[] { AtmosphericScattering }, tooltip: "When enabled, Cameras using these Frame Settings render volumetric effects such as volumetric fog and lighting (Depends on \"Volumetrics\" in current HDRP Asset).")] Volumetrics = 28, /// When enabled, Cameras using these Frame Settings use several previous frames to calculate volumetric effects which increases their overall quality at run time. [FrameSettingsField(1, displayedName: "Reprojection", positiveDependencies: new[] { AtmosphericScattering, Volumetrics }, tooltip: "When enabled, Cameras using these Frame Settings use several previous frames to calculate volumetric effects which increases their overall quality at run time.")] diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl b/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl index 95ad50d2..8be2d26b 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl @@ -274,7 +274,7 @@ float3 LoadCameraColor(uint2 pixelCoords, uint lod) float3 SampleCameraColor(float2 uv, float lod) { - return SAMPLE_TEXTURE2D_X_LOD(_ColorPyramidTexture, s_trilinear_clamp_sampler, uv * _RTHandleScaleHistory.xy, lod).rgb; + return SAMPLE_TEXTURE2D_X_LOD(_ColorPyramidTexture, s_trilinear_clamp_sampler, uv * _ColorPyramidUvScaleAndLimitCurrentFrame.xy, lod).rgb; } float3 LoadCameraColor(uint2 pixelCoords) diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/CloudSystem/CloudLayer/CloudLayer.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/CloudSystem/CloudLayer/CloudLayer.cs index fc4aaacd..78353e66 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/CloudSystem/CloudLayer/CloudLayer.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/CloudSystem/CloudLayer/CloudLayer.cs @@ -69,7 +69,7 @@ namespace UnityEngine.Rendering.HighDefinition [VolumeComponentMenu("Sky/Cloud Layer")] [SupportedOnRenderPipeline(typeof(HDRenderPipelineAsset))] [CloudUniqueID((int)CloudType.CloudLayer)] - [HDRPHelpURL("Override-Cloud-Layer")] + [HDRPHelpURL("create-simple-clouds-cloud-layer")] public partial class CloudLayer : CloudSettings { /// Controls the global opacity of the cloud layer. diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/GradientSky/GradientSky.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/GradientSky/GradientSky.cs index a5bcf458..711b58fc 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/GradientSky/GradientSky.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/GradientSky/GradientSky.cs @@ -9,7 +9,7 @@ namespace UnityEngine.Rendering.HighDefinition [VolumeComponentMenu("Sky/Gradient Sky")] [SupportedOnRenderPipeline(typeof(HDRenderPipelineAsset))] [SkyUniqueID((int)SkyType.Gradient)] - [HDRPHelpURL("Override-Gradient-Sky")] + [HDRPHelpURL("create-a-gradient-sky")] public class GradientSky : SkySettings { /// Top color of the gradient sky. diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/HDRISky/HDRISky.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/HDRISky/HDRISky.cs index 862e5360..d196de65 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/HDRISky/HDRISky.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/HDRISky/HDRISky.cs @@ -9,7 +9,7 @@ namespace UnityEngine.Rendering.HighDefinition [VolumeComponentMenu("Sky/HDRI Sky")] [SupportedOnRenderPipeline(typeof(HDRenderPipelineAsset))] [SkyUniqueID((int)SkyType.HDRI)] - [HDRPHelpURL("Override-HDRI-Sky")] + [HDRPHelpURL("create-an-hdri-sky")] public partial class HDRISky : SkySettings { /// diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSky.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSky.cs index 93e91bb8..7a402f74 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSky.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSky.cs @@ -22,7 +22,7 @@ namespace UnityEngine.Rendering.HighDefinition [VolumeComponentMenu("Sky/Physically Based Sky")] [SupportedOnRenderPipeline(typeof(HDRenderPipelineAsset))] [SkyUniqueID((int)SkyType.PhysicallyBased)] - [HDRPHelpURL("Override-Physically-Based-Sky")] + [HDRPHelpURL("create-a-physically-based-sky")] public partial class PhysicallyBasedSky : SkySettings { /// diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/StaticLightingSky.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/StaticLightingSky.cs index ee04eea0..5d6b2dfc 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/StaticLightingSky.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/StaticLightingSky.cs @@ -7,7 +7,7 @@ namespace UnityEngine.Rendering.HighDefinition /// /// Class controlling which sky is used for static and baked lighting. /// - [HDRPHelpURLAttribute("Static-Lighting-Sky")] + [HDRPHelpURLAttribute("Environment-Lighting")] [ExecuteAlways] [AddComponentMenu("")] // Hide this object from the Add Component menu public class StaticLightingSky : MonoBehaviour diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/HDRenderPipeline.WaterSystem.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/HDRenderPipeline.WaterSystem.cs index aeef35e1..be472120 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/HDRenderPipeline.WaterSystem.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/HDRenderPipeline.WaterSystem.cs @@ -440,8 +440,8 @@ namespace UnityEngine.Rendering.HighDefinition float triangleSize = (1 << lod) * cb._GridSize.x / WaterConsts.k_WaterTessellatedMeshResolution; // align grid size on region extent float2 optimalTriangleSize = new float2( - extent.x / Mathf.Max(Mathf.Floor(extent.x / triangleSize), 1), - extent.y / Mathf.Max(Mathf.Floor(extent.y / triangleSize), 1)); + extent.x / Mathf.Max(Mathf.Ceil(extent.x / triangleSize), 1), + extent.y / Mathf.Max(Mathf.Ceil(extent.y / triangleSize), 1)); cb._GridSize = optimalTriangleSize * cb._GridSize.x / triangleSize; // align grid pos on one region corner float2 corner = -(cb._PatchOffset + 0.5f * cb._GridSize) - cb._RegionExtent; diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/WaterDecal/WaterDecal.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/WaterDecal/WaterDecal.cs index 5ea37fbe..13a9e96f 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/WaterDecal/WaterDecal.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/WaterDecal/WaterDecal.cs @@ -6,7 +6,7 @@ namespace UnityEngine.Rendering.HighDefinition /// /// Water decal component. /// - [HDRPHelpURL("WaterSystem-waterdecal")] + [HDRPHelpURL("water-decals-and-masking-in-the-water-system")] [ExecuteInEditMode] public partial class WaterDecal : MonoBehaviour { diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/WaterExcluder.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/WaterExcluder.cs index 7511119c..3864e462 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/WaterExcluder.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/WaterExcluder.cs @@ -10,7 +10,7 @@ namespace UnityEngine.Rendering.HighDefinition /// [DisallowMultipleComponent] [AddComponentMenu("")] - [HDRPHelpURL("WaterSystem-waterexcluder")] + [HDRPHelpURL("water-exclude-part-of-the-water-surface")] [ExecuteAlways] public partial class WaterExcluder : MonoBehaviour { diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/WaterRendering.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/WaterRendering.cs index 4a05e83e..2defaf02 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/WaterRendering.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/WaterRendering.cs @@ -7,7 +7,7 @@ namespace UnityEngine.Rendering.HighDefinition /// [Serializable, VolumeComponentMenu("Lighting/Water Rendering")] [SupportedOnRenderPipeline(typeof(HDRenderPipelineAsset))] - [HDRPHelpURL("Override-Water-Rendering")] + [HDRPHelpURL("water-use-the-water-system-in-your-project")] public sealed partial class WaterRendering : VolumeComponent { /// diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/WaterSurface/WaterSurface.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/WaterSurface/WaterSurface.cs index 5ed8e75e..f4d68f90 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/WaterSurface/WaterSurface.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/WaterSurface/WaterSurface.cs @@ -79,7 +79,7 @@ namespace UnityEngine.Rendering.HighDefinition /// /// Water surface component. /// - [HDRPHelpURL("WaterSystem")] + [HDRPHelpURL("water")] [DisallowMultipleComponent] [ExecuteInEditMode] public partial class WaterSurface : MonoBehaviour diff --git a/Packages/com.unity.render-pipelines.high-definition/Tests/Editor/HDCameraTests.cs b/Packages/com.unity.render-pipelines.high-definition/Tests/Editor/HDCameraTests.cs new file mode 100644 index 00000000..69eb5dab --- /dev/null +++ b/Packages/com.unity.render-pipelines.high-definition/Tests/Editor/HDCameraTests.cs @@ -0,0 +1,58 @@ +using NUnit.Framework; +using UnityEngine.Experimental.Rendering; + +namespace UnityEngine.Rendering.HighDefinition.Tests +{ + class HDCameraTests + { + [SetUp] + public void Setup() + { + if (GraphicsSettings.currentRenderPipeline is not HDRenderPipelineAsset) + Assert.Ignore("This is an HDRP Tests, and the current pipeline is not HDRP."); + } + + [Test] + public void TestCameraRelativeRendering() + { + GameObject cameraGameObject = new GameObject("Camera"); + var camera = cameraGameObject.AddComponent(); + var hdCamera = new HDCamera(camera); + + if (!VolumeManager.instance.isInitialized) + VolumeManager.instance.Initialize(); + + var positionSettings = new CameraPositionSettings(); + positionSettings.position = new Vector3(100.0f, 300.0f, 500.0f); + positionSettings.rotation = Quaternion.Euler(62.34f, 185.53f, 323.563f); + + var resolution = new Vector4(1920.0f, 1080.0f, 1.0f / 1920.0f, 1.0f / 1080.0f); + float aspect = resolution.x * resolution.w; + + camera.worldToCameraMatrix = positionSettings.ComputeWorldToCameraMatrix(); + camera.projectionMatrix = Matrix4x4.Perspective(75.0f, aspect, 0.1f, 1000.0f); + + var view = camera.worldToCameraMatrix; + var proj = camera.projectionMatrix; + + // Minimal setup for ComputePixelCoordToWorldSpaceViewDirectionMatrix(). + var viewConstants = new HDCamera.ViewConstants(); + viewConstants.viewMatrix = view; + viewConstants.projMatrix = proj; + viewConstants.invViewProjMatrix = (proj * view).inverse; + + // hdCamera.xr must be initialized for ComputePixelCoordToWorldSpaceViewDirectionMatrix(). + var hdrp = HDRenderPipeline.currentPipeline; + hdCamera.Update(hdCamera.frameSettings, hdrp, XRSystem.emptyPass, allocateHistoryBuffers: false); + + var matrix0 = hdCamera.ComputePixelCoordToWorldSpaceViewDirectionMatrix(viewConstants, resolution, aspect, 0); + var matrix1 = hdCamera.ComputePixelCoordToWorldSpaceViewDirectionMatrix(viewConstants, resolution, aspect, 1); + + // These matrices convert a clip space position to a world space view direction, + // therefore should be same regardless of Camera Relative Rendering. + Assert.AreEqual(matrix0, matrix1, $"{matrix0} != {matrix1}"); + + CoreUtils.Destroy(cameraGameObject); + } + } +} diff --git a/Packages/com.unity.render-pipelines.high-definition/Tests/Editor/HDCameraTests.cs.meta b/Packages/com.unity.render-pipelines.high-definition/Tests/Editor/HDCameraTests.cs.meta new file mode 100644 index 00000000..c0a9e3f7 --- /dev/null +++ b/Packages/com.unity.render-pipelines.high-definition/Tests/Editor/HDCameraTests.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 599a7e24f19b4c38a8f23735cf98b54f +timeCreated: 1735265964 \ No newline at end of file diff --git a/Packages/com.unity.render-pipelines.high-definition/package.json b/Packages/com.unity.render-pipelines.high-definition/package.json index 4a62e595..4bfc2a16 100644 --- a/Packages/com.unity.render-pipelines.high-definition/package.json +++ b/Packages/com.unity.render-pipelines.high-definition/package.json @@ -1,17 +1,17 @@ { "name": "com.unity.render-pipelines.high-definition", "description": "The High Definition Render Pipeline (HDRP) is a high-fidelity Scriptable Render Pipeline built by Unity to target modern (Compute Shader compatible) platforms. HDRP utilizes Physically-Based Lighting techniques, linear lighting, HDR lighting, and a configurable hybrid Tile/Cluster deferred/Forward lighting architecture and gives you the tools you need to create games, technical demos, animations, and more to a high graphical standard.", - "version": "17.0.3", + "version": "17.0.4", "unity": "6000.0", "displayName": "High Definition RP", "dependencies": { "com.unity.modules.video": "1.0.0", "com.unity.modules.animation": "1.0.0", "com.unity.modules.imageconversion": "1.0.0", - "com.unity.render-pipelines.core": "17.0.3", - "com.unity.shadergraph": "17.0.3", - "com.unity.visualeffectgraph": "17.0.3", - "com.unity.render-pipelines.high-definition-config": "17.0.3" + "com.unity.render-pipelines.core": "17.0.4", + "com.unity.shadergraph": "17.0.4", + "com.unity.visualeffectgraph": "17.0.4", + "com.unity.render-pipelines.high-definition-config": "17.0.4" }, "keywords": [ "graphics", @@ -100,5 +100,5 @@ ] } ], - "_fingerprint": "d066ab5c07247dcd38c9580d5e750be54570236b" + "_fingerprint": "51792a1ba6925f88f17d1060626c3b35c93eaff5" } diff --git a/Packages/com.unity.shadergraph/CHANGELOG.md b/Packages/com.unity.shadergraph/CHANGELOG.md index 1b4d279a..dab411d4 100644 --- a/Packages/com.unity.shadergraph/CHANGELOG.md +++ b/Packages/com.unity.shadergraph/CHANGELOG.md @@ -10,6 +10,50 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. Version Updated The version number for this package has increased due to a version update of a related graphics package. +## [17.0.3] - 2025-02-13 + +This version is compatible with Unity 6000.0.39f1. + +### Changed +- Removed duplicate LIGHTMAP_ON and DIRLIGHTMAP_COMBINED variants when generating shaders for builtin-deferred. +- Added a new set of sample content - Shader Graph UGUI Shaders - to the Shader Graph package that contains examples of how to use the new Canvas target in Shader Graph to create dynamic UI elements. This new sample can be imported from the Sample tab of the Package Manager after selecting the Shader Graph package + +### Fixed +- Added an issue where convert-to subgraph would sometimes result in an exception. +- Added an issue where the GI Node would only display correctly after deserialization. +- Added support for perceptual color mode for gradients in shader graph. +- Fixed an issue where an HDRP fullscreen shader graph imported into a URP project would fail to import under some circumstances. +- Fixed shader graph built-in pipeline variants not getting stripped when an SRP is active. +- Fixed an issue where moving a property node in a Shader Graph with no targets would log an error. +- Fixed an issue where the Custom Function node's "Body" field would expand off-screen instead of scrolling. +- Disallowed shader variant related settings to be set to negative values. +- Fixed a null reference exception when shader variant project settings were changed under certain circumstances. +- Fixed an issue where the Graph Inspector would not update after changing a node's precision from the context menu. +- Fixed an issue where using a color picker would cause the main preview to display cyan until the color picker was closed. +- Fixed an issue where some keyboard shortcuts did not display with the correct alignment in context menus. +- Fixed an issue so users can no longer select 'Delete' for context blocks. +- Fixed identifier collision detection on properties. +- Added sticky note checks to the group shortcuts. +- Fixed node previews toggle shortcut. +- Fixed an issue in ShaderGraph where undoing changes to a property after modifying its value in the Graph Inspector would cause the property to become deselected. +- Fixed an issue in Shader Graph with an undeclared identifier error around foveated rendering area. +- Fixed a bug that Normal From Height node in a shader graph might return an invalid value when using 16-bit half precision. +- Fixed 'Objects are trying to be loaded during a domain backup' errors due to invalid serialization of some shader graphs. +- Changed the name displayed in a Graph inspector when a selected BlockNode has changed. +- Fixed an issue so that pasting an empty group positions it based on the cursor's location. +- Fixed an issue with low quality Graph Inspector and Open Shader Graph User Manual icons. +- Added padding to Shader Graph Preferences settings. +- Addressed an issue where precision mismatch could result in an asset failing to import. +- Fixed an issue that caused errors in the Feature Examples sample content for Shader Graph. +- Fixed the issue with `NullReferenceException` when updating a legacy node for second time through undo. +- Fixed an issue where a shader graph was reverted to its last saved state when entering Play Mode without saving changes. +- [Metal] Fix shader compilation errors due to Foveated Rendering when building URP 3D template. +- Fixed an issue where Unity pragmas were not used in files included by the Custom Function Node, and added a "Use Pragmas" toggle to enable/disable them as needed. +- Fixed an issue where the Main Light Direction node always returned 0 on the built-in render pipeline. +- Fixed an issue where the shader graph was not marked dirty when toggling checkboxes in its Graph Settings. +- Fixed missing documentation about the Custom Render Texture in Shader Graph. +- Fixed "Shader error in 'ProBuilder6/Standard Vertex Color': 'PBRDeferredFragment'" error logged in the console when compiling the shader. + ## [17.0.2] - 2024-04-02 This version is compatible with Unity 6000.0.0b15. diff --git a/Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/PBRDeferredPass.hlsl b/Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/PBRDeferredPass.hlsl index 2230ce87..a36cea6f 100644 --- a/Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/PBRDeferredPass.hlsl +++ b/Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/PBRDeferredPass.hlsl @@ -55,7 +55,7 @@ void PBRDeferredFragment(v2f_surf IN, SurfaceOutputStandard o, out half4 outGBuffer1 : SV_Target1, out half4 outGBuffer2 : SV_Target2, out half4 outEmission : SV_Target3 -#if defined(SHADOWS_SHADOWMASK) && (UNITY_ALLOWED_MRT_COUNT > 4) +#if OUTPUT_SHADOWMASK , out half4 outShadowMask : SV_Target4 #endif ) @@ -126,7 +126,7 @@ void PBRDeferredFragment(v2f_surf IN, SurfaceOutputStandard o, // call lighting function to output g-buffer outEmission = LightingStandard_Deferred (o, worldViewDir, gi, outGBuffer0, outGBuffer1, outGBuffer2); - #if defined(SHADOWS_SHADOWMASK) && (UNITY_ALLOWED_MRT_COUNT > 4) + #if OUTPUT_SHADOWMASK outShadowMask = UnityGetRawBakedOcclusions (IN.lmap.xy, worldPos); #endif #ifndef UNITY_HDR_ON diff --git a/Packages/com.unity.shadergraph/package.json b/Packages/com.unity.shadergraph/package.json index 21c4ec45..dd6928a7 100644 --- a/Packages/com.unity.shadergraph/package.json +++ b/Packages/com.unity.shadergraph/package.json @@ -1,12 +1,12 @@ { "name": "com.unity.shadergraph", "description": "The Shader Graph package adds a visual Shader editing tool to Unity. You can use this tool to create Shaders in a visual way instead of writing code. Specific render pipelines can implement specific graph features. Currently, both the High Definition Rendering Pipeline and the Universal Rendering Pipeline support Shader Graph.", - "version": "17.0.3", + "version": "17.0.4", "unity": "6000.0", "displayName": "Shader Graph", "dependencies": { - "com.unity.render-pipelines.core": "17.0.3", - "com.unity.searcher": "4.9.2" + "com.unity.render-pipelines.core": "17.0.4", + "com.unity.searcher": "4.9.3" }, "samples": [ { @@ -36,7 +36,12 @@ "com.unity.render-pipelines.core/Samples~/Common", "com.unity.shadergraph/Samples~/Common" ] + }, + { + "displayName": "UGUI Shaders", + "description": "This sample is all about creating 2D UI elements using the Canvas target in HDRP or URP. It provides a set of subgraphs to speed up and simplify the process of creating buttons, widgets, backgrounds, and other UI elements. It also contains examples of how these subgraphs can be used together to create dynamic UI elements that are fast to render and don't require any texture memory.", + "path": "Samples~/UGUIShaders" } ], - "_fingerprint": "9111176982208cf007caa931c3cf2716ceec4632" + "_fingerprint": "425e21ee5890a7be1fc569c29e55bc023ce57d08" } diff --git a/Packages/com.unity.ugui/Editor/TMP/TMPro_ContextMenus.cs b/Packages/com.unity.ugui/Editor/TMP/TMPro_ContextMenus.cs index 0cee3dfc..2fd32cbc 100644 --- a/Packages/com.unity.ugui/Editor/TMP/TMPro_ContextMenus.cs +++ b/Packages/com.unity.ugui/Editor/TMP/TMPro_ContextMenus.cs @@ -2,7 +2,8 @@ using UnityEditor; using System.IO; using System.Collections; - +using UnityEngine.TextCore.LowLevel; +using UnityEngine.TextCore.Text; namespace TMPro.EditorUtilities { @@ -420,6 +421,29 @@ namespace TMPro.EditorUtilities TMPro_EventManager.ON_FONT_PROPERTY_CHANGED(true, fontAsset); } + [MenuItem("CONTEXT/TMP_FontAsset/Reset FaceInfo", priority = 101)] + static void ResetFaceInfo(MenuCommand command) + { + TMP_FontAsset fontAsset = command.context as TMP_FontAsset; + + if (fontAsset == null) + return; + + if (Selection.activeObject != fontAsset) + Selection.activeObject = fontAsset; + + if (fontAsset.LoadFontFace() != FontEngineError.Success) + return; + + fontAsset.faceInfo = FontEngine.GetFaceInfo(); + TextResourceManager.RebuildFontAssetCache(); + TextEventManager.ON_FONT_PROPERTY_CHANGED(true, fontAsset); + + EditorUtility.SetDirty(fontAsset); + AssetDatabase.SaveAssetIfDirty(fontAsset); + AssetDatabase.Refresh(); + } + /// /// Import all font features /// diff --git a/Packages/com.unity.ugui/Editor/TMP/TMPro_FontAssetCreatorWindow.cs b/Packages/com.unity.ugui/Editor/TMP/TMPro_FontAssetCreatorWindow.cs index 65434777..001203e7 100644 --- a/Packages/com.unity.ugui/Editor/TMP/TMPro_FontAssetCreatorWindow.cs +++ b/Packages/com.unity.ugui/Editor/TMP/TMPro_FontAssetCreatorWindow.cs @@ -474,13 +474,13 @@ namespace TMPro.EditorUtilities GUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); - m_PaddingFieldValue = EditorGUILayout.FloatField("Padding", m_PaddingFieldValue); + m_PaddingFieldValue = Mathf.Max(EditorGUILayout.FloatField("Padding", m_PaddingFieldValue), 0); int selection = m_PaddingMode == PaddingMode.Undefined || m_PaddingMode == PaddingMode.Pixel ? 1 : 0; selection = GUILayout.SelectionGrid(selection, k_PaddingOptionLabels, 2); if (m_PaddingMode == PaddingMode.Percentage) - m_PaddingFieldValue = (int)(m_PaddingFieldValue + 0.5f); + m_PaddingFieldValue = Mathf.Min((int)(m_PaddingFieldValue + 0.5f), float.MaxValue); if (EditorGUI.EndChangeCheck()) { diff --git a/Packages/com.unity.ugui/Package Resources/TMP Essential Resources.unitypackage b/Packages/com.unity.ugui/Package Resources/TMP Essential Resources.unitypackage index 30871545..b0cab8de 100644 --- a/Packages/com.unity.ugui/Package Resources/TMP Essential Resources.unitypackage +++ b/Packages/com.unity.ugui/Package Resources/TMP Essential Resources.unitypackage @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5a258f71e21757d380416b238e099772e09dbead695889add09268d88f4b16a6 -size 888625 +oid sha256:58564ec64cef8a8cea3d0b8ffb5e6fecf4176d544a2f6a29a2b43a0a33256431 +size 941722 diff --git a/Packages/com.unity.ugui/Package Resources/TMP Examples & Extras.unitypackage b/Packages/com.unity.ugui/Package Resources/TMP Examples & Extras.unitypackage index b7ba6e33..f0fa3eb3 100644 --- a/Packages/com.unity.ugui/Package Resources/TMP Examples & Extras.unitypackage +++ b/Packages/com.unity.ugui/Package Resources/TMP Examples & Extras.unitypackage @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c0201ed3d2a50c80af8eb10cea7e65393191a08dbff54ecd455672fc141832d2 -size 2104106 +oid sha256:7a963b3b2fdc78bd96b04b9a2e31b28f463bbbb38fd3963667a964746fe18fb8 +size 2120925 diff --git a/Packages/com.unity.ugui/Runtime/TMP/TMP_DefaultControls.cs b/Packages/com.unity.ugui/Runtime/TMP/TMP_DefaultControls.cs index c2793ad0..af82c72e 100644 --- a/Packages/com.unity.ugui/Runtime/TMP/TMP_DefaultControls.cs +++ b/Packages/com.unity.ugui/Runtime/TMP/TMP_DefaultControls.cs @@ -87,7 +87,11 @@ namespace TMPro if (parent == null) return; +#if UNITY_EDITOR + Undo.SetTransformParent(child.transform, parent.transform, ""); +#else child.transform.SetParent(parent.transform, false); +#endif SetLayerRecursively(child, parent.layer); } diff --git a/Packages/com.unity.ugui/Runtime/TMP/TMP_FontAsset.cs b/Packages/com.unity.ugui/Runtime/TMP/TMP_FontAsset.cs index 742c1aff..5f4debc1 100644 --- a/Packages/com.unity.ugui/Runtime/TMP/TMP_FontAsset.cs +++ b/Packages/com.unity.ugui/Runtime/TMP/TMP_FontAsset.cs @@ -6,6 +6,7 @@ using UnityEngine.Serialization; using UnityEngine.TextCore; using UnityEngine.TextCore.LowLevel; using Unity.Profiling; +using Unity.Jobs.LowLevel.Unsafe; #if UNITY_EDITOR using UnityEditor; @@ -807,11 +808,20 @@ namespace TMPro m_AtlasPadding = (int)material.GetFloat(ShaderUtilities.ID_GradientScale) - 1; } - #if TEXTCORE_FONT_ENGINE_1_5_OR_NEWER +#if TEXTCORE_FONT_ENGINE_1_5_OR_NEWER // Update Units per EM for pre-existing font assets. - if (m_FaceInfo.unitsPerEM == 0) - m_FaceInfo.unitsPerEM = FontEngine.GetFaceInfo().unitsPerEM; - #endif + if (m_FaceInfo.unitsPerEM == 0 && atlasPopulationMode != AtlasPopulationMode.Static) + { + // Only retrieve Units Per EM if we are on the main thread. + if (!JobsUtility.IsExecutingJob) + { + m_FaceInfo.unitsPerEM = FontEngine.GetFaceInfo().unitsPerEM; + Debug.Log("Font Asset [" + name + "] Units Per EM set to " + m_FaceInfo.unitsPerEM + ". Please commit the newly serialized value."); + } + else + Debug.LogError("Font Asset [" + name + "] is missing Units Per EM. Please select the 'Reset FaceInfo' menu item on Font Asset [" + name + "] to ensure proper serialization."); + } +#endif // Compute hash codes for various properties of the font asset used for lookup. hashCode = TMP_TextUtilities.GetHashCode(this.name); @@ -1145,19 +1155,22 @@ namespace TMPro //internal HashSet FallbackSearchQueryLookup = new HashSet(); - internal void AddCharacterToLookupCache(uint unicode, TMP_Character character) + internal void AddCharacterToLookupCache(uint unicode, TMP_Character character, FontStyles fontStyle = FontStyles.Normal, FontWeight fontWeight = FontWeight.Regular, bool isAlternativeTypeface = false) { - m_CharacterLookupDictionary.Add(unicode, character); + uint lookupKey = unicode; + + // Compute composite lookup key if a font style or weight is used. + if (fontStyle != FontStyles.Normal || fontWeight != FontWeight.Regular) + lookupKey = (((isAlternativeTypeface ? 0x80u : 0u) | ((uint)fontStyle << 4) | ((uint)fontWeight / 100)) << 24) | unicode; - // Add font asset to fallback references. - //FallbackSearchQueryLookup.Add(character.textAsset.instanceID); + m_CharacterLookupDictionary.TryAdd(lookupKey, character); } /// /// /// /// - FontEngineError LoadFontFace() + internal FontEngineError LoadFontFace() { if (m_AtlasPopulationMode == AtlasPopulationMode.Dynamic) { diff --git a/Packages/com.unity.ugui/Runtime/TMP/TMP_FontAssetUtilities.cs b/Packages/com.unity.ugui/Runtime/TMP/TMP_FontAssetUtilities.cs index a5b59245..544b1b9a 100644 --- a/Packages/com.unity.ugui/Runtime/TMP/TMP_FontAssetUtilities.cs +++ b/Packages/com.unity.ugui/Runtime/TMP/TMP_FontAssetUtilities.cs @@ -65,7 +65,7 @@ namespace TMPro private static TMP_Character GetCharacterFromFontAsset_Internal(uint unicode, TMP_FontAsset sourceFontAsset, bool includeFallbacks, FontStyles fontStyle, FontWeight fontWeight, out bool isAlternativeTypeface) { isAlternativeTypeface = false; - TMP_Character character = null; + TMP_Character character; #region FONT WEIGHT AND FONT STYLE HANDLING // Determine if a font weight or style is used. If so check if an alternative typeface is assigned for the given weight and / or style. @@ -73,6 +73,31 @@ namespace TMPro if (isItalic || fontWeight != FontWeight.Regular) { + // Check if character is already cached using the composite unicode value the takes into consideration the font style and weight + uint compositeUnicodeLookupKey = ((0x80u | ((uint)fontStyle << 4) | ((uint)fontWeight / 100)) << 24) | unicode; + if (sourceFontAsset.characterLookupTable.TryGetValue(compositeUnicodeLookupKey, out character)) + { + // Set isAlternativeTypeface + isAlternativeTypeface = true; + + if (character.textAsset is not null) + return character; + + // Remove character from lookup table + sourceFontAsset.characterLookupTable.Remove(unicode); + } + else if (sourceFontAsset.characterLookupTable.TryGetValue(compositeUnicodeLookupKey & 0x7FFFFFFF, out character)) + { + // Set isAlternativeTypeface + isAlternativeTypeface = false; + + if (character.textAsset is not null) + return character; + + // Remove character from lookup table + sourceFontAsset.characterLookupTable.Remove(unicode); + } + // Get reference to the font weight pairs of the given font asset. TMP_FontWeightPair[] fontWeights = sourceFontAsset.fontWeightTable; @@ -114,7 +139,7 @@ namespace TMPro { if (temp.characterLookupTable.TryGetValue(unicode, out character)) { - if (character.textAsset != null) + if (character.textAsset is not null) { isAlternativeTypeface = true; return character; @@ -132,32 +157,21 @@ namespace TMPro return character; } - - // Check if the source font file contains the requested character. - //if (TryGetCharacterFromFontFile(unicode, fontAsset, out characterData)) - //{ - // isAlternativeTypeface = true; - - // return characterData; - //} - - // If we find the requested character, we add it to the font asset character table - // and return its character data. - // We also add this character to the list of characters we will need to add to the font atlas. - // We assume the font atlas has room otherwise this font asset should not be marked as dynamic. - // Alternatively, we could also add multiple pages of font atlas textures (feature consideration). } - - // At this point, we were not able to find the requested character in the alternative typeface - // so we check the source font asset and its potential fallbacks. } + + // Search potential fallbacks of the source font asset + if (includeFallbacks && sourceFontAsset.fallbackFontAssetTable != null) + return SearchFallbacksForCharacter(unicode, sourceFontAsset, fontStyle, fontWeight, out isAlternativeTypeface); + + return null; } #endregion - // Search the source font asset for the requested character. + // Search the source font asset for the requested character if (sourceFontAsset.characterLookupTable.TryGetValue(unicode, out character)) { - if (character.textAsset != null) + if (character.textAsset is not null) return character; // Remove character from lookup table @@ -171,36 +185,40 @@ namespace TMPro } // Search fallback font assets if we still don't have a valid character and include fallback is set to true. - if (character == null && includeFallbacks && sourceFontAsset.fallbackFontAssetTable != null) - { - // Get reference to the list of fallback font assets. - List fallbackFontAssets = sourceFontAsset.fallbackFontAssetTable; - int fallbackCount = fallbackFontAssets.Count; + if (includeFallbacks && sourceFontAsset.fallbackFontAssetTable != null) + return SearchFallbacksForCharacter(unicode, sourceFontAsset, fontStyle, fontWeight, out isAlternativeTypeface); + + return null; + } - if (fallbackCount == 0) - return null; + private static TMP_Character SearchFallbacksForCharacter(uint unicode, TMP_FontAsset sourceFontAsset, FontStyles fontStyle, FontWeight fontWeight, out bool isAlternativeTypeface) + { + isAlternativeTypeface = false; - for (int i = 0; i < fallbackCount; i++) - { - TMP_FontAsset temp = fallbackFontAssets[i]; + // Get reference to the list of fallback font assets. + List fallbackFontAssets = sourceFontAsset.fallbackFontAssetTable; + int fallbackCount = fallbackFontAssets.Count; - if (temp == null) - continue; + if (fallbackCount == 0) + return null; - int id = temp.instanceID; + for (int i = 0; i < fallbackCount; i++) + { + TMP_FontAsset temp = fallbackFontAssets[i]; - // Try adding font asset to search list. If already present skip to the next one otherwise check if it contains the requested character. - if (k_SearchedAssets.Add(id) == false) - continue; + if (temp == null) + continue; - // Add reference to this search query - //sourceFontAsset.FallbackSearchQueryLookup.Add(id); + int id = temp.instanceID; - character = GetCharacterFromFontAsset_Internal(unicode, temp, true, fontStyle, fontWeight, out isAlternativeTypeface); + // Try adding font asset to search list. If already present skip to the next one otherwise check if it contains the requested character. + if (k_SearchedAssets.Add(id) == false) + continue; - if (character != null) - return character; - } + TMP_Character character = GetCharacterFromFontAsset_Internal(unicode, temp, true, fontStyle, fontWeight, out isAlternativeTypeface); + + if (character != null) + return character; } return null; diff --git a/Packages/com.unity.ugui/Runtime/TMP/TMP_Text.cs b/Packages/com.unity.ugui/Runtime/TMP/TMP_Text.cs index 2854f87a..6b0b1f35 100644 --- a/Packages/com.unity.ugui/Runtime/TMP/TMP_Text.cs +++ b/Packages/com.unity.ugui/Runtime/TMP/TMP_Text.cs @@ -6091,19 +6091,13 @@ namespace TMPro { //Debug.Log("Unicode: " + unicode.ToString("X8")); - TMP_Character character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, fontAsset, false, fontStyle, fontWeight, out isUsingAlternativeTypeface); - - if (character != null) - return character; - - // Search potential list of fallback font assets assigned to the font asset. - if (fontAsset.m_FallbackFontAssetTable != null && fontAsset.m_FallbackFontAssetTable.Count > 0) - character = TMP_FontAssetUtilities.GetCharacterFromFontAssets(unicode, fontAsset, fontAsset.m_FallbackFontAssetTable, true, fontStyle, fontWeight, out isUsingAlternativeTypeface); + // Search the font asset and potential fallback for the requested character + TMP_Character character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, fontAsset, true, fontStyle, fontWeight, out isUsingAlternativeTypeface); if (character != null) { // Add character to font asset lookup cache - fontAsset.AddCharacterToLookupCache(unicode, character); + fontAsset.AddCharacterToLookupCache(unicode, character, fontStyle, fontWeight, isUsingAlternativeTypeface); return character; } @@ -6117,11 +6111,8 @@ namespace TMPro // Use material and index of primary font asset. if (character != null) { - m_currentMaterialIndex = 0; - m_currentMaterial = m_materialReferences[0].material; - // Add character to font asset lookup cache - fontAsset.AddCharacterToLookupCache(unicode, character); + fontAsset.AddCharacterToLookupCache(unicode, character, fontStyle, fontWeight, isUsingAlternativeTypeface); return character; } @@ -6133,7 +6124,7 @@ namespace TMPro if (character != null) { // Add character to font asset lookup cache - fontAsset.AddCharacterToLookupCache(unicode, character); + fontAsset.AddCharacterToLookupCache(unicode, character, fontStyle, fontWeight, isUsingAlternativeTypeface); return character; } @@ -6155,7 +6146,7 @@ namespace TMPro if (character != null) { // Add character to font asset lookup cache - fontAsset.AddCharacterToLookupCache(unicode, character); + fontAsset.AddCharacterToLookupCache(unicode, character, fontStyle, fontWeight, isUsingAlternativeTypeface); return character; } @@ -6167,7 +6158,7 @@ namespace TMPro if (character != null) { // Add character to font asset lookup cache - fontAsset.AddCharacterToLookupCache(unicode, character); + fontAsset.AddCharacterToLookupCache(unicode, character, fontStyle, fontWeight, isUsingAlternativeTypeface); return character; } @@ -6181,6 +6172,44 @@ namespace TMPro return spriteCharacter; } + // Since we have been unable to locate the character thus far using the designated font style and weight. Attempt to locate this character using normal style and regular font weight in order to synthesize it. + if (fontStyle != FontStyles.Normal || fontWeight != FontWeight.Regular) + { + character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, fontAsset, true, FontStyles.Normal, FontWeight.Regular, out isUsingAlternativeTypeface); + + if (character != null) + { + // Add character to font asset lookup cache + fontAsset.AddCharacterToLookupCache(unicode, character, fontStyle, fontWeight, isUsingAlternativeTypeface); + + return character; + } + + // Search potential Global fallback font assets. + if (TMP_Settings.fallbackFontAssets != null && TMP_Settings.fallbackFontAssets.Count > 0) + character = TMP_FontAssetUtilities.GetCharacterFromFontAssets(unicode, fontAsset, TMP_Settings.fallbackFontAssets, true, FontStyles.Normal, FontWeight.Regular, out isUsingAlternativeTypeface); + + if (character != null) + { + // Add character to font asset lookup cache + fontAsset.AddCharacterToLookupCache(unicode, character, fontStyle, fontWeight, isUsingAlternativeTypeface); + + return character; + } + + // Search for the character in the Default Font Asset assigned in the TMP Settings file. + if (TMP_Settings.defaultFontAsset != null) + character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, TMP_Settings.defaultFontAsset, true, FontStyles.Normal, FontWeight.Regular, out isUsingAlternativeTypeface); + + if (character != null) + { + // Add character to font asset lookup cache + fontAsset.AddCharacterToLookupCache(unicode, character, fontStyle, fontWeight, isUsingAlternativeTypeface); + + return character; + } + } + return null; } diff --git a/Packages/com.unity.ugui/Runtime/TMP/TextMeshPro.cs b/Packages/com.unity.ugui/Runtime/TMP/TextMeshPro.cs index e34e1852..05abff22 100644 --- a/Packages/com.unity.ugui/Runtime/TMP/TextMeshPro.cs +++ b/Packages/com.unity.ugui/Runtime/TMP/TextMeshPro.cs @@ -1651,34 +1651,34 @@ namespace TMPro unicode = textProcessingArray[i].unicode = (uint)TMP_Settings.missingGlyphCharacter == 0 ? 9633 : (uint)TMP_Settings.missingGlyphCharacter; // Check for the missing glyph character in the currently assigned font asset and its fallbacks - character = TMP_FontAssetUtilities.GetCharacterFromFontAsset((uint)unicode, m_currentFontAsset, true, m_FontStyleInternal, m_FontWeightInternal, out isUsingAlternativeTypeface); + character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, m_currentFontAsset, true, FontStyles.Normal, FontWeight.Regular, out isUsingAlternativeTypeface); if (character == null) { // Search for the missing glyph character in the TMP Settings Fallback list. if (TMP_Settings.fallbackFontAssets != null && TMP_Settings.fallbackFontAssets.Count > 0) - character = TMP_FontAssetUtilities.GetCharacterFromFontAssets(unicode, m_currentFontAsset, TMP_Settings.fallbackFontAssets, true, m_FontStyleInternal, m_FontWeightInternal, out isUsingAlternativeTypeface); + character = TMP_FontAssetUtilities.GetCharacterFromFontAssets(unicode, m_currentFontAsset, TMP_Settings.fallbackFontAssets, true, FontStyles.Normal, FontWeight.Regular, out isUsingAlternativeTypeface); } if (character == null) { // Search for the missing glyph in the TMP Settings Default Font Asset. if (TMP_Settings.defaultFontAsset != null) - character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, TMP_Settings.defaultFontAsset, true, m_FontStyleInternal, m_FontWeightInternal, out isUsingAlternativeTypeface); + character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, TMP_Settings.defaultFontAsset, true, FontStyles.Normal, FontWeight.Regular, out isUsingAlternativeTypeface); } if (character == null) { // Use Space (32) Glyph from the currently assigned font asset. unicode = textProcessingArray[i].unicode = 32; - character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, m_currentFontAsset, true, m_FontStyleInternal, m_FontWeightInternal, out isUsingAlternativeTypeface); + character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, m_currentFontAsset, true, FontStyles.Normal, FontWeight.Regular, out isUsingAlternativeTypeface); } if (character == null) { // Use End of Text (0x03) Glyph from the currently assigned font asset. unicode = textProcessingArray[i].unicode = 0x03; - character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, m_currentFontAsset, true, m_FontStyleInternal, m_FontWeightInternal, out isUsingAlternativeTypeface); + character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, m_currentFontAsset, true, FontStyles.Normal, FontWeight.Regular, out isUsingAlternativeTypeface); } if (!TMP_Settings.warningsDisabled) @@ -1700,6 +1700,7 @@ namespace TMPro { isUsingFallbackOrAlternativeTypeface = true; m_currentFontAsset = character.textAsset as TMP_FontAsset; + m_currentMaterialIndex = MaterialReference.AddMaterialReference(m_currentFontAsset.material, m_currentFontAsset, ref m_materialReferences, m_materialReferenceIndexLookup); } #region VARIATION SELECTOR diff --git a/Packages/com.unity.ugui/Runtime/TMP/TextMeshProUGUI.cs b/Packages/com.unity.ugui/Runtime/TMP/TextMeshProUGUI.cs index bf9ccc78..1bfb4740 100644 --- a/Packages/com.unity.ugui/Runtime/TMP/TextMeshProUGUI.cs +++ b/Packages/com.unity.ugui/Runtime/TMP/TextMeshProUGUI.cs @@ -1966,34 +1966,34 @@ namespace TMPro unicode = textProcessingArray[i].unicode = (uint)TMP_Settings.missingGlyphCharacter == 0 ? 9633 : (uint)TMP_Settings.missingGlyphCharacter; // Check for the missing glyph character in the currently assigned font asset and its fallbacks - character = TMP_FontAssetUtilities.GetCharacterFromFontAsset((uint)unicode, m_currentFontAsset, true, m_FontStyleInternal, m_FontWeightInternal, out isUsingAlternativeTypeface); + character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, m_currentFontAsset, true, FontStyles.Normal, FontWeight.Regular, out isUsingAlternativeTypeface); if (character == null) { // Search for the missing glyph character in the TMP Settings Fallback list. if (TMP_Settings.fallbackFontAssets != null && TMP_Settings.fallbackFontAssets.Count > 0) - character = TMP_FontAssetUtilities.GetCharacterFromFontAssets(unicode, m_currentFontAsset, TMP_Settings.fallbackFontAssets, true, m_FontStyleInternal, m_FontWeightInternal, out isUsingAlternativeTypeface); + character = TMP_FontAssetUtilities.GetCharacterFromFontAssets(unicode, m_currentFontAsset, TMP_Settings.fallbackFontAssets, true, FontStyles.Normal, FontWeight.Regular, out isUsingAlternativeTypeface); } if (character == null) { // Search for the missing glyph in the TMP Settings Default Font Asset. if (TMP_Settings.defaultFontAsset != null) - character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, TMP_Settings.defaultFontAsset, true, m_FontStyleInternal, m_FontWeightInternal, out isUsingAlternativeTypeface); + character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, TMP_Settings.defaultFontAsset, true, FontStyles.Normal, FontWeight.Regular, out isUsingAlternativeTypeface); } if (character == null) { // Use Space (32) Glyph from the currently assigned font asset. unicode = textProcessingArray[i].unicode = 32; - character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, m_currentFontAsset, true, m_FontStyleInternal, m_FontWeightInternal, out isUsingAlternativeTypeface); + character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, m_currentFontAsset, true, FontStyles.Normal, FontWeight.Regular, out isUsingAlternativeTypeface); } if (character == null) { // Use End of Text (0x03) Glyph from the currently assigned font asset. unicode = textProcessingArray[i].unicode = 0x03; - character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, m_currentFontAsset, true, m_FontStyleInternal, m_FontWeightInternal, out isUsingAlternativeTypeface); + character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, m_currentFontAsset, true, FontStyles.Normal, FontWeight.Regular, out isUsingAlternativeTypeface); } if (!TMP_Settings.warningsDisabled) @@ -2015,6 +2015,7 @@ namespace TMPro { isUsingFallbackOrAlternativeTypeface = true; m_currentFontAsset = character.textAsset as TMP_FontAsset; + m_currentMaterialIndex = MaterialReference.AddMaterialReference(m_currentFontAsset.material, m_currentFontAsset, ref m_materialReferences, m_materialReferenceIndexLookup); } #region VARIATION SELECTOR diff --git a/Packages/com.unity.ugui/Tests/Editor/TMP/Unity.TextMeshPro.Editor.Tests.asmdef b/Packages/com.unity.ugui/Tests/Editor/TMP/Unity.TextMeshPro.Editor.Tests.asmdef index adb75e25..c9e16102 100644 --- a/Packages/com.unity.ugui/Tests/Editor/TMP/Unity.TextMeshPro.Editor.Tests.asmdef +++ b/Packages/com.unity.ugui/Tests/Editor/TMP/Unity.TextMeshPro.Editor.Tests.asmdef @@ -1,17 +1,27 @@ { "name": "Unity.TextMeshPro.Editor.Tests", + "rootNamespace": "", "references": [ "Unity.TextMeshPro", - "Unity.TextMeshPro.Editor" + "Unity.TextMeshPro.Editor", + "UnityEngine.TestRunner", + "UnityEditor.TestRunner" ], - "optionalUnityReferences": [ - "TestAssemblies" - ], - "defineConstraints": [ - "UNITY_INCLUDE_TESTS" - ], "includePlatforms": [ "Editor" ], - "excludePlatforms": [] + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [ + "nunit.framework.dll" + ], + "autoReferenced": false, + "defineConstraints": [ + "UNITY_INCLUDE_TESTS", + "UNITY_INCLUDE_TESTS", + "UGUI_TESTS_ENABLED" + ], + "versionDefines": [], + "noEngineReferences": false } \ No newline at end of file diff --git a/Packages/com.unity.ugui/Tests/Editor/UGUI/UI/PropertyDrawers/PropertyDrawerTests.cs b/Packages/com.unity.ugui/Tests/Editor/UGUI/UI/PropertyDrawers/PropertyDrawerTests.cs index 5f87c3cc..c9b2a08e 100644 --- a/Packages/com.unity.ugui/Tests/Editor/UGUI/UI/PropertyDrawers/PropertyDrawerTests.cs +++ b/Packages/com.unity.ugui/Tests/Editor/UGUI/UI/PropertyDrawers/PropertyDrawerTests.cs @@ -51,7 +51,7 @@ public class PropertyDrawerTests static PropertyDrawerTestsWindow window; [UnitySetUp] - [MenuItem("Tests/Open Property Drawer Test Window")] + // WW1MOD: Disabled this menu item [MenuItem("Tests/Open Property Drawer Test Window")] public static IEnumerator SetUp() { VisualTreeBindingsUpdater.disableBindingsThrottling = true; diff --git a/Packages/com.unity.ugui/Tests/Editor/UGUI/UnityEditor.UI.EditorTests.asmdef b/Packages/com.unity.ugui/Tests/Editor/UGUI/UnityEditor.UI.EditorTests.asmdef index 8900ceb9..e7ceab95 100644 --- a/Packages/com.unity.ugui/Tests/Editor/UGUI/UnityEditor.UI.EditorTests.asmdef +++ b/Packages/com.unity.ugui/Tests/Editor/UGUI/UnityEditor.UI.EditorTests.asmdef @@ -1,14 +1,26 @@ { "name": "UnityEditor.UI.EditorTests", + "rootNamespace": "", "references": [ "UnityEditor.UI", - "UnityEngine.UI" - ], - "optionalUnityReferences": [ - "TestAssemblies" + "UnityEngine.UI", + "UnityEngine.TestRunner", + "UnityEditor.TestRunner" ], "includePlatforms": [ "Editor" ], - "excludePlatforms": [] -} + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [ + "nunit.framework.dll" + ], + "autoReferenced": false, + "defineConstraints": [ + "UNITY_INCLUDE_TESTS", + "UGUI_TESTS_ENABLED" + ], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Packages/com.unity.ugui/Tests/Runtime/TMP/Unity.TextMeshPro.Tests.asmdef b/Packages/com.unity.ugui/Tests/Runtime/TMP/Unity.TextMeshPro.Tests.asmdef index f0c5260e..d3c8be29 100644 --- a/Packages/com.unity.ugui/Tests/Runtime/TMP/Unity.TextMeshPro.Tests.asmdef +++ b/Packages/com.unity.ugui/Tests/Runtime/TMP/Unity.TextMeshPro.Tests.asmdef @@ -1,14 +1,24 @@ { "name": "Unity.TextMeshPro.Tests", + "rootNamespace": "", "references": [ - "Unity.TextMeshPro" + "Unity.TextMeshPro", + "UnityEngine.TestRunner", + "UnityEditor.TestRunner" ], - "optionalUnityReferences": [ - "TestAssemblies" - ], - "defineConstraints": [ - "UNITY_INCLUDE_TESTS" - ], "includePlatforms": [], - "excludePlatforms": [] + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [ + "nunit.framework.dll" + ], + "autoReferenced": false, + "defineConstraints": [ + "UNITY_INCLUDE_TESTS", + "UNITY_INCLUDE_TESTS", + "UGUI_TESTS_ENABLED" + ], + "versionDefines": [], + "noEngineReferences": false } \ No newline at end of file diff --git a/Packages/com.unity.ugui/Tests/Runtime/UGUI/UnityEngine.UI.Tests.asmdef b/Packages/com.unity.ugui/Tests/Runtime/UGUI/UnityEngine.UI.Tests.asmdef index b598da30..73f23750 100644 --- a/Packages/com.unity.ugui/Tests/Runtime/UGUI/UnityEngine.UI.Tests.asmdef +++ b/Packages/com.unity.ugui/Tests/Runtime/UGUI/UnityEngine.UI.Tests.asmdef @@ -1,5 +1,6 @@ { "name": "UnityEngine.UI.Tests", + "rootNamespace": "", "references": [ "UnityEngine.UI", "UnityEngine.TestRunner", @@ -14,7 +15,8 @@ ], "autoReferenced": false, "defineConstraints": [ - "UNITY_INCLUDE_TESTS" + "UNITY_INCLUDE_TESTS", + "UGUI_TESTS_ENABLED" ], "versionDefines": [ { @@ -39,4 +41,4 @@ } ], "noEngineReferences": false -} +} \ No newline at end of file diff --git a/Packages/com.unity.ugui/package.json b/Packages/com.unity.ugui/package.json index b3a1e386..ed6919c2 100644 --- a/Packages/com.unity.ugui/package.json +++ b/Packages/com.unity.ugui/package.json @@ -19,5 +19,5 @@ "com.unity.modules.ui": "1.0.0", "com.unity.modules.imgui": "1.0.0" }, - "_fingerprint": "fd5da3b4bec8d043b01c30177bd62059c5fa36d0" + "_fingerprint": "03407c6d875144b0a8ffdc0af3e0d5cccfa5a4ae" } diff --git a/Packages/com.unity.visualeffectgraph/CHANGELOG.md b/Packages/com.unity.visualeffectgraph/CHANGELOG.md index d62ab234..121da2c2 100644 --- a/Packages/com.unity.visualeffectgraph/CHANGELOG.md +++ b/Packages/com.unity.visualeffectgraph/CHANGELOG.md @@ -10,6 +10,94 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. Version Updated The version number for this package has increased due to a version update of a related graphics package. +## [17.0.3] - 2025-02-13 + +This version is compatible with Unity 6000.0.39f1. + +### Changed +- Added a missing button in the VFX template window to quickly install learning templates. + +### Fixed +- Fixed HLSL blocks so that they accept parameters that don't have an `in` attribute. +- Fixed incorrect error message on Custom HLSL. +- Improved CustomHLSL to consider custom HLSL and includes workflow. +- Added support for more HLSL function prototype declaration. +- Resolved a corner case issue where the presence of multiple instances of the same buffer led to a compilation failure. +- A compilation issue occured when declaring a gradient in ShaderGraph blackboard. +- Fixed NullReferenceException when enabling Decal Layers in HDRP. +- Fixed exposed properties reset when editing multiple VFX at the same time on inspector. +- Fixed incorrect source spawnCount. +- Fixed exception when a category color is reset in the node search. +- Fixed a rare crash when destroying a VFX instance during rendering. +- Updated the starter template Description and some default VFX resources. +- Force culling when VFX rendering is disabled. +- VFX Graph VFXOutputEventHandlers Sample now compatible with Cinemachine 3.x. +- Disabled compile menu when authoring subgraphs. +- Fixed the ability to add blocks to subgraph context. +- Fixed some UI elements could overflow their reserved space. +- Fixed "int" type could not be parsed when the access modifier is not specified. +- Fixed unexpected CustomHLSL includes in neighbors contexts. +- Fixed potential exception message in the console when opening any VFX Graph. +- Fixed potential crash when using the Noise Module in a particle system. +- Fixed output properties in subgraphs had misplaced wire connector. +- Fixed a leak while spamming ReInit. +- Fixed compilation error when using the Six-way Lit Output with Adaptive Probe Volumes. +- Custom HLSL can be missing when connected to several contexts. +- Improved how the sleep state is updated for particle systems receiving GPU events. +- Wrong mesh rendered with instancing, when using multi mesh and exposed submesh mask. +- Fixed potential crash and correctness when using a system with multiple Volumetric Fog Outputs. +- Fixed SpawnIndex attribute when using instancing. +- Fixed an exception when trying to create curl noise sub-variant nodes. +- Fixed variadic attributes to not be allowed to be used in custom HLSL code. +- Fixed random texture rendered with instancing when using exposed texture set to None. +- Fixed a crash that occurred when visualizing a VFX preview with raytracing enabled. +- Fixed a potential division by zero in RayBoxIntersection code. +- Fixed an issue where copying or pasting in a different asset in a context with a block that used a custom attribute would lose the custom attribute type and fallback to float. + + +- Fixed missing drag area to change a value for inline float, uint and int operators. +- Fixed several UX issues in the VFX Graph blackboard. +- Fixed copy/pasting a selection from a graph to another when the selection contains multiple times the same property node. +- Fixed compatibility between Flipbook and Vector2 field types. +- Added error feedback in case of incorrect setup of the Position Sequential Circle block. +- Read unexposed shader global properties when using a Shader Graph output. +- Fixed ParticleIndexInStrip, StripIndex, and ParticleCountinStrip attributes when used in quad or mesh outputs (previously all returning 0). +- Fixed rendering unwanted particles when rendering particle strip systems as particles (previously rendering entire capacity). +- Fixed strips with immortal particles disappearing with instancing on. +- Fixed an issue where Convert Output to Output Particle ShaderGraph Octagon or Triangle generates an exception. +- Fixed corrupted graph when a custom type was missing. +- Fixed node search expand/collapse button, which could be blurry, depending on screen DPI setting. +- Fixed sticky note resizing could be broken. +- Fixed a crash that would uccur during the update of a Visual Effect when deleting a used Texture. +- Fixed an issue where strip tangent was not computed correctly when using Shader Graph output. +- Fixed two different HLSL parsing issues with VFX Graph custom HLSL. +- Fixed an issue where Tooltips were not displaying. +- Fixed capacity field in the Particle System Info panel not being refreshed when modifying system capacity. +- Fixed overdraw debug mode of unlit particles in URP. +- Improved Water integration to prevent an unexpected error from dispatch. +- Incorrect sanitization of SetCustomAttribute when Random was different than Random.Off. +- Missing delayed field for Sample Water Surface Operator. +- Unexpected log "Expression graph was marked as dirty after compiling context for UI" while using Custom HLSL based operators. +- Particle outputs connected to particle strip systems don't render last particle. +- Fixed an issue when using the same name as a built-in attribute in a custom HLSL function's parameter would lead to a compilation error. +- Fixed an issue when creating a Custom HLSL operator with two outputs could prevent the generated shader from compiling. +- Fixed an issue with VFX particles GBuffer pass with URP Render Graph. +- Fixed an issue when importing old VFX asset in Unity6 using custom attribute with same name as built-in attribute. +- Subgraph blocks now accept correct types of block based on their suitable context. +- Fixed port's label was not be visible when node is collapsed. +- Fixed an exception that could prevent opening a VFX in one specific case. +- Fixed CustomRenderTexture could not be used in VFX Graph object fields. +- Fixed reordering properties inside a category was not possible anymore. +Also reordering a category could not work if there was properties at the root (with no category) +- Fixed a small cursor offset when drawing a rectangle selection +- This PR fix resolves minor issues related to VFX graph content sample package. +- This PR fix resolves minor issues related to VFX graph content sample package. +- This PR fix resolves minor issues related to VFX graph content sample package. +- Fix emissive decal when using color attribute for emissive. +- Fix NullReferenceExpection happening with disconnected output contexts. +- Fix occasional crashes when modifying exposed properties when in paused play mode +- Fixed VFX Graph template window was empty when the Terrain Tool package is installed + ## [17.0.2] - 2024-04-02 This version is compatible with Unity 6000.0.0b15. diff --git a/Packages/com.unity.visualeffectgraph/Editor/GraphView/Elements/Controllers/VFXDataAnchorController.cs b/Packages/com.unity.visualeffectgraph/Editor/GraphView/Elements/Controllers/VFXDataAnchorController.cs index 2399497a..5c0de179 100644 --- a/Packages/com.unity.visualeffectgraph/Editor/GraphView/Elements/Controllers/VFXDataAnchorController.cs +++ b/Packages/com.unity.visualeffectgraph/Editor/GraphView/Elements/Controllers/VFXDataAnchorController.cs @@ -560,9 +560,9 @@ namespace UnityEditor.VFX.UI } } - class VFXUpcommingDataAnchorController : VFXDataAnchorController + class VFXUpcomingDataAnchorController : VFXDataAnchorController { - public VFXUpcommingDataAnchorController(VFXNodeController sourceNode, bool hidden) : base(null, sourceNode, hidden) + public VFXUpcomingDataAnchorController(VFXNodeController sourceNode, bool hidden) : base(null, sourceNode, hidden) { } @@ -638,7 +638,7 @@ namespace UnityEditor.VFX.UI if (op == null) return false; - if (controller is VFXUpcommingDataAnchorController) + if (controller is VFXUpcomingDataAnchorController) return false; if (!CanLinkToNode(controller.sourceNode, cache)) diff --git a/Packages/com.unity.visualeffectgraph/Editor/GraphView/Elements/Controllers/VFXOperatorController.cs b/Packages/com.unity.visualeffectgraph/Editor/GraphView/Elements/Controllers/VFXOperatorController.cs index 56e64a7e..73d118fe 100644 --- a/Packages/com.unity.visualeffectgraph/Editor/GraphView/Elements/Controllers/VFXOperatorController.cs +++ b/Packages/com.unity.visualeffectgraph/Editor/GraphView/Elements/Controllers/VFXOperatorController.cs @@ -258,14 +258,14 @@ namespace UnityEditor.VFX.UI { } - VFXUpcommingDataAnchorController m_UpcommingDataAnchor; + VFXUpcomingDataAnchorController m_UpcomingDataAnchor; protected override void NewInputSet(List newInputs) { - if (m_UpcommingDataAnchor == null) + if (m_UpcomingDataAnchor == null) { - m_UpcommingDataAnchor = new VFXUpcommingDataAnchorController(this, false); + m_UpcomingDataAnchor = new VFXUpcomingDataAnchorController(this, false); } - newInputs.Add(m_UpcommingDataAnchor); + newInputs.Add(m_UpcomingDataAnchor); } public override void OnEdgeFromInputGoingToBeRemoved(VFXDataAnchorController myInput) diff --git a/Packages/com.unity.visualeffectgraph/Editor/GraphView/Elements/VFXDataAnchor.cs b/Packages/com.unity.visualeffectgraph/Editor/GraphView/Elements/VFXDataAnchor.cs index 82da36ae..7c4ba303 100644 --- a/Packages/com.unity.visualeffectgraph/Editor/GraphView/Elements/VFXDataAnchor.cs +++ b/Packages/com.unity.visualeffectgraph/Editor/GraphView/Elements/VFXDataAnchor.cs @@ -471,7 +471,7 @@ namespace UnityEditor.VFX.UI } // If linking to a new parameter, copy the slot value and space - if (direction == Direction.Input && controller.model != null) //model will be null for upcomming which won't have a value + if (direction == Direction.Input && controller.model != null) //model will be null for upcoming which won't have a value { if (newNodeController is VFXOperatorController) { diff --git a/Packages/com.unity.visualeffectgraph/Editor/GraphView/Elements/VFXEdgeDragInfo.cs b/Packages/com.unity.visualeffectgraph/Editor/GraphView/Elements/VFXEdgeDragInfo.cs index a0725d75..eef2ca4f 100644 --- a/Packages/com.unity.visualeffectgraph/Editor/GraphView/Elements/VFXEdgeDragInfo.cs +++ b/Packages/com.unity.visualeffectgraph/Editor/GraphView/Elements/VFXEdgeDragInfo.cs @@ -60,7 +60,13 @@ namespace UnityEditor.VFX.UI { error = "An edge with the same input and output already exists"; } - else if (!draggedAnchor.controller.model.CanLink(overAnchor.controller.model)) + else if (draggedAnchor.controller is VFXUpcomingDataAnchorController upComingAnchor && upComingAnchor.sourceNode.model.GetBestAffinityType(overAnchor.controller.portType) == null || + overAnchor.controller is VFXUpcomingDataAnchorController upComingAnchor2 && upComingAnchor2.sourceNode.model.GetBestAffinityType(draggedAnchor.controller.portType) == null ) + { + // dragged and over can not both be upcoming because only inputs are allowed to be upcoming and the direction check has already been made. + error = "There is no compatible type between the output and the operator"; + } + else if (draggedAnchor.controller.model != null && overAnchor.controller.model != null && !draggedAnchor.controller.model.CanLink(overAnchor.controller.model)) { error = "The input and output have incompatible types"; } diff --git a/Packages/com.unity.visualeffectgraph/Editor/GraphView/Profiling/VFXProfilingBoard.cs b/Packages/com.unity.visualeffectgraph/Editor/GraphView/Profiling/VFXProfilingBoard.cs index 0fa01905..e580deb0 100644 --- a/Packages/com.unity.visualeffectgraph/Editor/GraphView/Profiling/VFXProfilingBoard.cs +++ b/Packages/com.unity.visualeffectgraph/Editor/GraphView/Profiling/VFXProfilingBoard.cs @@ -95,6 +95,7 @@ namespace UnityEditor.VFX.UI capabilities |= Capabilities.Movable; RegisterCallback(OnMouseClick); + RegisterCallback(e=> e.StopPropagation()); // Prevent graphview from zooming in/out when using the mouse wheel over the component board RegisterCallback(e => e.StopPropagation()); @@ -167,6 +168,7 @@ namespace UnityEditor.VFX.UI void OnMouseClick(MouseDownEvent e) { m_View.SetBoardToFront(this); + e.StopPropagation(); } public void Detach() diff --git a/Packages/com.unity.visualeffectgraph/Editor/GraphView/VFXComponentBoard.cs b/Packages/com.unity.visualeffectgraph/Editor/GraphView/VFXComponentBoard.cs index 91995775..5ad19cbe 100644 --- a/Packages/com.unity.visualeffectgraph/Editor/GraphView/VFXComponentBoard.cs +++ b/Packages/com.unity.visualeffectgraph/Editor/GraphView/VFXComponentBoard.cs @@ -194,6 +194,7 @@ namespace UnityEditor.VFX.UI capabilities |= Capabilities.Movable; RegisterCallback(OnMouseClick); + RegisterCallback(e=>e.StopPropagation()); // Prevent graphview from zooming in/out when using the mouse wheel over the component board RegisterCallback(e => e.StopPropagation()); @@ -230,6 +231,7 @@ namespace UnityEditor.VFX.UI void OnMouseClick(MouseDownEvent e) { m_View.SetBoardToFront(this); + e.StopPropagation(); } void OnMouseClickBoundsContainer(MouseDownEvent e) diff --git a/Packages/com.unity.visualeffectgraph/Editor/GraphView/Views/VFXHelpDropdownButton.cs b/Packages/com.unity.visualeffectgraph/Editor/GraphView/Views/VFXHelpDropdownButton.cs index 997f3007..9e373e85 100644 --- a/Packages/com.unity.visualeffectgraph/Editor/GraphView/Views/VFXHelpDropdownButton.cs +++ b/Packages/com.unity.visualeffectgraph/Editor/GraphView/Views/VFXHelpDropdownButton.cs @@ -14,10 +14,6 @@ namespace UnityEditor.VFX.UI const string k_AdditionalHelpers = "OutputEvent Helpers"; const string k_LearningSamples = "Learning Templates"; const string k_ManualUrl = @"https://docs.unity3d.com/Packages/com.unity.visualeffectgraph@{0}/index.html"; - const string k_ForumUrl = @"https://forum.unity.com/forums/visual-effect-graph.428/"; - const string k_SpaceShipUrl = @"https://github.com/Unity-Technologies/SpaceshipDemo"; - const string k_SamplesUrl = @"https://github.com/Unity-Technologies/VisualEffectGraph-Samples"; - const string k_VfxGraphUrl = @"https://unity.com/visual-effect-graph"; string m_ManualUrlWithVersion; ListRequest m_PackageManagerRequest; @@ -40,18 +36,6 @@ namespace UnityEditor.VFX.UI var installLearningButton = m_PopupContent.Q