diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/801_SubSurfaceScatteringDeferred.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/801_SubSurfaceScatteringDeferred.png index 1166dbdfdb7..2785f237130 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/801_SubSurfaceScatteringDeferred.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/801_SubSurfaceScatteringDeferred.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6bb66282150196ecce0fffb240d84b12adfc3b830847bdbdbc49b9ec49ccc402 -size 176312 +oid sha256:30c2180073a4a12ea50c7761c6b2f2d1828dec693bb182850863cac3d441e7ab +size 176320 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/802_SubSurfaceScatteringForward.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/802_SubSurfaceScatteringForward.png index f3a625b08e7..1dbf512dac1 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/802_SubSurfaceScatteringForward.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/802_SubSurfaceScatteringForward.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bb7caee4791feaa6a73d239592cd0b65614722c9b62244a13e4c325e4cf5dd56 -size 176013 +oid sha256:5d6f94de39d459443575a707cf66c0bc4aa473a26afcd022788067216c18274e +size 176174 diff --git a/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs b/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs index f487281dc3c..21a110079a0 100644 --- a/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs +++ b/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs @@ -16,24 +16,24 @@ namespace UnityEditor.Rendering /// in the inspector: /// /// using UnityEngine.Rendering; - /// + /// /// [CustomEditor(typeof(VolumeProfile))] /// public class CustomVolumeProfileEditor : Editor /// { /// VolumeComponentListEditor m_ComponentList; - /// + /// /// void OnEnable() /// { /// m_ComponentList = new VolumeComponentListEditor(this); /// m_ComponentList.Init(target as VolumeProfile, serializedObject); /// } - /// + /// /// void OnDisable() /// { /// if (m_ComponentList != null) /// m_ComponentList.Clear(); /// } - /// + /// /// public override void OnInspectorGUI() /// { /// serializedObject.Update(); @@ -58,6 +58,8 @@ public sealed class VolumeComponentListEditor Dictionary m_EditorTypes; // Component type => Editor type List m_Editors; + int m_CurrentHashCode; + /// /// Creates a new instance of to use in an /// existing editor. @@ -195,9 +197,12 @@ public void OnGUI() if (asset == null) return; - if (asset.isDirty) + // Even if the asset is not dirty, the list of component may have been changed by another inspector. + // In this case, only the hash will tell us that we need to refresh. + if (asset.isDirty || asset.GetHashCode() != m_CurrentHashCode) { RefreshEditors(); + m_CurrentHashCode = asset.GetHashCode(); asset.isDirty = false; } diff --git a/com.unity.render-pipelines.core/Editor/Volume/VolumeProfileFactory.cs b/com.unity.render-pipelines.core/Editor/Volume/VolumeProfileFactory.cs index c9eba822995..cf00102a263 100644 --- a/com.unity.render-pipelines.core/Editor/Volume/VolumeProfileFactory.cs +++ b/com.unity.render-pipelines.core/Editor/Volume/VolumeProfileFactory.cs @@ -56,12 +56,22 @@ public static VolumeProfile CreateVolumeProfile(Scene scene, string targetName) { var scenePath = Path.GetDirectoryName(scene.path); var extPath = scene.name; - var profilePath = scenePath + "/" + extPath; + var profilePath = scenePath + Path.DirectorySeparatorChar + extPath; if (!AssetDatabase.IsValidFolder(profilePath)) - AssetDatabase.CreateFolder(scenePath, extPath); + { + var directories = profilePath.Split(Path.DirectorySeparatorChar); + string rootPath = ""; + foreach (var directory in directories) + { + var newPath = rootPath + directory; + if (!AssetDatabase.IsValidFolder(newPath)) + AssetDatabase.CreateFolder(rootPath.TrimEnd(Path.DirectorySeparatorChar), directory); + rootPath = newPath + Path.DirectorySeparatorChar; + } + } - path = profilePath + "/"; + path = profilePath + Path.DirectorySeparatorChar; } path += targetName + " Profile.asset"; diff --git a/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs b/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs index 9b354b47598..198a44af7ac 100644 --- a/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs +++ b/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs @@ -279,5 +279,23 @@ public bool TryGetAllSubclassOf(Type type, List result) return count != result.Count; } + + + /// + /// A custom hashing function that Unity uses to compare the state of parameters. + /// + /// A computed hash code for the current instance. + public override int GetHashCode() + { + unchecked + { + int hash = 17; + + for (int i = 0; i < components.Count; i++) + hash = hash * 23 + components[i].GetHashCode(); + + return hash; + } + } } } diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 11372fc7c22..4dca3f293b2 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -507,6 +507,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed drag area width at left of Light's intensity field in Inspector. - Fixed light type resolution when performing a reset on HDAdditionalLightData (case 1220931) - Fixed reliance on atan2 undefined behavior in motion vector debug shader. +- Fixed an usage of a a compute buffer not bound (1229964) +- Fixed an issue where changing the default volume profile from another inspector would not update the default volume editor. +- Fix issues in the post process system with RenderTexture being invalid in some cases, causing rendering problems. +- Fixed an issue where unncessarily serialized members in StaticLightingSky component would change each time the scene is changed. +- Fixed a weird behavior in the scalable settings drawing when the space becomes tiny (1212045). +- Fixed a regression in the ray traced indirect diffuse due to the new probe system. +- Fix for range compression factor for probes going negative (now clamped to positive values). +- Fixed path validation when creating new volume profile (case 1229933) ### Changed - Color buffer pyramid is not allocated anymore if neither refraction nor distortion are enabled diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/DefaultSettingsPanel.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/DefaultSettingsPanel.cs index 1018c140941..b244d14d284 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/DefaultSettingsPanel.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/DefaultSettingsPanel.cs @@ -45,6 +45,7 @@ public class Styles ReorderableList m_BeforeTransparentCustomPostProcesses; ReorderableList m_BeforePostProcessCustomPostProcesses; ReorderableList m_AfterPostProcessCustomPostProcesses; + int m_CurrentVolumeProfileHash; public void OnGUI(string searchContext) { @@ -207,6 +208,13 @@ void Draw_VolumeInspector() } EditorGUILayout.EndHorizontal(); + // The state of the profile can change without the asset reference changing so in this case we need to reset the editor. + if (m_CurrentVolumeProfileHash != asset.GetHashCode() && m_CachedDefaultVolumeProfileEditor != null) + { + m_CurrentVolumeProfileHash = asset.GetHashCode(); + m_CachedDefaultVolumeProfileEditor = null; + } + Editor.CreateCachedEditor(asset, Type.GetType("UnityEditor.Rendering.VolumeProfileEditor"), ref m_CachedDefaultVolumeProfileEditor); EditorGUIUtility.labelWidth -= 18; bool oldEnabled = GUI.enabled; @@ -230,13 +238,13 @@ void Draw_VolumeInspector() hdrpAsset.defaultLookDevProfile = newLookDevAsset; EditorUtility.SetDirty(hdrpAsset); } - + if (GUILayout.Button(EditorGUIUtility.TrTextContent("New", "Create a new Volume Profile for default in your default resource folder (defined in Wizard)"), GUILayout.Width(38), GUILayout.Height(18))) { DefaultVolumeProfileCreator.CreateAndAssign(DefaultVolumeProfileCreator.Kind.LookDev); } EditorGUILayout.EndHorizontal(); - + Editor.CreateCachedEditor(lookDevAsset, Type.GetType("UnityEditor.Rendering.VolumeProfileEditor"), ref m_CachedLookDevVolumeProfileEditor); EditorGUIUtility.labelWidth -= 18; oldEnabled = GUI.enabled; @@ -311,7 +319,7 @@ static string GetDefaultName(Kind kind) } return defaultName; } - + public static void CreateAndAssign(Kind kind) { var assetCreator = ScriptableObject.CreateInstance(); diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedScalableSetting.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedScalableSetting.cs index 29ffffe21c3..1c1e0e5ff17 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedScalableSetting.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedScalableSetting.cs @@ -136,29 +136,55 @@ ScalableSettingSchema schema static void MultiField(Rect position, GUIContent[] subLabels, T[] values) where T: struct { + // The number of slots we need to fit into this rectangle var length = values.Length; - var num = (position.width - (float) (length - 1) * 3f) / (float) length; - var position1 = new Rect(position) - { - width = num - }; - var labelWidth = EditorGUIUtility.labelWidth; + + // Let's compute the space allocated for every field including the label + var num = position.width / (float) length; + + // Reset the indentation var indentLevel = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; + + // Variable to keep track of the current pixel shift in the rectangle we were assigned for this whole section. + float pixelShift = 0; + + // Loop through the levels for (var index = 0; index < values.Length; ++index) { - EditorGUIUtility.labelWidth = CalcPrefixLabelWidth(subLabels[index], (GUIStyle) null); - if (typeof(T) == typeof(int)) - values[index] = (T)(object)EditorGUI.DelayedIntField(position1, subLabels[index], (int)(object)values[index]); - else if (typeof(T) == typeof(bool)) - values[index] = (T)(object)EditorGUI.Toggle(position1, subLabels[index], (bool)(object)values[index]); - else if (typeof(T) == typeof(float)) - values[index] = (T)(object)EditorGUI.FloatField(position1, subLabels[index], (float)(object)values[index]); - else - throw new ArgumentOutOfRangeException($"<{typeof(T)}> is not a supported type for multi field"); - position1.x += num + 4f; + // Let's first compute what is the width of the label of this scalable setting level + // We make sure that the label doesn't go beyond the space available for this scalable setting level + var labelWidth = Mathf.Clamp(CalcPrefixLabelWidth(subLabels[index], (GUIStyle)null), 0, num); + + // Draw the Label at the expected position + EditorGUI.LabelField(new Rect(position.x + pixelShift, position.y, labelWidth, position.height), subLabels[index]); + + // We need to remove from the position the label size that we've just drawn and shift by it's length + pixelShift += labelWidth; + + // The amount of space left for the field + float spaceLeft = num - labelWidth; + + // If at least two pixels are left to draw this field, draw it, otherwise, skip + if (spaceLeft > 2) + { + // Define the rectangle for the field + var fieldSlot = new Rect(position.x + pixelShift, position.y, num - labelWidth, position.height); + + // Draw the right field depending on its type. + if (typeof(T) == typeof(int)) + values[index] = (T)(object)EditorGUI.DelayedIntField(fieldSlot, (int)(object)values[index]); + else if (typeof(T) == typeof(bool)) + values[index] = (T)(object)EditorGUI.Toggle(fieldSlot, (bool)(object)values[index]); + else if (typeof(T) == typeof(float)) + values[index] = (T)(object)EditorGUI.FloatField(fieldSlot, (float)(object)values[index]); + else + throw new ArgumentOutOfRangeException($"<{typeof(T)}> is not a supported type for multi field"); + } + + // Shift by the slot that was left for the field + pixelShift += spaceLeft; } - EditorGUIUtility.labelWidth = labelWidth; EditorGUI.indentLevel = indentLevel; } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs index d4c0c4e2c4e..147eef60ec8 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs @@ -1264,7 +1264,7 @@ internal void GetDirectionalLightData(CommandBuffer cmd, HDCamera hdCamera, Visi lightData.shadowDimmer = additionalLightData.shadowDimmer; lightData.volumetricShadowDimmer = additionalLightData.volumetricShadowDimmer; - GetContactShadowMask(additionalLightData, HDAdditionalLightData.ScalableSettings.UseContactShadow(m_Asset), hdCamera, true, ref lightData.contactShadowMask,ref lightData.isRayTracedContactShadow); + GetContactShadowMask(additionalLightData, HDAdditionalLightData.ScalableSettings.UseContactShadow(m_Asset), hdCamera, isRasterization: true, ref lightData.contactShadowMask,ref lightData.isRayTracedContactShadow); // We want to have a colored penumbra if the flag is on and the color is not gray bool penumbraTint = additionalLightData.penumbraTint && ((additionalLightData.shadowTint.r != additionalLightData.shadowTint.g) || (additionalLightData.shadowTint.g != additionalLightData.shadowTint.b)); @@ -1365,7 +1365,7 @@ bool EnoughScreenSpaceShadowSlots(GPULightType gpuLightType, int screenSpaceChan } internal void GetLightData(CommandBuffer cmd, HDCamera hdCamera, HDShadowSettings shadowSettings, VisibleLight light, Light lightComponent, - ProcessedLightData processedData, int shadowIndex, BoolScalableSetting contactShadowsScalableSetting, bool isRasterization, ref Vector3 lightDimensions, ref int screenSpaceShadowIndex, ref int screenSpaceChannelSlot, ref LightData lightData) + in ProcessedLightData processedData, int shadowIndex, BoolScalableSetting contactShadowsScalableSetting, bool isRasterization, ref Vector3 lightDimensions, ref int screenSpaceShadowIndex, ref int screenSpaceChannelSlot, ref LightData lightData) { var additionalLightData = processedData.additionalLightData; var gpuLightType = processedData.gpuLightType; @@ -2370,7 +2370,7 @@ void PrepareGPULightdata(CommandBuffer cmd, HDCamera hdCamera, CullingResults cu LightData lightData = new LightData(); // Punctual, area, projector lights - the rendering side. - GetLightData(cmd, hdCamera, hdShadowSettings, light, lightComponent, m_ProcessedLightData[lightIndex], shadowIndex, contactShadowScalableSetting, isRasterization: true, ref lightDimensions, ref m_ScreenSpaceShadowIndex, ref m_ScreenSpaceShadowChannelSlot, ref lightData); + GetLightData(cmd, hdCamera, hdShadowSettings, light, lightComponent, in m_ProcessedLightData[lightIndex], shadowIndex, contactShadowScalableSetting, isRasterization: true, ref lightDimensions, ref m_ScreenSpaceShadowIndex, ref m_ScreenSpaceShadowChannelSlot, ref lightData); // Add the previously created light data m_lightList.lights.Add(lightData); @@ -2938,7 +2938,8 @@ static void ClearLightLists( in BuildGPULightListParameters parameters, // Note we clear the whole content and not just the header since it is fast enough, happens only in one frame and is a bit more robust // to changes to the inner workings of the lists. // Also, we clear all the lists and to be resilient to changes in pipeline. - ClearLightList(parameters, cmd, resources.tileAndClusterData.bigTileLightList); + if (parameters.runBigTilePrepass) + ClearLightList(parameters, cmd, resources.tileAndClusterData.bigTileLightList); ClearLightList(parameters, cmd, resources.tileAndClusterData.lightList); ClearLightList(parameters, cmd, resources.tileAndClusterData.perVoxelOffset); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl index aaa59d16f26..65e1815119f 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl @@ -38,6 +38,9 @@ void InitBuiltinData(PositionInputs posInput, float alpha, float3 normalWS, floa builtinData.opacity = alpha; + // Use uniform directly - The float need to be cast to uint (as unity don't support to set a uint as uniform) + builtinData.renderingLayers = _EnableLightLayers ? asuint(unity_RenderingLayer.x) : DEFAULT_LIGHT_LAYERS; + // We only want to read the screen space buffer that holds the indirect diffuse signal if this is not a transparent surface #if RAYTRACING_ENABLED && (SHADERPASS == SHADERPASS_GBUFFER || SHADERPASS == SHADERPASS_FORWARD) && !defined(_SURFACE_TYPE_TRANSPARENT) if (_RaytracedIndirectDiffuse == 1) @@ -54,12 +57,11 @@ void InitBuiltinData(PositionInputs posInput, float alpha, float3 normalWS, floa } else #endif + { + // Sample lightmap/probevolume/lightprobe/volume proxy + builtinData.bakeDiffuseLighting = SampleBakedGI(posInput, normalWS, builtinData.renderingLayers, texCoord1.xy, texCoord2.xy); + } - // Use uniform directly - The float need to be cast to uint (as unity don't support to set a uint as uniform) - builtinData.renderingLayers = _EnableLightLayers ? asuint(unity_RenderingLayer.x) : DEFAULT_LIGHT_LAYERS; - - // Sample lightmap/probevolume/lightprobe/volume proxy - builtinData.bakeDiffuseLighting = SampleBakedGI(posInput, normalWS, builtinData.renderingLayers, texCoord1.xy, texCoord2.xy); // We also sample the back lighting in case we have transmission. If not use this will be optimize out by the compiler // For now simply recall the function with inverted normal, the compiler should be able to optimize the lightmap case to not resample the directional lightmap // however it may not optimize the lightprobe case due to the proxy volume relying on dynamic if (to verify), not a problem for SH9, but a problem for proxy volume. diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs index 6b1f806b9ef..f96361158ec 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs @@ -130,6 +130,15 @@ private enum SMAAStage HDRenderPipeline m_HDInstance; + void FillEmptyExposureTexture() + { + var tex = new Texture2D(1, 1, TextureFormat.RGHalf, false, true); + tex.SetPixel(0, 0, new Color(1f, ColorUtils.ConvertExposureToEV100(1f), 0f, 0f)); + tex.Apply(); + Graphics.Blit(tex, m_EmptyExposureTexture); + CoreUtils.Destroy(tex); + } + public PostProcessSystem(HDRenderPipelineAsset hdAsset, RenderPipelineResources defaultResources) { m_Resources = defaultResources; @@ -180,11 +189,7 @@ public PostProcessSystem(HDRenderPipelineAsset hdAsset, RenderPipelineResources // TODO: Write a version that uses structured buffer instead of texture to do atomic as Metal doesn't support atomics on textures. m_MotionBlurSupportsScattering = m_MotionBlurSupportsScattering && (SystemInfo.graphicsDeviceType != GraphicsDeviceType.Metal); - var tex = new Texture2D(1, 1, TextureFormat.RGHalf, false, true); - tex.SetPixel(0, 0, new Color(1f, ColorUtils.ConvertExposureToEV100(1f), 0f, 0f)); - tex.Apply(); - Graphics.Blit(tex, m_EmptyExposureTexture); - CoreUtils.Destroy(tex); + FillEmptyExposureTexture(); // Initialize our target pool to ease RT management m_Pool = new TargetPool(); @@ -261,6 +266,23 @@ public void Cleanup() m_FarBokehTileList = null; } + // In some cases, the internal buffer of render textures might be invalid. + // Usually when using these textures with API such as SetRenderTarget, they are recreated internally. + // This is not the case when these textures are used exclusively with Compute Shaders. So to make sure they work in this case, we recreate them here. + void CheckRenderTexturesValidity() + { + if (!m_EmptyExposureTexture.rt.IsCreated()) + FillEmptyExposureTexture(); + + HDUtils.CheckRTCreated(m_InternalLogLut.rt); + HDUtils.CheckRTCreated(m_TempTexture1024.rt); + HDUtils.CheckRTCreated(m_TempTexture32.rt); + if (m_KeepAlpha) + { + HDUtils.CheckRTCreated(m_AlphaTexture.rt); + } + } + public void BeginFrame(CommandBuffer cmd, HDCamera camera, HDRenderPipeline hdInstance) { m_HDInstance = hdInstance; @@ -310,6 +332,8 @@ public void BeginFrame(CommandBuffer cmd, HDCamera camera, HDRenderPipeline hdIn m_DitheringFS = frameSettings.IsEnabled(FrameSettingsField.Dithering); m_AntialiasingFS = frameSettings.IsEnabled(FrameSettingsField.Antialiasing); + CheckRenderTexturesValidity(); + // Handle fixed exposure & disabled pre-exposure by forcing an exposure multiplier of 1 if (!m_ExposureControlFS) { @@ -930,7 +954,7 @@ void DoTemporalAntialiasing(CommandBuffer cmd, HDCamera camera, RTHandle source, float minAntiflicker = 0.0f; float maxAntiflicker = 3.5f; - float motionRejectionMultiplier = Mathf.Lerp(0.0f, 250.0f, camera.taaMotionVectorRejection * camera.taaMotionVectorRejection * camera.taaMotionVectorRejection); + float motionRejectionMultiplier = Mathf.Lerp(0.0f, 250.0f, camera.taaMotionVectorRejection * camera.taaMotionVectorRejection * camera.taaMotionVectorRejection); var taaParameters = new Vector4(camera.taaHistorySharpening, Mathf.Lerp(minAntiflicker, maxAntiflicker, camera.taaAntiFlicker), motionRejectionMultiplier, 0.0f); Vector2 historySize = new Vector2(prevHistory.referenceSize.x * prevHistory.scaleFactor.x, @@ -938,7 +962,7 @@ void DoTemporalAntialiasing(CommandBuffer cmd, HDCamera camera, RTHandle source, var rtScaleForHistory = camera.historyRTHandleProperties.rtHandleScale; var taaHistorySize = new Vector4(historySize.x, historySize.y, 1.0f / historySize.x, 1.0f / historySize.y); - // Precompute weights used for the Blackman-Harris filter. TODO: Note that these are slightly wrong as they don't take into account the jitter size. This needs to be fixed at some point. + // Precompute weights used for the Blackman-Harris filter. TODO: Note that these are slightly wrong as they don't take into account the jitter size. This needs to be fixed at some point. float crossWeights = Mathf.Exp(-2.29f * 2); float plusWeights = Mathf.Exp(-2.29f); float centerWeight = 1; @@ -2828,7 +2852,11 @@ public RTHandle Get(in Vector2 scaleFactor, GraphicsFormat format, bool mipmap = var hashCode = ComputeHashCode(scaleFactor.x, scaleFactor.y, (int)format, mipmap); if (m_Targets.TryGetValue(hashCode, out var stack) && stack.Count > 0) - return stack.Pop(); + { + var tex = stack.Pop(); + HDUtils.CheckRTCreated(tex.rt); + return tex; + } var rt = RTHandles.Alloc( scaleFactor, TextureXR.slices, DepthBits.None, colorFormat: format, dimension: TextureXR.dimension, 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 400fb7f5498..8c08d67f32a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -1894,7 +1894,7 @@ AOVRequestData aovRequest if (m_RayTracingSupported) { - // This calls need to happen once per camera + // This call need to happen once per camera // TODO: This can be wasteful for "compatible" cameras. // We need to determine the minimum set of feature used by all the camera and build the minimum number of acceleration structures. BuildRayTracingAccelerationStructure(hdCamera); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingLightCluster.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingLightCluster.cs index 3d79129c046..a163f01aab7 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingLightCluster.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingLightCluster.cs @@ -545,7 +545,7 @@ void BuildLightData(CommandBuffer cmd, HDCamera hdCamera, HDRayTracingLights ray Vector3 lightDimensions = new Vector3(0.0f, 0.0f, 0.0f); // Use the shared code to build the light data - m_RenderPipeline.GetLightData(cmd, hdCamera, hdShadowSettings, visibleLight, lightComponent, processedData, + m_RenderPipeline.GetLightData(cmd, hdCamera, hdShadowSettings, visibleLight, lightComponent, in processedData, shadowIndex, contactShadowScalableSetting, isRasterization: false, ref lightDimensions, ref screenSpaceShadowIndex, ref screenSpaceChannelSlot, ref lightData); // We make the light position camera-relative as late as possible in order diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RayTracingSubSurface.raytrace b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RayTracingSubSurface.raytrace index 45aa3819f51..ee418bafeb1 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RayTracingSubSurface.raytrace +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RayTracingSubSurface.raytrace @@ -78,7 +78,7 @@ void RayGenSubSurface() // Deduce our scattering distance // For some reason the value in shapeParam is negative, convert it to milimeters while we are there. - float3 scatteringDistance = -1.0 / shapeParam * 0.001; + float3 scatteringDistance = 1.0 / shapeParam * 0.001; // Define which sample in the sequence we are up to. int globalSampleIndex = _RaytracingFrameIndex * _RaytracingNumSamples + _RaytracingSampleIndex; diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl index 071c8beaac5..e902906a95c 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl @@ -98,7 +98,7 @@ VaryingsToDS InterpolateWithBaryCoordsToDS(VaryingsToDS input0, VaryingsToDS inp #define PackVaryingsType PackVaryingsToPS #endif -#define TEST_RECURSIVE_RENDERING (SHADEROPTIONS_RAYTRACING && defined(HAVE_RECURSIVE_RENDERING) && (SHADERPASS == SHADERPASS_GBUFFER || SHADERPASS == SHADERPASS_FORWARD || (SHADERPASS == SHADERPASS_DEPTH_ONLY))) +#define TEST_RECURSIVE_RENDERING (SHADEROPTIONS_RAYTRACING && defined(HAVE_RECURSIVE_RENDERING) && (SHADERPASS == SHADERPASS_GBUFFER || SHADERPASS == SHADERPASS_FORWARD || (SHADERPASS == SHADERPASS_DEPTH_ONLY && !defined(SCENESELECTIONPASS)))) // TODO: Here we will also have all the vertex deformation (GPU skinning, vertex animation, morph target...) or we will need to generate a compute shaders instead (better! but require work to deal with unpacking like fp16) // Make it inout so that MotionVectorPass can get the modified input values later. VaryingsMeshType VertMesh(AttributesMesh input) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/StaticLightingSky.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/StaticLightingSky.cs index b8505b5cd66..d3aa6bb1293 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/StaticLightingSky.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/StaticLightingSky.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using UnityEngine.Serialization; @@ -15,8 +16,9 @@ class StaticLightingSky : MonoBehaviour int m_LastComputedHash; bool m_NeedUpdateStaticLightingSky; - // This one contain only property values from overridden properties in the original profile component - public SkySettings m_SkySettings; + [NonSerialized] + public SkySettings m_SkySettings; // This one contain only property values from overridden properties in the original profile component + [NonSerialized] public SkySettings m_SkySettingsFromProfile; public SkySettings skySettings diff --git a/com.unity.render-pipelines.high-definition/Runtime/Utilities/ProbeSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/Utilities/ProbeSettings.cs index 23499318e19..23360c346f5 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Utilities/ProbeSettings.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Utilities/ProbeSettings.cs @@ -137,6 +137,7 @@ public struct Lighting public float fadeDistance; /// The result of the rendering of the probe will be divided by this factor. When the probe is read, this factor is undone as the probe data is read. /// This is to simply avoid issues with values clamping due to precision of the storing format. + [Min(1e-6f)] public float rangeCompressionFactor; }