diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/LinuxEditor/Vulkan/None/9800_Compositor.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/LinuxEditor/Vulkan/None/9800_Compositor.png index c3444fce114..9b0ae3cfb84 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/LinuxEditor/Vulkan/None/9800_Compositor.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/LinuxEditor/Vulkan/None/9800_Compositor.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fae7334c0189de563adff3d2547c5eee8f750f8f0587722389615c42cfd057f8 -size 90574 +oid sha256:560f65375036eb1901a2b397609c4f2b766fe4f4a769cbbdf61fc66ca065a4f0 +size 90859 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/9800_Compositor.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/9800_Compositor.png index 4d32dde27c3..4e8c7627221 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/9800_Compositor.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/9800_Compositor.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:77ab31f6262195834e8335063a62b06804476ef5bf4f41ed7ff1d721558b498b -size 89682 +oid sha256:242f316c9e40115f0d0447dd3545a7716f1fb16f852fc32b04d13b8482a22747 +size 90530 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/9800_Compositor.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/9800_Compositor.png index 882d40bac50..9914ab7cad1 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/9800_Compositor.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/9800_Compositor.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b64cf2b79e284812084bcadfa8f5252860cf7d8710b5db3a18f833d1a371b4c9 -size 90576 +oid sha256:5c8a47ab2d42a002ece2727b11177144db13278f39b1b3e49fb5e8b6fc3a019d +size 90912 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/9800_Compositor.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/9800_Compositor.png index 882d40bac50..9914ab7cad1 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/9800_Compositor.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/9800_Compositor.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b64cf2b79e284812084bcadfa8f5252860cf7d8710b5db3a18f833d1a371b4c9 -size 90576 +oid sha256:5c8a47ab2d42a002ece2727b11177144db13278f39b1b3e49fb5e8b6fc3a019d +size 90912 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/9800_Compositor.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/9800_Compositor.png index c3444fce114..9914ab7cad1 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/9800_Compositor.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/9800_Compositor.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fae7334c0189de563adff3d2547c5eee8f750f8f0587722389615c42cfd057f8 -size 90574 +oid sha256:5c8a47ab2d42a002ece2727b11177144db13278f39b1b3e49fb5e8b6fc3a019d +size 90912 diff --git a/com.unity.render-pipelines.core/ShaderLibrary/Refraction.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/Refraction.hlsl index 5ad1d16ee23..66059e3af34 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/Refraction.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/Refraction.hlsl @@ -17,7 +17,7 @@ RefractionModelResult RefractionModelSphere(real3 V, float3 positionWS, real3 no // Sphere shape model: // We approximate locally the shape of the object as sphere, that is tangent to the shape. // The sphere has a diameter of {thickness} - // The center of the sphere is at {positionWS} - {normalWS} * {thickness} + // The center of the sphere is at {positionWS} - {normalWS} * {thickness} * 0.5 // // So the light is refracted twice: in and out of the tangent sphere diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index fa4523fb432..1749fbd5785 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - API to allow OnDemand shadows to not render upon placement in the Cached Shadow Atlas. - Exposed update upon light movement for directional light shadows in UI. - Added a fallback for the ray traced directional shadow in case of a transmission (case 1307870). +- Added an info box for micro shadow editor (case 1322830). ### Fixed - Fixed probe volumes debug views. @@ -154,6 +155,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed a bug with Reflection Probe baking would result in an incorrect baking reusing other's Reflection Probe baking - Fixed volumetric fog being visually chopped or missing when using hardware Dynamic Resolution Scaling. - Fixed generation of the packed depth pyramid when hardware Dynamic Resolution Scaling is enabled. +- Fixed issue with an assert getting triggered with OnDemand shadows. +- Fixed Decal's UV edit mode with negative UV +- Fixed issue with the color space of AOVs (case 1324759) +- Fixed issue with history buffers when using multiple AOVs (case 1323684). +- Fixed camera preview with multi selection (case 1324126). ### Changed - Removed the material pass probe volumes evaluation mode. @@ -189,6 +195,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - The default LookDev volume profile is now copied and referened in the Asset folder instead of the package folder. - Changed normal used in path tracing to create a local light list from the geometric to the smooth shading one. - Assets going through the migration system are now dirtied. +- Changed ray tracing acceleration structure build, so that only meshes with HDRP materials are included (case 1322365). +- Increased path tracing max samples from 4K to 16K (case 1327729). ## [10.3.0] - 2020-12-01 diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Refraction-in-HDRP.md b/com.unity.render-pipelines.high-definition/Documentation~/Refraction-in-HDRP.md index ef8b4b3c7a0..7c3a9756c46 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Refraction-in-HDRP.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Refraction-in-HDRP.md @@ -58,7 +58,7 @@ This means that, if screen space refraction does not return information for a pi The first tier of the refraction hierarchy is a screen space solution. To calculate screen space refraction, the algorithm traces a ray starting from the refractive object. It then refracts the ray according to the properties of the material. To compute the refracted ray, the algorithm assumes that the refractive object can be approximated as a simple shape ([Refraction Model](#RefractionModel)) . -The refracted ray will be then intersected against the proxy volume to find the right pixel in screen space that best approximates the result of the refracted ray. +The refracted ray will be then intersected against the closest probe proxy volume to find the pixel in screen space that best approximates the result of the refracted ray. If there is no reflection probe proxy available, HDRP will fallback to a projection at infinite. @@ -82,15 +82,15 @@ For more information on Reflection Probes, see: HDRP uses simple shapes to approximate the surface of GameObjects: - **Sphere**: Approximates the surface as a sphere. -- **Box**: Approximates the surface as an hollow box. In this case think of the thickness as being the distance between two parallel faces of the box. -- **Thin**: Approximated the surface as a box with a fixed thickness of 5cm. +- **Box**: Approximates the surface as a hollow box. In this case think of the thickness as being the distance between two parallel faces of the box. +- **Thin**: Approximates the surface as a hollow box with a fixed thickness of 5cm. ### Examples -- For a filled GameObject, use a **Sphere** Refraction Model with a thickness that is approximately the size of the GameObject that the Material is for. To set the thickness, use the **Refraction Thickness**. +- For a solid GameObject, use the **Sphere** Refraction Model with a thickness that is approximately the size of the GameObject that the Material is for. To set the thickness, use the **Refraction Thickness**. ![](Images/RefractionInHDRP1.png) -- For a hollow refractive GameObject (for example, a bubble), use a **Box** refraction Mode with a small value for thickness. To set the thickness, use the **Refraction Thickness**. +- For a hollow refractive GameObject (for example, a bubble), use the **Thin** refraction Model, or **Box** with a small thickness value. To set the thickness, use the **Refraction Thickness**. -![](Images/RefractionInHDRP2.png) + ![](Images/RefractionInHDRP2.png) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/System-Requirements.md b/com.unity.render-pipelines.high-definition/Documentation~/System-Requirements.md index 1f90455530b..3034e141573 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/System-Requirements.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/System-Requirements.md @@ -8,6 +8,7 @@ The following table shows the compatibility of the High Definition Render Pipeli | **Package version** | **Minimum Unity version** | **Maximum Unity version** | | ------------------- | ------------------------- | ------------------------- | +| 11.x | 2021.1 | 2021.1 | | 10.x | 2020.2 | 2020.2 | | 8.x / 9.x-preview | 2020.1 | 2020.1 | | 7.x | 2019.3 | 2019.4 | diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/MicroShadowingEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/MicroShadowingEditor.cs new file mode 100644 index 00000000000..2a499e83914 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/MicroShadowingEditor.cs @@ -0,0 +1,16 @@ +using UnityEngine.Rendering.HighDefinition; + +namespace UnityEditor.Rendering.HighDefinition +{ + [VolumeComponentEditor(typeof(MicroShadowing))] + sealed class MicroShadowingEditor : VolumeComponentEditor + { + static public readonly string k_DirectionnalWarning = "Micro Shadows only works with directional Lights"; + + public override void OnInspectorGUI() + { + base.OnInspectorGUI(); + EditorGUILayout.HelpBox(k_DirectionnalWarning, MessageType.Info); + } + } +} diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/MicroShadowingEditor.cs.meta b/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/MicroShadowingEditor.cs.meta new file mode 100644 index 00000000000..47292dbeae0 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/MicroShadowingEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: faceeca3ea8e9664bbd1485f9966da7a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DecalProjectorEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DecalProjectorEditor.cs index b8fb3eb13fb..bb7750b3313 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DecalProjectorEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DecalProjectorEditor.cs @@ -134,7 +134,7 @@ static DisplacableRectHandles uvHandles get { if (s_uvHandles == null || s_uvHandles.Equals(null)) - s_uvHandles = new DisplacableRectHandles(s_LastColor); + s_uvHandles = new DisplacableRectHandles(s_LastColor, allowsNegative: true); return s_uvHandles; } } diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DisplacableRectHandles.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DisplacableRectHandles.cs index 6579041a564..b3e12138ddf 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DisplacableRectHandles.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DisplacableRectHandles.cs @@ -15,6 +15,7 @@ enum NamedEdge { Right, Top, Left, Bottom, None } Color m_MonochromeHandleColor; Color m_WireframeColor; Color m_WireframeColorBehind; + bool allowsNegative; /// The position of the center of the box in Handle.matrix space. On plane z=0. public Vector2 center { get; set; } @@ -58,9 +59,10 @@ public Color baseColor } } - public DisplacableRectHandles(Color baseColor) + public DisplacableRectHandles(Color baseColor, bool allowsNegative = false) { this.baseColor = baseColor; + this.allowsNegative = allowsNegative; } /// Draw the rect. @@ -258,7 +260,8 @@ public void DrawHandle() case NamedEdge.Bottom: topPosition.y -= delta; break; } - EnsureEdgeFacesOutsideForSymetry(theChangedEdge, ref leftPosition, ref rightPosition, ref topPosition, ref bottomPosition); + if (!allowsNegative) + EnsureEdgeFacesOutsideForSymetry(theChangedEdge, ref leftPosition, ref rightPosition, ref topPosition, ref bottomPosition); } if (useHomothety) @@ -278,13 +281,14 @@ public void DrawHandle() break; } - EnsureEdgeFacesOutsideForHomothety(theChangedEdge, ref leftPosition, ref rightPosition, ref topPosition, ref bottomPosition); + if (!allowsNegative) + EnsureEdgeFacesOutsideForHomothety(theChangedEdge, ref leftPosition, ref rightPosition, ref topPosition, ref bottomPosition); } var max = new Vector2(rightPosition.x, topPosition.y); var min = new Vector2(leftPosition.x, bottomPosition.y); - if (!useSymetry && !useHomothety) + if (!useSymetry && !useHomothety && !allowsNegative) EnsureEdgeFacesOutsideForOtherTransformation(ref max, ref min); center = (max + min) * .5f; diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/RefractionUIBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/RefractionUIBlock.cs index 8b78290fc5d..36d42d39dc8 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/RefractionUIBlock.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/RefractionUIBlock.cs @@ -19,7 +19,7 @@ internal static class Styles { public static string refractionModelText = "Refraction Model"; public static GUIContent refractionIorText = new GUIContent("Index Of Refraction", "Controls the index of refraction for this Material."); - public static GUIContent refractionThicknessText = new GUIContent("Thickness", "Controls the thickness for rough refraction."); + public static GUIContent refractionThicknessText = new GUIContent("Thickness", "Controls the thickness for rough refraction.\nFor a Sphere model, this is the diameter of the sphere."); public static GUIContent refractionThicknessMapText = new GUIContent("Thickness Map", "Specifies the Refraction Thickness Map (R) for this Material - This acts as a thickness multiplier map."); public static GUIContent refractionThicknessRemappingText = new GUIContent("Thickness Remapping", "Controls the maximum thickness for rough refraction."); public static GUIContent thicknessMapText = new GUIContent("Thickness Map", "Specifies the Thickness Map (R) for this Material - This map describes the thickness of the object. When subsurface scattering is enabled, low values allow some light to transmit through the object."); diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraEditor.Handlers.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraEditor.Handlers.cs index 2be99125948..db52abd15b3 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraEditor.Handlers.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraEditor.Handlers.cs @@ -28,20 +28,32 @@ void OnOverlayGUI(Object target, SceneView sceneView) Camera InitializePreviewCamera(Camera c, Vector2 previewSize) { - m_PreviewCamera.CopyFrom(c); - EditorUtility.CopySerialized(c, m_PreviewCamera); + Camera previewCamera = null; + HDAdditionalCameraData previewAdditionalCameraData = null; + for (int i = 0; i < serializedObject.targetObjects.Length; i++) + { + if (serializedObject.targetObjects[i] == c) + { + previewCamera = m_PreviewCameras[i]; + previewAdditionalCameraData = m_PreviewAdditionalCameraDatas[i]; + break; + } + } + + previewCamera.CopyFrom(c); + EditorUtility.CopySerialized(c, previewCamera); var cameraData = c.GetComponent(); - EditorUtility.CopySerialized(cameraData, m_PreviewAdditionalCameraData); + EditorUtility.CopySerialized(cameraData, previewAdditionalCameraData); // We need to explicitly reset the camera type here // It is probably a CameraType.Game, because we copied the source camera's properties. - m_PreviewCamera.cameraType = CameraType.Preview; - m_PreviewCamera.gameObject.SetActive(false); + previewCamera.cameraType = CameraType.Preview; + previewCamera.gameObject.SetActive(false); var previewTexture = GetPreviewTextureWithSize((int)previewSize.x, (int)previewSize.y); - m_PreviewCamera.targetTexture = previewTexture; - m_PreviewCamera.pixelRect = new Rect(0, 0, previewSize.x, previewSize.y); + previewCamera.targetTexture = previewTexture; + previewCamera.pixelRect = new Rect(0, 0, previewSize.x, previewSize.y); - return m_PreviewCamera; + return previewCamera; } static Type k_SceneViewOverlay_WindowFunction = Type.GetType("UnityEditor.SceneViewOverlay+WindowFunction,UnityEditor"); diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraEditor.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraEditor.cs index 94f012b6345..72d657dee3d 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraEditor.cs @@ -14,19 +14,25 @@ partial class HDCameraEditor : Editor SerializedHDCamera m_SerializedCamera; RenderTexture m_PreviewTexture; - Camera m_PreviewCamera; - HDAdditionalCameraData m_PreviewAdditionalCameraData; + Camera[] m_PreviewCameras; + HDAdditionalCameraData[] m_PreviewAdditionalCameraDatas; void OnEnable() { m_SerializedCamera = new SerializedHDCamera(serializedObject); - m_PreviewCamera = EditorUtility.CreateGameObjectWithHideFlags("Preview Camera", HideFlags.HideAndDontSave, typeof(Camera)).GetComponent(); - m_PreviewCamera.enabled = false; - m_PreviewCamera.cameraType = CameraType.Preview; // Must be init before adding HDAdditionalCameraData - m_PreviewAdditionalCameraData = m_PreviewCamera.gameObject.AddComponent(); - // Say that we are a camera editor preview and not just a regular preview - m_PreviewAdditionalCameraData.isEditorCameraPreview = true; + var targetCount = serializedObject.targetObjects.Length; + m_PreviewCameras = new Camera[targetCount]; + m_PreviewAdditionalCameraDatas = new HDAdditionalCameraData[targetCount]; + for (int i = 0; i < targetCount; i++) + { + m_PreviewCameras[i] = EditorUtility.CreateGameObjectWithHideFlags("Preview " + serializedObject.targetObject.name, HideFlags.HideAndDontSave, typeof(Camera)).GetComponent(); + m_PreviewCameras[i].enabled = false; + m_PreviewCameras[i].cameraType = CameraType.Preview; // Must be init before adding HDAdditionalCameraData + m_PreviewAdditionalCameraDatas[i] = m_PreviewCameras[i].gameObject.AddComponent(); + // Say that we are a camera editor preview and not just a regular preview + m_PreviewAdditionalCameraDatas[i].isEditorCameraPreview = true; + } } void OnDisable() @@ -36,8 +42,10 @@ void OnDisable() m_PreviewTexture.Release(); m_PreviewTexture = null; } - DestroyImmediate(m_PreviewCamera.gameObject); - m_PreviewCamera = null; + for (int i = 0; i < serializedObject.targetObjects.Length; i++) + DestroyImmediate(m_PreviewCameras[i].gameObject); + m_PreviewCameras = null; + m_PreviewAdditionalCameraDatas = null; } public override void OnInspectorGUI() diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineMenuItems.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineMenuItems.cs index 4a642f0985a..5d3c96e0cf9 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineMenuItems.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineMenuItems.cs @@ -213,7 +213,7 @@ static void MenuCreateCSharpPostProcessVolume() static void MenuCreatePostProcessShader() { string templatePath = $"{HDUtils.GetHDRenderPipelinePath()}/Editor/PostProcessing/Templates/CustomPostProcessingShader.template"; - ProjectWindowUtil.CreateScriptAssetFromTemplateFile(templatePath, "New Post Process Shader.shader"); + ProjectWindowUtil.CreateScriptAssetFromTemplateFile(templatePath, "New Post Process Volume.shader"); } //[MenuItem("Internal/HDRP/Add \"Additional Light-shadow Data\" (if not present)")] diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs index f9bc192d79f..69fe7f63ac9 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs @@ -41,7 +41,9 @@ unsafe struct ShaderVariablesDebugDisplay public int _DebugSingleShadowIndex; public int _DebugProbeVolumeMode; - public Vector3 _DebugDisplayPad0; + public int _DebugAOVOutput; + public int _DebugDisplayPad0; + public int _DebugDisplayPad1; } /// diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs.hlsl index f23e6568552..01f7a9a59ca 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs.hlsl @@ -68,7 +68,9 @@ CBUFFER_START(ShaderVariablesDebugDisplay) float _MatcapViewScale; int _DebugSingleShadowIndex; int _DebugProbeVolumeMode; - float3 _DebugDisplayPad0; + int _DebugAOVOutput; + int _DebugDisplayPad0; + int _DebugDisplayPad1; CBUFFER_END diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDCachedShadowAtlas.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDCachedShadowAtlas.cs index 5c968626fd5..7f0f139e7f3 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDCachedShadowAtlas.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDCachedShadowAtlas.cs @@ -618,7 +618,8 @@ internal void MarkAsRendered(int shadowIdx) if (m_ShadowsPendingRendering.ContainsKey(shadowIdx)) { m_ShadowsPendingRendering.Remove(shadowIdx); - m_ShadowsWithValidData.Add(shadowIdx, shadowIdx); + if (!m_ShadowsWithValidData.ContainsKey(shadowIdx)) + m_ShadowsWithValidData.Add(shadowIdx, shadowIdx); } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs index fd3b58b867d..ebc5bd7818a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs @@ -705,6 +705,16 @@ internal void Update(FrameSettings currentFrameSettings, HDRenderPipeline hdrp, if (numColorPyramidBuffersRequired != 0) { AllocHistoryFrameRT((int)HDCameraFrameHistoryType.ColorBufferMipChain, HistoryBufferAllocatorFunction, numColorPyramidBuffersRequired); + + // Handle the AOV history buffers + var cameraHistory = GetHistoryRTHandleSystem(); + foreach (var aovRequest in aovRequests) + { + var aovHistory = GetHistoryRTHandleSystem(aovRequest); + BindHistoryRTHandleSystem(aovHistory); + AllocHistoryFrameRT((int)HDCameraFrameHistoryType.ColorBufferMipChain, HistoryBufferAllocatorFunction, numColorPyramidBuffersRequired); + } + BindHistoryRTHandleSystem(cameraHistory); } if (numVolumetricBuffersRequired != 0) @@ -768,6 +778,12 @@ internal void SetReferenceSize() { RTHandles.SetReferenceSize(actualWidth, actualHeight, msaaSamples); m_HistoryRTSystem.SwapAndSetReferenceSize(actualWidth, actualHeight, msaaSamples); + + foreach (var aovHistory in m_AOVHistoryRTSystem) + { + var historySystem = aovHistory.Value; + historySystem.SwapAndSetReferenceSize(actualWidth, actualHeight, msaaSamples); + } } // Updating RTHandle needs to be done at the beginning of rendering (not during update of HDCamera which happens in batches) @@ -856,6 +872,12 @@ internal static void ResetAllHistoryRTHandleSystems(int width, int height) if (width < currentHistorySize.x || height < currentHistorySize.y) { hdCamera.m_HistoryRTSystem.ResetReferenceSize(width, height); + + foreach (var aovHistory in hdCamera.m_AOVHistoryRTSystem) + { + var historySystem = aovHistory.Value; + historySystem.ResetReferenceSize(width, height); + } } } } @@ -1118,6 +1140,10 @@ public RTHandle Allocator(string id, int frameIndex, RTHandleSystem rtHandleSyst int m_NumVolumetricBuffersAllocated = 0; float m_AmbientOcclusionResolutionScale = 0.0f; // Factor used to track if history should be reallocated for Ambient Occlusion float m_ScreenSpaceAccumulationResolutionScale = 0.0f; // Use another scale if AO & SSR don't have the same resolution + + Dictionary m_AOVHistoryRTSystem = new Dictionary(new AOVRequestDataComparer()); + + /// /// Store current algorithm which help to know if we trigger to reset history SSR Buffers. /// @@ -1565,6 +1591,13 @@ void Dispose() m_HistoryRTSystem = null; } + foreach (var aovHistory in m_AOVHistoryRTSystem) + { + var historySystem = aovHistory.Value; + historySystem.Dispose(); + } + m_AOVHistoryRTSystem.Clear(); + if (lightingSky != null && lightingSky != visualSky) lightingSky.Cleanup(); @@ -1586,6 +1619,12 @@ static RTHandle HistoryBufferAllocatorFunction(string viewName, int frameIndex, void ReleaseHistoryBuffer() { m_HistoryRTSystem.ReleaseAll(); + + foreach (var aovHistory in m_AOVHistoryRTSystem) + { + var historySystem = aovHistory.Value; + historySystem.ReleaseAll(); + } } Rect GetPixelRect() @@ -1596,6 +1635,30 @@ Rect GetPixelRect() return new Rect(camera.pixelRect.x, camera.pixelRect.y, camera.pixelWidth, camera.pixelHeight); } + internal BufferedRTHandleSystem GetHistoryRTHandleSystem() + { + return m_HistoryRTSystem; + } + + internal void BindHistoryRTHandleSystem(BufferedRTHandleSystem historyRTSystem) + { + m_HistoryRTSystem = historyRTSystem; + } + + internal BufferedRTHandleSystem GetHistoryRTHandleSystem(AOVRequestData aovRequest) + { + if (m_AOVHistoryRTSystem.TryGetValue(aovRequest, out var aovHistory)) + { + return aovHistory; + } + else + { + var newHistory = new BufferedRTHandleSystem(); + m_AOVHistoryRTSystem.Add(aovRequest, newHistory); + return newHistory; + } + } + #endregion } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index b6322f553b4..81b3f395f42 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -1907,11 +1907,17 @@ ref _cullingResults probe.SetRenderData(ProbeSettings.Mode.Realtime, probeRenderData); } + // Save the camera history before rendering the AOVs + var cameraHistory = renderRequest.hdCamera.GetHistoryRTHandleSystem(); + // var aovRequestIndex = 0; foreach (var aovRequest in renderRequest.hdCamera.aovRequests) { using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.HDRenderPipelineRenderAOV))) { + // Before rendering the AOV, bind the correct history buffers + var aovHistory = renderRequest.hdCamera.GetHistoryRTHandleSystem(aovRequest); + renderRequest.hdCamera.BindHistoryRTHandleSystem(aovHistory); cmd.SetInvertCulling(renderRequest.cameraSettings.invertFaceCulling); ExecuteRenderRequest(renderRequest, renderContext, cmd, aovRequest); cmd.SetInvertCulling(false); @@ -1921,6 +1927,9 @@ ref _cullingResults cmd.Clear(); } + // We are now going to render the main camera, so bind the correct HistoryRTHandleSystem (in case we previously render an AOV) + renderRequest.hdCamera.BindHistoryRTHandleSystem(cameraHistory); + using (new ProfilingScope(cmd, renderRequest.hdCamera.profilingSampler)) { cmd.SetInvertCulling(renderRequest.cameraSettings.invertFaceCulling); @@ -2087,7 +2096,7 @@ AOVRequestData aovRequest Resize(hdCamera); m_PostProcessSystem.BeginFrame(cmd, hdCamera, this); - ApplyDebugDisplaySettings(hdCamera, cmd); + ApplyDebugDisplaySettings(hdCamera, cmd, aovRequest.isValid); if (DebugManager.instance.displayRuntimeUI #if UNITY_EDITOR @@ -3342,7 +3351,7 @@ static void RenderSSR(in RenderSSRParameters parameters, } } - unsafe void ApplyDebugDisplaySettings(HDCamera hdCamera, CommandBuffer cmd) + unsafe void ApplyDebugDisplaySettings(HDCamera hdCamera, CommandBuffer cmd, bool aovOutput) { // See ShaderPassForward.hlsl: for forward shaders, if DEBUG_DISPLAY is enabled and no DebugLightingMode or DebugMipMapMod // modes have been set, lighting is automatically skipped (To avoid some crashed due to lighting RT not set on console). @@ -3426,6 +3435,8 @@ unsafe void ApplyDebugDisplaySettings(HDCamera hdCamera, CommandBuffer cmd) cb._DebugSingleShadowIndex = m_CurrentDebugDisplaySettings.data.lightingDebugSettings.shadowDebugUseSelection ? m_DebugSelectedLightShadowIndex : (int)m_CurrentDebugDisplaySettings.data.lightingDebugSettings.shadowMapIndex; + cb._DebugAOVOutput = aovOutput ? 1 : 0; + ConstantBuffer.PushGlobal(cmd, m_ShaderVariablesDebugDisplayCB, HDShaderIDs._ShaderVariablesDebugDisplay); cmd.SetGlobalTexture(HDShaderIDs._DebugFont, defaultResources.textures.debugFontTex); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs index e2141b22044..6f1c240d5e0 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs @@ -31,7 +31,7 @@ public sealed class PathTracing : VolumeComponent /// Defines the maximum number of paths cast within each pixel, over time (one per frame). /// [Tooltip("Defines the maximum number of paths cast within each pixel, over time (one per frame).")] - public ClampedIntParameter maximumSamples = new ClampedIntParameter(256, 1, 4096); + public ClampedIntParameter maximumSamples = new ClampedIntParameter(256, 1, 16384); /// /// Defines the minimum number of bounces for each path, in [1, 10]. diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingManager.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingManager.cs index 53086afc0b8..3b85c6a0004 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingManager.cs @@ -76,6 +76,7 @@ public partial class HDRenderPipeline bool[] subMeshTransparentArray = new bool[maxNumSubMeshes]; ReflectionProbe reflectionProbe = new ReflectionProbe(); List materialArray = new List(maxNumSubMeshes); + Dictionary m_ShaderValidityCache = new Dictionary(); // Used to detect material and transform changes for Path Tracing Dictionary m_MaterialCRCs = new Dictionary(); @@ -116,6 +117,40 @@ internal void ReleaseRayTracingManager() m_DiffuseDenoiser.Release(); } + bool IsValidRayTracedMaterial(Material currentMaterial) + { + if (currentMaterial == null || currentMaterial.shader == null) + return false; + + bool isValid; + + // We use a cache, to speed up the case where materials/shaders are reused many times + int shaderId = currentMaterial.shader.GetInstanceID(); + if (m_ShaderValidityCache.TryGetValue(shaderId, out isValid)) + return isValid; + + // For the time being, we only consider non-decal HDRP materials as valid + isValid = currentMaterial.GetTag("RenderPipeline", false) == "HDRenderPipeline" && !DecalSystem.IsDecalMaterial(currentMaterial); + + m_ShaderValidityCache.Add(shaderId, isValid); + + return isValid; + } + + static bool IsTransparentMaterial(Material currentMaterial) + { + return currentMaterial.IsKeywordEnabled("_SURFACE_TYPE_TRANSPARENT") + || (HDRenderQueue.k_RenderQueue_Transparent.lowerBound <= currentMaterial.renderQueue + && HDRenderQueue.k_RenderQueue_Transparent.upperBound >= currentMaterial.renderQueue); + } + + static bool IsAlphaTestedMaterial(Material currentMaterial) + { + return currentMaterial.IsKeywordEnabled("_ALPHATEST_ON") + || (HDRenderQueue.k_RenderQueue_OpaqueAlphaTest.lowerBound <= currentMaterial.renderQueue + && HDRenderQueue.k_RenderQueue_OpaqueAlphaTest.upperBound >= currentMaterial.renderQueue); + } + AccelerationStructureStatus AddInstanceToRAS(Renderer currentRenderer, bool rayTracedShadow, bool aoEnabled, int aoLayerValue, @@ -172,8 +207,8 @@ AccelerationStructureStatus AddInstanceToRAS(Renderer currentRenderer, // Grab the material for the current sub-mesh Material currentMaterial = materialArray[meshIdx]; - // Make sure that the material is both non-null and non-decal - if (currentMaterial != null && !DecalSystem.IsDecalMaterial(currentMaterial)) + // Make sure that the material is HDRP's and non-decal + if (IsValidRayTracedMaterial(currentMaterial)) { // Mesh is valid given that all requirements are ok validMesh = true; diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/AOV/AOVRequest.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/AOV/AOVRequest.cs index 27e3e946286..c16151ec9f7 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/AOV/AOVRequest.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/AOV/AOVRequest.cs @@ -176,5 +176,55 @@ public void FillDebugData(DebugDisplaySettings debug) throw new ArgumentException("Unknown DebugFullScreen"); } } + + /// + /// Equality operator. + /// + /// The AOV request to compare to. + /// True if the provided AOV request is equal to this. + public override bool Equals(object obj) + { + return obj is AOVRequest && ((AOVRequest)obj) == this; + } + + /// + /// Compares if two AOV requests have the same settings. + /// + /// The first AOVRequest to compare. + /// The second AOVRequest to compare. + /// True if the two AOV requests have the same settings. + public static bool operator==(AOVRequest a, AOVRequest b) + { + return a.m_DebugFullScreen == b.m_DebugFullScreen && + a.m_LightFilterProperty == b.m_LightFilterProperty && + a.m_LightingProperty == b.m_LightingProperty && + a.m_MaterialProperty == b.m_MaterialProperty; + } + + /// + /// Compares if two AOV requests have the same settings. + /// + /// The first AOVRequest to compare. + /// The second AOVRequest to compare. + /// True if the two AOV requests have not the same settings. + public static bool operator!=(AOVRequest a, AOVRequest b) + { + return !(a == b); + } + + /// + /// Computes a hash code for the AOV Request. + /// + /// A hash code for the AOV Request. + public override int GetHashCode() + { + int hash = 17; + hash = hash * 23 + (int)m_DebugFullScreen; + hash = hash * 23 + (int)m_LightFilterProperty; + hash = hash * 23 + (int)m_LightingProperty; + hash = hash * 23 + (int)m_MaterialProperty; + + return hash; + } } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/AOV/AOVRequestData.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/AOV/AOVRequestData.cs index ef494431e1e..26d790d4fa8 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/AOV/AOVRequestData.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/AOV/AOVRequestData.cs @@ -313,5 +313,44 @@ public void SetupDebugData(ref DebugDisplaySettings debugDisplaySettings) /// The game object of the light to be rendered. /// true when the light must be rendered, false when it should be ignored. public bool IsLightEnabled(GameObject gameObject) => m_LightFilter == null || m_LightFilter.Contains(gameObject); + + internal int GetHash() + { + int hash = m_Settings.GetHashCode(); + + if (m_LightFilter != null) + { + foreach (var obj in m_LightFilter) + { + hash += obj.GetHashCode(); + } + } + + return hash; + } + + internal bool HasSameSettings(AOVRequestData other) + { + if (m_Settings != other.m_Settings) + return false; + + if (m_LightFilter != null) + return m_LightFilter.Equals(other.m_LightFilter); + + return true; + } + } + + internal class AOVRequestDataComparer : IEqualityComparer + { + public bool Equals(AOVRequestData x, AOVRequestData y) + { + return x.HasSameSettings(y); + } + + public int GetHashCode(AOVRequestData obj) + { + return obj.GetHash(); + } } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForward.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForward.hlsl index b4b8f76bc69..1810134ed59 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForward.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForward.hlsl @@ -183,8 +183,8 @@ void Frag(PackedVaryingsToPS packedInput, // TEMP! // For now, the final blit in the backbuffer performs an sRGB write - // So in the meantime we apply the inverse transform to linear data to compensate. - if (!needLinearToSRGB) + // So in the meantime we apply the inverse transform to linear data to compensate, unless we output to AOVs. + if (!needLinearToSRGB && _DebugAOVOutput == 0) result = SRGBToLinear(max(0, result)); outColor = float4(result, 1.0); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForwardUnlit.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForwardUnlit.hlsl index 66cf2247af9..093b8fe4464 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForwardUnlit.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForwardUnlit.hlsl @@ -147,8 +147,8 @@ void Frag(PackedVaryingsToPS packedInput, // TEMP! // For now, the final blit in the backbuffer performs an sRGB write - // So in the meantime we apply the inverse transform to linear data to compensate. - if (!needLinearToSRGB) + // So in the meantime we apply the inverse transform to linear data to compensate, unless we output to AOVs. + if (!needLinearToSRGB && _DebugAOVOutput == 0) result = SRGBToLinear(max(0, result)); outResult = float4(result, 1.0); diff --git a/com.unity.visualeffectgraph/Documentation~/System-Requirements.md b/com.unity.visualeffectgraph/Documentation~/System-Requirements.md index 6e1ebabf5c3..f88b2909f5e 100644 --- a/com.unity.visualeffectgraph/Documentation~/System-Requirements.md +++ b/com.unity.visualeffectgraph/Documentation~/System-Requirements.md @@ -8,6 +8,7 @@ The following table shows the compatibility of the Visual Effect Graph versions | **Package version** | **Minimum Unity version** | **Maximum Unity version** | | ------------------- | ------------------------- | ------------------------- | +| 11.x | 2021.1 | 2021.1 | | 10.x | 2020.2 | 2020.2 | | 8.x / 9.x-preview | 2020.1 | 2020.1 | | 7.x | 2019.3 | 2019.4 | @@ -19,6 +20,7 @@ The Visual Effect Graph varies in compatibility between the High Definition Rend | **Package version** | **HDRP** | **URP** | | ------------------- | -------------- | ------------- | +| 11.x | Out of preview | In preview | | 10.x | Out of preview | In preview | | 8.x / 9.x-preview | Out of preview | In preview | | 7.x | Out of preview | In preview |