diff --git a/Packages/com.unity.render-pipelines.core/CHANGELOG.md b/Packages/com.unity.render-pipelines.core/CHANGELOG.md index 49a917ac7c2..bddccf0cf65 100644 --- a/Packages/com.unity.render-pipelines.core/CHANGELOG.md +++ b/Packages/com.unity.render-pipelines.core/CHANGELOG.md @@ -9,6 +9,22 @@ 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. +## [15.0.6] - 2023-09-27 + +This version is compatible with Unity 2023.1.16f1. + +### Added +- Added callbacks when RenderPipeline is created or disposed. +- ObjectID Render Request that provides a render texture with the ObjectId of each pixel. + +### Fixed +- Fixed potentially broken rendering and errors after renaming a VolumeProfile asset. +- Fixed a crash on keywords::LocalKeywordState::ResetWithSpace when shader contains Grab Pass. +- Fixed Rendering Debugger runtime UI getting occluded by user UI with sorting order larger than 0. +- Removed some unexpected SRP changed callback invocations. +- Fixed console errors when debug actions are removed from Input Manager during play mode. +- Fixed occasional ArgumentOutOfRangeException in StaticLightingSky. + ## [15.0.5] - 2023-05-23 This version is compatible with Unity 2023.1.0b19. diff --git a/Packages/com.unity.render-pipelines.core/Editor/AssetDatabaseHelper.cs b/Packages/com.unity.render-pipelines.core/Editor/AssetDatabaseHelper.cs new file mode 100644 index 00000000000..dd6742f1efc --- /dev/null +++ b/Packages/com.unity.render-pipelines.core/Editor/AssetDatabaseHelper.cs @@ -0,0 +1,34 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace UnityEditor.Rendering +{ + /// Set of helpers for AssetDatabase operations. + public static class AssetDatabaseHelper + { + /// + /// Finds all assets of type T in the project. + /// + /// Asset type extension i.e ".mat" for materials + /// The type of material you are looking for + /// A IEnumerable object + public static IEnumerable FindAssets(string extension = null) + { + string typeName = typeof(T).ToString(); + int i = typeName.LastIndexOf('.'); + if (i != -1) + { + typeName = typeName.Substring(i+1, typeName.Length - i-1); + } + + string query = !string.IsNullOrEmpty(extension) ? $"t:{typeName} glob:\"**/*{extension}\"" : $"t:{typeName}"; + + foreach (var guid in AssetDatabase.FindAssets(query)) + { + var asset = AssetDatabase.LoadMainAssetAtPath(AssetDatabase.GUIDToAssetPath(guid)); + if (asset is T castAsset) + yield return castAsset; + } + } + } +} diff --git a/Packages/com.unity.render-pipelines.core/Editor/AssetDatabaseHelper.cs.meta b/Packages/com.unity.render-pipelines.core/Editor/AssetDatabaseHelper.cs.meta new file mode 100644 index 00000000000..af6fffbb136 --- /dev/null +++ b/Packages/com.unity.render-pipelines.core/Editor/AssetDatabaseHelper.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ecc2633973414f6d8bbab97cf0c937b4 +timeCreated: 1693402114 \ No newline at end of file diff --git a/Packages/com.unity.render-pipelines.core/Editor/MaterialUpgrader.cs b/Packages/com.unity.render-pipelines.core/Editor/MaterialUpgrader.cs index b945345a5aa..5bb4f1385b2 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/MaterialUpgrader.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/MaterialUpgrader.cs @@ -38,6 +38,13 @@ public class MaterialUpgrader string m_OldShader; string m_NewShader; + private static string[] s_PathsWhiteList = new[] + { + "Hidden/", + "HDRP/", + "Shader Graphs/" + }; + /// /// Retrieves path to new shader. /// @@ -309,20 +316,6 @@ public void RenameKeywordToFloat(string oldName, string newName, float setVal, f m_KeywordFloatRename.Add(new KeywordFloatRename { keyword = oldName, property = newName, setVal = setVal, unsetVal = unsetVal }); } - /// - /// Checking if the passed in value is a path to a Material. - /// - /// Path to test. - /// Returns true if the passed in value is a path to a material. - static bool IsMaterialPath(string path) - { - if (string.IsNullOrEmpty(path)) - { - throw new ArgumentNullException(nameof(path)); - } - return path.HasExtension(".mat"); - } - static MaterialUpgrader GetUpgrader(List upgraders, Material material) { if (material == null || material.shader == null) @@ -364,6 +357,29 @@ static bool ShouldUpgradeShader(Material material, HashSet shaderNamesTo return !shaderNamesToIgnore.Contains(material.shader.name); } + + private static bool IsNotAutomaticallyUpgradable(List upgraders, Material material) + { + return GetUpgrader(upgraders, material) == null && !material.shader.name.ContainsAny(s_PathsWhiteList); + } + + + /// + /// Checking if project folder contains any materials that are not using built-in shaders. + /// + /// List if MaterialUpgraders + /// Returns true if at least one material uses a non-built-in shader (ignores Hidden, HDRP and Shader Graph Shaders) + public static bool ProjectFolderContainsNonBuiltinMaterials(List upgraders) + { + foreach (var material in AssetDatabaseHelper.FindAssets(".mat")) + { + if(IsNotAutomaticallyUpgradable(upgraders, material)) + return true; + } + + return false; + } + /// /// Upgrade the project folder. /// @@ -388,31 +404,21 @@ public static void UpgradeProjectFolder(List upgraders, HashSe if ((!Application.isBatchMode) && (!EditorUtility.DisplayDialog(DialogText.title, "The upgrade will overwrite materials in your project. " + DialogText.projectBackMessage, DialogText.proceed, DialogText.cancel))) return; - int totalMaterialCount = 0; - foreach (string s in UnityEditor.AssetDatabase.GetAllAssetPaths()) - { - if (IsMaterialPath(s)) - totalMaterialCount++; - } - + var materialAssets = AssetDatabase.FindAssets($"t:{nameof(Material)} glob:\"**/*.mat\""); int materialIndex = 0; - foreach (string path in UnityEditor.AssetDatabase.GetAllAssetPaths()) - { - if (IsMaterialPath(path)) - { - materialIndex++; - if (UnityEditor.EditorUtility.DisplayCancelableProgressBar(progressBarName, string.Format("({0} of {1}) {2}", materialIndex, totalMaterialCount, path), (float)materialIndex / (float)totalMaterialCount)) - break; - Material m = UnityEditor.AssetDatabase.LoadMainAssetAtPath(path) as Material; + foreach (var guid in materialAssets) + { + Material material = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guid)); + materialIndex++; + if (UnityEditor.EditorUtility.DisplayCancelableProgressBar(progressBarName, string.Format("({0} of {1}) {2}", materialIndex, materialAssets.Length, material), (float)materialIndex / (float)materialAssets.Length)) + break; - if (!ShouldUpgradeShader(m, shaderNamesToIgnore)) - continue; + if (!ShouldUpgradeShader(material, shaderNamesToIgnore)) + continue; - Upgrade(m, upgraders, flags); + Upgrade(material, upgraders, flags); - //SaveAssetsAndFreeMemory(); - } } // Upgrade terrain specifically since it is a builtin material diff --git a/Packages/com.unity.render-pipelines.core/Editor/StringExtensions.cs b/Packages/com.unity.render-pipelines.core/Editor/StringExtensions.cs index 59dfcd1aa7c..0097e227b22 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/StringExtensions.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/StringExtensions.cs @@ -26,5 +26,29 @@ public static class StringExtensions /// True if the extension is found on the string path public static bool HasExtension(this string input, string extension) => input.EndsWith(extension, StringComparison.OrdinalIgnoreCase); + + + /// + /// Checks if a string contains any of the strings given in strings to check and early out if it does + /// + /// The input string + /// List of strings to check + /// True if a string contains any of the strings given in strings + public static bool ContainsAny(this string input, params string[] stringsToCheck) + { + if(string.IsNullOrEmpty(input)) + return false; + + foreach (var value in stringsToCheck) + { + if(string.IsNullOrEmpty(value)) + continue; + + if (input.Contains(value)) + return true; + } + + return false; + } } } 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 2b33338d4c3..a92c1291281 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeParameter.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeParameter.cs @@ -1875,6 +1875,20 @@ public override object Clone() { return new AnimationCurveParameter(new AnimationCurve(GetValue().keys), overrideState); } + + /// + /// Returns a hash code for the animationCurve. + /// + /// A hash code for the animationCurve. + public override int GetHashCode() + { + unchecked + { + var hash = overrideState.GetHashCode(); + + return hash * 23 + value.GetHashCode(); + } + } } /// diff --git a/Packages/com.unity.render-pipelines.core/package.json b/Packages/com.unity.render-pipelines.core/package.json index a08e6da14f9..6f16c6810ad 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": "15.0.6", + "version": "15.0.7", "unity": "2023.1", "displayName": "Core RP Library", "dependencies": { 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 bd46f2c3169..e475892dedf 100644 --- a/Packages/com.unity.render-pipelines.high-definition-config/CHANGELOG.md +++ b/Packages/com.unity.render-pipelines.high-definition-config/CHANGELOG.md @@ -9,6 +9,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. +## [15.0.6] - 2023-09-27 + +This version is compatible with Unity 2023.1.16f1. + +Version Updated +The version number for this package has increased due to a version update of a related graphics package. + ## [15.0.5] - 2023-05-23 This version is compatible with Unity 2023.1.0b19. 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 b5e81be5423..c35ed165f17 100644 --- a/Packages/com.unity.render-pipelines.high-definition-config/package.json +++ b/Packages/com.unity.render-pipelines.high-definition-config/package.json @@ -1,10 +1,10 @@ { "name": "com.unity.render-pipelines.high-definition-config", "description": "Configuration files for the High Definition Render Pipeline.", - "version": "15.0.6", + "version": "15.0.7", "unity": "2023.1", "displayName": "High Definition RP Config", "dependencies": { - "com.unity.render-pipelines.core": "15.0.6" + "com.unity.render-pipelines.core": "15.0.7" } } \ No newline at end of file diff --git a/Packages/com.unity.render-pipelines.high-definition/CHANGELOG.md b/Packages/com.unity.render-pipelines.high-definition/CHANGELOG.md index ba3a53bf65f..ea1fb190156 100644 --- a/Packages/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/Packages/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -9,6 +9,80 @@ 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. +## [15.0.6] - 2023-09-27 + +This version is compatible with Unity 2023.1.16f1. + +### Changed +- Improved CPU performances by disabling "QuantizedFrontToBack" sorting in opaque rendering. +- When HDRP is disabled, Compute Shaders are being stripped. +- Avoid clamping to integers for HDR manipulation. +- Reduced GC Alloc when using raytracing and HDRP. +- Updated description of Decal Projector Draw Distance setting to mention HDRP asset setting. + +### Fixed +- Fixed TAA aliasing edge issues on alpha output for recorder / green screen. This fix does the following: +* Removes history rejection when the current alpha value is 0. Instead it does blend with the history color when alpha value is 0 on the current plane. +* The reasoning for blending again with the history when alpha is 0 is because we want the color to blend a bit with opacity, which is the main reason for the alpha values. sort of like a precomputed color +* As a safety, we set the color to black if alpha is 0. This results in better image quality when alpha is enabled. +- Added check to ensure gismos arent rendered when they shouldnt be. +- Fixed quad overdraw debug at high resolution. +- Fixed cloud layer rotation does not allow for smooth rotation. +- Fixed GetScaledSize when not using scaling. +- Fixed VT init to avoid RTHandle allocation outside of HDRP rendering loop. +- Upgrading from DLSS 2.4 to DLSS 3.0 for upscaling part. +- Fixed the incorrect base color of decals for transparency. +- Fixed shaders stripping for Lens Flares. +- Various space transform fixes. +- Fixed HDProbes to support custom resolutions for all rendering modes. +- Fixed scene template dependencies. +- Minor fix to HDRP UI when Raytraced AO is enabled. +- Added a new custom pass injection after opaque and sky finished rendering. +- Fixed D3D validation error for area lights in HDShadowAtlas. +- Fixed baked light being wrongly put in the cached shadow atlas. +- Improving DLSS ghosting artifacts a little bit, by using a better pre-exposure parameter. Fixing reset history issues on DLSS camera cuts. +- Added an helpbox for local custom pass volumes that doesn't have a collider attached. +- Respect the transparent reflections settings when using raytracing. +- Fixed Virtual offset being computed if distance was 0. +- Show base color texture on decal materials if Affect BaseColor is disabled. +- Fixed inconsistent documentation about hardware supporting raytracing. +- Fixed wrong metapass when using planar/triplanar projection in HDRP. +- Fixed color pyramid history buffer logic when history is reset and the color pyramid is not required. +- Fixed fireflies in path traced volume scattering using MIS. Add support for anisotropic fog. +- Fixed Decal additive normal blending on shadergraph materials. +- Fixed decal projector with neutral normal when using surface gradient. +- Fixed recovering the current Quality level when migrating a HDRP Asset. +- Added warning to reflection probe editor to prevent user from baking in a low quality level. +- Fixed custom pass injection point "After Opaque And Sky" happening after cloud rendering. +- Fixed FTLP (Fine Tiled Light Pruning) Shader Options max light count. Previous support only supported up to 63 These changes allow to go up to 255 with higher instability as numbers per tile approach 255. +For support greater than 255, do it at your own risk! (and expect some flickering). +- Fixed out of bounds access when XR is enabled. +- Mixed runtime lights were not considering the intensity multiplier during bakes. These changes fix this behaviour and make bakes more intuitive. +- Fixed the incorrect size of the material preview texture. +- Fixed prefab preview rendering dark until moved. +- Fixed: realtime Reflection probe makes volumetrics clouds wind stop. +- Fixed error on water inspector when no SRP is active. +- Fixed preview for refractive materials with MSAA. +- Allow the game to switch HDR on or off during run time. +- Fixed GraphicsBuffer leak from APV binding code. +- Re-enabled HDR output on Mac (Was disabled). +- Fixed a potential GPU crash/hang when using local volumetric fogs. +- Added error when the Rendering Layer names in HDRP Global Settings is empty. +- Fixed an issue where an async pass would try to sync to a culled pass mistakenly. +- Fixed the logic used to set up materials featuring displacement mapping that would sometimes result in artifacts or suboptimal performance. +- Mixed tracing mode for transparent screenspace reflections now mixes both tracing modes as expected, instead of only using ray traced reflections. +- Fixed custom post process volume component example in doc. +- Fixed ShaderGraph Decal material position issue by using world space position. +- Fixed the sharpening pass in order to avoid washed-out colors when using a render target with an alpha channel. +- Fixed Helpbox UI for LightProbeGroup Inspector. +- Fixed missing current sector data in debug modes. +- Fixed error when assigning non water material to water. +- Fixed to sample settings helper. +- Fixed foam generated on shore waves. +- Fixed missing foam color parameter. +- Fixed GPU warnings due to water system. +- Fixing a DLSS error in the Standalone Profiler console for Unity 2023.1 by backporting a PR that recently fixed it in 2023.2 + ## [15.0.5] - 2023-05-23 This version is compatible with Unity 2023.1.0b19. diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/TransparencyUIBlock.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/TransparencyUIBlock.cs index 3fe7473bef1..1272fd44241 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/TransparencyUIBlock.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/TransparencyUIBlock.cs @@ -74,7 +74,12 @@ protected override bool showSection if (materials[0].IsShaderGraph()) { var shader = materials[0].shader; - var defaultRefractionModel = shader.GetPropertyDefaultFloatValue(shader.FindPropertyIndex(kRefractionModel)); + + var propertyIndex = shader.FindPropertyIndex(kRefractionModel); + if (propertyIndex == -1) + return false; + + var defaultRefractionModel = shader.GetPropertyDefaultFloatValue(propertyIndex); if (defaultRefractionModel == 0) return false; } diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs index 8fd9b4d5c41..66e7937e557 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs @@ -201,6 +201,7 @@ public class Styles public const string cacheErrorFormat = "This configuration will lead to more than 2 GB reserved for this cache at runtime! ({0} requested) Only {1} element will be reserved instead."; public const string cacheInfoFormat = "Reserving {0} in memory at runtime."; public const string multipleDifferenteValueMessage = "Multiple different values"; + public const string rayTracingUnsupportedMessage = "The current HDRP Asset does not support Ray Tracing."; public static readonly GUIContent cookieSizeContent = EditorGUIUtility.TrTextContent("Cookie Size", "Specifies the maximum size for the individual 2D cookies that HDRP uses for Directional and Spot Lights."); public static readonly GUIContent cookieTextureArraySizeContent = EditorGUIUtility.TrTextContent("Texture Array Size", "Sets the maximum Texture Array size for the 2D cookies HDRP uses for Directional and Spot Lights. Higher values allow HDRP to use more cookies concurrently on screen."); 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 new file mode 100644 index 00000000000..9a399270845 --- /dev/null +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/LightClusterEditor.cs @@ -0,0 +1,27 @@ +using UnityEngine; +using UnityEngine.Rendering; +using UnityEngine.Rendering.HighDefinition; + +namespace UnityEditor.Rendering.HighDefinition +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(LightCluster))] + class LightClusterEditor : VolumeComponentEditor + { + public override void OnInspectorGUI() + { + HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset; + bool notSupported = currentAsset != null && !currentAsset.currentPlatformRenderPipelineSettings.supportRayTracing; + if (notSupported) + { + EditorGUILayout.Space(); + HDEditorUtils.QualitySettingsHelpBox(HDRenderPipelineUI.Styles.rayTracingUnsupportedMessage, + MessageType.Warning, HDRenderPipelineUI.ExpandableGroup.Rendering, + "m_RenderPipelineSettings.supportRayTracing"); + } + using var disableScope = new EditorGUI.DisabledScope(notSupported); + + base.OnInspectorGUI(); + } + } +} diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/LightClusterEditor.cs.meta b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/LightClusterEditor.cs.meta new file mode 100644 index 00000000000..224c1780c69 --- /dev/null +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/LightClusterEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0d4669e8c9d524c4e972b97a5c8b9e3a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/HDRenderPipelineGlobalSettingsUI.Drawers.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/HDRenderPipelineGlobalSettingsUI.Drawers.cs index 84e70a790e6..90a36905162 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/HDRenderPipelineGlobalSettingsUI.Drawers.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/HDRenderPipelineGlobalSettingsUI.Drawers.cs @@ -21,11 +21,13 @@ public class DocumentationUrls #region Resources - static readonly CED.IDrawer ResourcesSection = CED.Group( + static readonly CED.IDrawer ResourcesSection = CED.Conditional( + (s,o) => Unsupported.IsDeveloperMode(), + CED.Group( CED.Group((serialized, owner) => CoreEditorUtils.DrawSectionHeader(Styles.resourceLabel)), CED.Group((serialized, owner) => EditorGUILayout.Space()), CED.Group(DrawResourcesSection), - CED.Group((serialized, owner) => EditorGUILayout.Space()) + CED.Group((serialized, owner) => EditorGUILayout.Space())) ); static void DrawResourcesSection(SerializedHDRenderPipelineGlobalSettings serialized, Editor owner) { diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Upgraders/UpgradeStandardShaderMaterials.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Upgraders/UpgradeStandardShaderMaterials.cs index 2c79e0bbfeb..fb90d62fd4d 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Upgraders/UpgradeStandardShaderMaterials.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Upgraders/UpgradeStandardShaderMaterials.cs @@ -7,7 +7,7 @@ namespace UnityEditor.Rendering.HighDefinition { class UpgradeStandardShaderMaterials { - static List GetHDUpgraders() + public static List GetHDUpgraders() { var upgraders = new List(); upgraders.Add(new StandardsToHDLitMaterialUpgrader("Standard", "HDRP/Lit")); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/VFXGraph/Shaders/Templates/Volumetric/PassVolumetricFog.template b/Packages/com.unity.render-pipelines.high-definition/Editor/VFXGraph/Shaders/Templates/Volumetric/PassVolumetricFog.template index 036641250cc..5d8d7ab25ce 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/VFXGraph/Shaders/Templates/Volumetric/PassVolumetricFog.template +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/VFXGraph/Shaders/Templates/Volumetric/PassVolumetricFog.template @@ -59,8 +59,8 @@ VertexToFragment Vert(vs_input i) UNITY_SETUP_INSTANCE_ID(i); // Call manually init instancing to get the correct batch index needed to compute the particle ID and call VFXInitInstancing with the correct parameters. - uint batchIndex, unused; - VFXInitInstancing(0, unused, batchIndex); + uint batchIndex, unused1, unused2; + VFXInitInstancing(0, unused1, batchIndex, unused2); uint id = i.vertexId + VFX_GET_INSTANCE_ID(i) * 2048 * 4; uint quadCountPerParticle = maxSliceCount[batchIndex]; diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/VFXGraph/UIBlocks/VFXShaderGraphGUI.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/VFXGraph/UIBlocks/VFXShaderGraphGUI.cs index afbe5b1a500..86d7dcc9e17 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/VFXGraph/UIBlocks/VFXShaderGraphGUI.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/VFXGraph/UIBlocks/VFXShaderGraphGUI.cs @@ -15,6 +15,9 @@ public VFXShaderGraphGUILit() { uiBlocks.Clear(); uiBlocks.Add(new SurfaceOptionUIBlock(MaterialUIBlock.ExpandableBit.Base, features: vfxSurfaceOptionFeatures)); + //VFX inspector UI is taking a shortcut here: + //We aren't doing distinction between LightingShaderGraphGUI & LitShaderGUI + //Only refraction has to be added to cover all settings cases uiBlocks.Add(new TransparencyUIBlock(MaterialUIBlock.ExpandableBit.Transparency, TransparencyUIBlock.Features.Refraction)); } } diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.Window.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.Window.cs index 2a7e94918cf..2fec22f18cc 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.Window.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.Window.cs @@ -53,6 +53,7 @@ static class Style public static readonly string resolveAllQuality = L10n.Tr("Fix All Qualities"); public static readonly string resolveAllBuildTarget = L10n.Tr("Fix All Platforms"); public static readonly string fixAllOnNonHDRP = L10n.Tr("The active Quality Level is not using a High Definition Render Pipeline asset. If you attempt a Fix All, the Quality Level will be changed to use it."); + public static readonly string nonBuiltinMaterialWarning = L10n.Tr("The project contains materials that are not using built-in shaders. These will be skipped in the automated migration process."); public struct ConfigStyle { @@ -452,6 +453,13 @@ private void CreateGUI() currentQualityScope.Add(dxrScopeCurrentQuality); container.Add(CreateTitle(Style.migrationTitle)); + + if (MaterialUpgrader.ProjectFolderContainsNonBuiltinMaterials( + UpgradeStandardShaderMaterials.GetHDUpgraders())) + { + container.Add(new HelpBox(HelpBox.Kind.Warning, Style.nonBuiltinMaterialWarning)); + } + container.Add(CreateLargeButton(Style.migrateAllButton, UpgradeStandardShaderMaterials.UpgradeMaterialsProject)); container.Add(CreateLargeButton(Style.migrateSelectedButton, UpgradeStandardShaderMaterials.UpgradeMaterialsSelection)); container.Add(CreateLargeButton(Style.migrateMaterials, HDRenderPipelineMenuItems.UpgradeMaterials)); 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 5d784bd8ae1..1cc3896cae4 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 @@ -801,7 +801,8 @@ public bool useScreenSpaceShadows /// public bool interactsWithSky { - get => m_InteractsWithSky; + // m_InteractWithSky can be true if user changed from directional to point light, so we need to check current type + get => m_InteractsWithSky && legacyLight.type == LightType.Directional; set { if (m_InteractsWithSky == value) diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDGpuLightsBuilder.Jobs.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDGpuLightsBuilder.Jobs.cs index 363644f46d9..b8bcf0b7dd4 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDGpuLightsBuilder.Jobs.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDGpuLightsBuilder.Jobs.cs @@ -79,8 +79,6 @@ internal struct CreateGpuLightDataJob : IJobParallelFor public float aerosolExtinctionCoefficient; [ReadOnly] public float maxShadowDistance; - [ReadOnly] - public float shadowOutBorderDistance; #endregion @@ -639,21 +637,6 @@ private void ConvertDirectionalLightToGPUFormat( var bakingOutput = visibleLightBakingOutput[lightIndex]; lightData.shadowMaskSelector[bakingOutput.occlusionMaskChannel] = 1.0f; lightData.nonLightMappedOnly = visibleLightShadowCasterMode[lightIndex] == LightShadowCasterMode.NonLightmappedOnly ? 1 : 0; - // Get shadow info from the volume stack. - float maxDistanceSq = maxShadowDistance * maxShadowDistance; - float outBorderDistance = shadowOutBorderDistance; - if (outBorderDistance < 1e-4f) - { - lightData.cascadesBorderFadeScaleBias = new Vector2(1e6f, -maxDistanceSq * 1e6f); - } - else - { - outBorderDistance = 1.0f - outBorderDistance; - outBorderDistance *= outBorderDistance; - float distanceFadeNear = outBorderDistance * maxDistanceSq; - lightData.cascadesBorderFadeScaleBias.x = 1.0f / (maxDistanceSq - distanceFadeNear); - lightData.cascadesBorderFadeScaleBias.y = -distanceFadeNear / (maxDistanceSq - distanceFadeNear); - } } else { @@ -764,7 +747,6 @@ public void StartCreateGpuLightDataJob( aerosolExtinctionCoefficient = skySettings.GetAerosolExtinctionCoefficient(), maxShadowDistance = shadowSettings.maxShadowDistance.value, - shadowOutBorderDistance = shadowSettings.cascadeShadowBorders[shadowSettings.cascadeShadowSplitCount.value - 1], // light entity data lightRenderDataArray = lightEntities.lightData, diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightDefinition.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightDefinition.cs index 47b41e1b839..3b6f130947f 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightDefinition.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightDefinition.cs @@ -95,8 +95,6 @@ struct DirectionalLightData [SurfaceDataAttributes(precision = FieldPrecision.Real)] public Vector4 shadowMaskSelector; // Used with ShadowMask feature - public Vector2 cascadesBorderFadeScaleBias; - public float diffuseDimmer; public float specularDimmer; diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightDefinition.cs.hlsl b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightDefinition.cs.hlsl index 634cb157650..1d7d27ce7ca 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightDefinition.cs.hlsl +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightDefinition.cs.hlsl @@ -5,10 +5,16 @@ #ifndef LIGHTDEFINITION_CS_HLSL #define LIGHTDEFINITION_CS_HLSL // -// UnityEngine.Rendering.HighDefinition.EnvCacheType: static fields +// UnityEngine.Rendering.HighDefinition.EnvLightReflectionDataRT: static fields // -#define ENVCACHETYPE_TEXTURE2D (0) -#define ENVCACHETYPE_CUBEMAP (1) +#define MAX_PLANAR_REFLECTIONS (16) +#define MAX_CUBE_REFLECTIONS (64) + +// +// UnityEngine.Rendering.HighDefinition.EnvLightReflectionData: static fields +// +#define MAX_PLANAR_REFLECTIONS (16) +#define MAX_CUBE_REFLECTIONS (64) // // UnityEngine.Rendering.HighDefinition.GPULightType: static fields @@ -23,29 +29,16 @@ #define GPULIGHTTYPE_DISC (7) // -// UnityEngine.Rendering.HighDefinition.GPUImageBasedLightingType: static fields -// -#define GPUIMAGEBASEDLIGHTINGTYPE_REFLECTION (0) -#define GPUIMAGEBASEDLIGHTINGTYPE_REFRACTION (1) - -// -// UnityEngine.Rendering.HighDefinition.CookieMode: static fields -// -#define COOKIEMODE_NONE (0) -#define COOKIEMODE_CLAMP (1) -#define COOKIEMODE_REPEAT (2) - -// -// UnityEngine.Rendering.HighDefinition.EnvLightReflectionDataRT: static fields +// UnityEngine.Rendering.HighDefinition.EnvCacheType: static fields // -#define MAX_PLANAR_REFLECTIONS (16) -#define MAX_CUBE_REFLECTIONS (64) +#define ENVCACHETYPE_TEXTURE2D (0) +#define ENVCACHETYPE_CUBEMAP (1) // -// UnityEngine.Rendering.HighDefinition.EnvLightReflectionData: static fields +// UnityEngine.Rendering.HighDefinition.GPUImageBasedLightingType: static fields // -#define MAX_PLANAR_REFLECTIONS (16) -#define MAX_CUBE_REFLECTIONS (64) +#define GPUIMAGEBASEDLIGHTINGTYPE_REFLECTION (0) +#define GPUIMAGEBASEDLIGHTINGTYPE_REFRACTION (1) // // UnityEngine.Rendering.HighDefinition.EnvShapeType: static fields @@ -60,6 +53,13 @@ // #define ENVCONSTANTS_CONVOLUTION_MIP_COUNT (7) +// +// UnityEngine.Rendering.HighDefinition.CookieMode: static fields +// +#define COOKIEMODE_NONE (0) +#define COOKIEMODE_CLAMP (1) +#define COOKIEMODE_REPEAT (2) + // Generated from UnityEngine.Rendering.HighDefinition.DirectionalLightData // PackingRules = Exact struct DirectionalLightData @@ -84,7 +84,6 @@ struct DirectionalLightData real minRoughness; int screenSpaceShadowIndex; real4 shadowMaskSelector; - float2 cascadesBorderFadeScaleBias; float diffuseDimmer; float specularDimmer; float penumbraTint; 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 077b8c0a039..b7dbd8ed50b 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 @@ -271,12 +271,20 @@ SHADOW_TYPE EvaluateShadow_Directional( LightLoopContext lightLoopContext, Posit #ifdef SHADOWS_SHADOWMASK float3 camToPixel = posInput.positionWS - GetPrimaryCameraPosition(); float distanceCamToPixel2 = dot(camToPixel, camToPixel); - float fade = saturate(distanceCamToPixel2 * light.cascadesBorderFadeScaleBias.x + light.cascadesBorderFadeScaleBias.y); - // 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 - shadow = shadow - fade + fade * shadowMask; + int shadowSplitIndex = lightLoopContext.shadowContext.shadowSplitIndex; + if (shadowSplitIndex < 0) + { + shadow = shadowMask; + } + else if (shadowSplitIndex == int(_CascadeShadowCount) - 1) + { + 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 + shadow = shadow - fade + fade * shadowMask; + } // See comment in EvaluateBSDF_Punctual shadow = light.nonLightMappedOnly ? min(shadowMask, shadow) : shadow; diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadow.hlsl b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadow.hlsl index 259170fe9c9..7f8ba241fd6 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadow.hlsl +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadow.hlsl @@ -22,7 +22,7 @@ // normalWS is the vertex normal if available or shading normal use to bias the shadow position -float GetDirectionalShadowAttenuation(HDShadowContext shadowContext, float2 positionSS, float3 positionWS, float3 normalWS, int shadowDataIndex, float3 L) +float GetDirectionalShadowAttenuation(inout HDShadowContext shadowContext, float2 positionSS, float3 positionWS, float3 normalWS, int shadowDataIndex, float3 L) { #if SHADOW_AUTO_FLIP_NORMAL normalWS *= FastSign(dot(normalWS, L)); diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs index b5040b4799a..deab2080765 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs @@ -2025,16 +2025,19 @@ void PushLightDataGlobalParams(CommandBuffer cmd) for (int viewId = 0; viewId < m_GpuLightsBuilder.lightsPerViewCount; ++viewId) { HDGpuLightsBuilder.LightsPerView lightsPerView = m_GpuLightsBuilder.lightsPerView[viewId]; - Debug.Assert(lightsPerView.boundsCount <= m_TotalLightCount, "Encountered bounds counts that are greater than the total light count."); + + bool validLightCount = lightsPerView.boundsCount <= m_TileAndClusterData.maxLightCount; + Debug.Assert(validLightCount, "Encountered bounds counts that are greater than the total light count."); /// In the CPU we have stored the left and right eye in one single array, offset by the LightsPerView.boundsOffset. This is before trivial rejection. /// In the GPU we compact them, and access each eye by the actual m_TotalLightCount, which contains the post trivial rejection offset. int inputStartIndex = lightsPerView.boundsOffset; int outputStartIndex = viewId * m_TotalLightCount; + int maxLightCount = (validLightCount) ? lightsPerView.boundsCount : m_TileAndClusterData.maxLightCount; // These two buffers have been set in Rebuild(). At this point, view 0 contains combined data from all views - m_TileAndClusterData.convexBoundsBuffer.SetData(m_GpuLightsBuilder.lightBounds, inputStartIndex, outputStartIndex, lightsPerView.boundsCount); - m_TileAndClusterData.lightVolumeDataBuffer.SetData(m_GpuLightsBuilder.lightVolumes, inputStartIndex, outputStartIndex, lightsPerView.boundsCount); + m_TileAndClusterData.convexBoundsBuffer.SetData(m_GpuLightsBuilder.lightBounds, inputStartIndex, outputStartIndex, maxLightCount); + m_TileAndClusterData.lightVolumeDataBuffer.SetData(m_GpuLightsBuilder.lightVolumes, inputStartIndex, outputStartIndex, maxLightCount); } ConstantBuffer.PushGlobal(cmd, m_EnvLightReflectionData, HDShaderIDs._EnvLightReflectionData); diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAlgorithms.hlsl b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAlgorithms.hlsl index 69baa6b4d70..beefb0fda7a 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAlgorithms.hlsl +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAlgorithms.hlsl @@ -254,12 +254,16 @@ void LoadDirectionalShadowDatas(inout HDShadowData sd, HDShadowContext shadowCon sd.cacheTranslationDelta = shadowContext.shadowDatas[index].cacheTranslationDelta; } -float EvalShadow_CascadedDepth_Blend_SplitIndex(HDShadowContext shadowContext, Texture2D tex, SamplerComparisonState samp, float2 positionSS, float3 positionWS, float3 normalWS, int index, float3 L, out int shadowSplitIndex) +float EvalShadow_CascadedDepth_Blend_SplitIndex(inout HDShadowContext shadowContext, Texture2D tex, SamplerComparisonState samp, float2 positionSS, float3 positionWS, float3 normalWS, int index, float3 L, out int shadowSplitIndex) { float alpha; int cascadeCount; float shadow = 1.0; shadowSplitIndex = EvalShadow_GetSplitIndex(shadowContext, index, positionWS, alpha, cascadeCount); +#ifdef SHADOWS_SHADOWMASK + shadowContext.shadowSplitIndex = shadowSplitIndex; + shadowContext.fade = alpha; +#endif float3 basePositionWS = positionWS; @@ -309,18 +313,22 @@ float EvalShadow_CascadedDepth_Blend_SplitIndex(HDShadowContext shadowContext, T return shadow; } -float EvalShadow_CascadedDepth_Blend(HDShadowContext shadowContext, Texture2D tex, SamplerComparisonState samp, float2 positionSS, float3 positionWS, float3 normalWS, int index, float3 L) +float EvalShadow_CascadedDepth_Blend(inout HDShadowContext shadowContext, Texture2D tex, SamplerComparisonState samp, float2 positionSS, float3 positionWS, float3 normalWS, int index, float3 L) { int unusedSplitIndex; return EvalShadow_CascadedDepth_Blend_SplitIndex(shadowContext, tex, samp, positionSS, positionWS, normalWS, index, L, unusedSplitIndex); } -float EvalShadow_CascadedDepth_Dither_SplitIndex(HDShadowContext shadowContext, Texture2D tex, SamplerComparisonState samp, float2 positionSS, float3 positionWS, float3 normalWS, int index, float3 L, out int shadowSplitIndex) +float EvalShadow_CascadedDepth_Dither_SplitIndex(inout HDShadowContext shadowContext, Texture2D tex, SamplerComparisonState samp, float2 positionSS, float3 positionWS, float3 normalWS, int index, float3 L, out int shadowSplitIndex) { float alpha; int cascadeCount; float shadow = 1.0; shadowSplitIndex = EvalShadow_GetSplitIndex(shadowContext, index, positionWS, alpha, cascadeCount); +#ifdef SHADOWS_SHADOWMASK + shadowContext.shadowSplitIndex = shadowSplitIndex; + shadowContext.fade = alpha; +#endif // Forcing the alpha to zero allows us to avoid the dithering as it requires the screen space position and an additional // shadow read wich can be avoided in this case. @@ -362,7 +370,7 @@ float EvalShadow_CascadedDepth_Dither_SplitIndex(HDShadowContext shadowContext, return shadow; } -float EvalShadow_CascadedDepth_Dither(HDShadowContext shadowContext, Texture2D tex, SamplerComparisonState samp, float2 positionSS, float3 positionWS, float3 normalWS, int index, float3 L) +float EvalShadow_CascadedDepth_Dither(inout HDShadowContext shadowContext, Texture2D tex, SamplerComparisonState samp, float2 positionSS, float3 positionWS, float3 normalWS, int index, float3 L) { int unusedSplitIndex; return EvalShadow_CascadedDepth_Dither_SplitIndex(shadowContext, tex, samp, positionSS, positionWS, normalWS, index, L, unusedSplitIndex); diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowContext.hlsl b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowContext.hlsl index 09ac6f1f620..dcf64f66a9c 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowContext.hlsl +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowContext.hlsl @@ -12,6 +12,10 @@ struct HDShadowContext { StructuredBuffer shadowDatas; HDDirectionalShadowData directionalShadowData; +#ifdef SHADOWS_SHADOWMASK + int shadowSplitIndex; + float fade; +#endif }; // HD shadow sampling bindings @@ -35,6 +39,10 @@ HDShadowContext InitShadowContext() sc.shadowDatas = _HDShadowDatas; sc.directionalShadowData = _HDDirectionalShadowData[0]; +#ifdef SHADOWS_SHADOWMASK + sc.shadowSplitIndex = -1; + sc.fade = 0.0; +#endif return sc; } diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowSettings.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowSettings.cs index a2d552878be..6b3f25aab14 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowSettings.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowSettings.cs @@ -8,7 +8,7 @@ namespace UnityEngine.Rendering.HighDefinition [Serializable, VolumeComponentMenu("Shadowing/Shadows")] [SupportedOnRenderPipeline(typeof(HDRenderPipelineAsset))] [HDRPHelpURL("Override-Shadows")] - public class HDShadowSettings : VolumeComponent + public class HDShadowSettings : VolumeComponent, ISerializationCallbackReceiver { float[] m_CascadeShadowSplits = new float[3]; float[] m_CascadeShadowBorders = new float[4]; @@ -27,6 +27,25 @@ public float[] cascadeShadowSplits } } + internal float InterCascadeToSqRangeBorder(float interCascadeBorder, float prevCascadeRelRange, float cascadeRelRange) + { + // Compute the border relative to the cascade range from the inter-cascade range + float rangeBorder = cascadeRelRange >= 0.0f + ? (cascadeRelRange - prevCascadeRelRange) * interCascadeBorder / cascadeRelRange + : 0.0f; + + // Range will be applied to squared distance, which makes the effective range at b = 1-sqrt(1-b'), so we need to output b'=1-(1-b)^2 + return 1.0f - (1.0f - rangeBorder) * (1.0f - rangeBorder); + } + internal float SqRangeBorderToInterCascade(float sqRangeBorder, float prevCascadeRelRange, float cascadeRelRange) + { + // Inverse of InterCascadeToSqRangeBorder + float interCascadeRange = cascadeRelRange - prevCascadeRelRange; + return interCascadeRange > 0.0f + ? Mathf.Clamp01((1.0f - Mathf.Sqrt(1.0f - sqRangeBorder)) * cascadeRelRange / interCascadeRange) + : 0.0f; + } + /// /// Size of the border between each shadow cascades for directional lights. /// @@ -34,10 +53,11 @@ public float[] cascadeShadowBorders { get { - m_CascadeShadowBorders[0] = cascadeShadowBorder0.value; - m_CascadeShadowBorders[1] = cascadeShadowBorder1.value; - m_CascadeShadowBorders[2] = cascadeShadowBorder2.value; - m_CascadeShadowBorders[3] = cascadeShadowBorder3.value; + var splitCount = cascadeShadowSplitCount.value; + m_CascadeShadowBorders[0] = InterCascadeToSqRangeBorder(cascadeShadowBorder0.value, 0.0f, splitCount > 1 ? cascadeShadowSplit0.value : 1.0f); + m_CascadeShadowBorders[1] = InterCascadeToSqRangeBorder(cascadeShadowBorder1.value, cascadeShadowSplit0.value, splitCount > 2 ? cascadeShadowSplit1.value : 1.0f); + m_CascadeShadowBorders[2] = InterCascadeToSqRangeBorder(cascadeShadowBorder2.value, cascadeShadowSplit1.value, splitCount > 3 ? cascadeShadowSplit2.value : 1.0f); + m_CascadeShadowBorders[3] = InterCascadeToSqRangeBorder(cascadeShadowBorder3.value, cascadeShadowSplit2.value, 1.0f); // For now we don't use shadow cascade borders but we still want to have the last split fading out. if (!HDRenderPipeline.s_UseCascadeBorders) @@ -48,6 +68,31 @@ public float[] cascadeShadowBorders } } + [SerializeField] bool interCascadeBorders = false; + /// OnBeforeSerialize. + public void OnBeforeSerialize() + { + // Borders newly serialized are defined against inter-cascade range (as the UI displays) + // Previously serialized borders were sent directly as shader input where they are considered against the full squared range + interCascadeBorders = true; + } + + /// OnAfterDeserialize. + public void OnAfterDeserialize() + { + if (!interCascadeBorders) + { + // Previously serialized borders were sent directly as shader input where they are considered against the full squared range + // This converts those ranges back to inter-cascade ranges (as the UI displays) so now both UI and shader output match + // Note that if a previously defined border would go out of the inter-cascade range, it will now be clamped to it + var splitCount = cascadeShadowSplitCount.value; + cascadeShadowBorder0.value = SqRangeBorderToInterCascade(cascadeShadowBorder0.value, 0.0f, splitCount > 1 ? cascadeShadowSplit0.value : 1.0f); + cascadeShadowBorder1.value = SqRangeBorderToInterCascade(cascadeShadowBorder1.value, cascadeShadowSplit0.value, splitCount > 2 ? cascadeShadowSplit1.value : 1.0f); + cascadeShadowBorder2.value = SqRangeBorderToInterCascade(cascadeShadowBorder2.value, cascadeShadowSplit1.value, splitCount > 3 ? cascadeShadowSplit2.value : 1.0f); + cascadeShadowBorder3.value = SqRangeBorderToInterCascade(cascadeShadowBorder3.value, cascadeShadowSplit2.value, 1.0f); + } + } + /// Sets the maximum distance HDRP renders shadows for all Light types. [Tooltip("Sets the maximum distance HDRP renders shadows for all Light types.")] public NoInterpMinFloatParameter maxShadowDistance = new NoInterpMinFloatParameter(500.0f, 0.0f); diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassInjectionPoint.cs.hlsl b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassInjectionPoint.cs.hlsl index 928b798271e..36efe130803 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassInjectionPoint.cs.hlsl +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassInjectionPoint.cs.hlsl @@ -9,6 +9,7 @@ // #define CUSTOMPASSINJECTIONPOINT_BEFORE_RENDERING (0) #define CUSTOMPASSINJECTIONPOINT_AFTER_OPAQUE_DEPTH_AND_NORMAL (5) +#define CUSTOMPASSINJECTIONPOINT_AFTER_OPAQUE_AND_SKY (6) #define CUSTOMPASSINJECTIONPOINT_BEFORE_PRE_REFRACTION (4) #define CUSTOMPASSINJECTIONPOINT_BEFORE_TRANSPARENT (1) #define CUSTOMPASSINJECTIONPOINT_BEFORE_POST_PROCESS (2) diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/EditorShaderVariables.hlsl b/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/EditorShaderVariables.hlsl index 85ada21b011..d09cc1c2259 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/EditorShaderVariables.hlsl +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/EditorShaderVariables.hlsl @@ -1,10 +1,20 @@ -#ifndef EDITOR_SHADER_VARAIBLES -#define E DITOR_SHADER_VARAIBLES +#ifndef EDITOR_SHADER_VARIABLES +#define EDITOR_SHADER_VARIABLES // ================================ // PER FRAME CONSTANTS // ================================ #if defined(USING_STEREO_MATRICES) + float4x4 unity_StereoMatrixP[2]; + float4x4 unity_StereoMatrixV[2]; + float4x4 unity_StereoMatrixInvV[2]; + float4x4 unity_StereoMatrixVP[2]; + + float4x4 unity_StereoCameraProjection[2]; + float4x4 unity_StereoCameraInvProjection[2]; + float4x4 unity_StereoWorldToCamera[2]; + float4x4 unity_StereoCameraToWorld[2]; + #define glstate_matrix_projection unity_StereoMatrixP[unity_StereoEyeIndex] #define unity_MatrixV unity_StereoMatrixV[unity_StereoEyeIndex] #define unity_MatrixInvV unity_StereoMatrixInvV[unity_StereoEyeIndex] @@ -15,13 +25,11 @@ #define unity_WorldToCamera unity_StereoWorldToCamera[unity_StereoEyeIndex] #define unity_CameraToWorld unity_StereoCameraToWorld[unity_StereoEyeIndex] #else - #if !defined(USING_STEREO_MATRICES) - float4x4 glstate_matrix_projection; - float4x4 unity_MatrixV; - float4x4 unity_MatrixInvV; - float4x4 unity_MatrixVP; - float4 unity_StereoScaleOffset; - #endif + float4x4 glstate_matrix_projection; + float4x4 unity_MatrixV; + float4x4 unity_MatrixInvV; + float4x4 unity_MatrixVP; + float4 unity_StereoScaleOffset; #endif -#endif // EDITOR_SHADER_VARAIBLES +#endif // EDITOR_SHADER_VARIABLES diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphHeader.hlsl b/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphHeader.hlsl new file mode 100644 index 00000000000..fb8b0ddc017 --- /dev/null +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphHeader.hlsl @@ -0,0 +1,8 @@ +#ifndef UNITY_HEADER_HD_INCLUDED +#define UNITY_HEADER_HD_INCLUDED + +// Always include Shader Graph version +// Always include last to avoid double macros +#include "Packages/com.unity.shadergraph/ShaderGraphLibrary/Functions.hlsl" + +#endif // UNITY_HEADER_HD_INCLUDED \ No newline at end of file diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphHeader.hlsl.meta b/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphHeader.hlsl.meta new file mode 100644 index 00000000000..5cfcb6cf7ba --- /dev/null +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphHeader.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: cc474706ef4b7e74188e960b8a1db23f +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs index 6dd39df58df..68a54d01dc5 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs @@ -914,7 +914,7 @@ bool AcquireSkyRenderingContext(SkyUpdateContext updateContext, int newHash, str { SphericalHarmonicsL2 cachedAmbientProbe = new SphericalHarmonicsL2(); // Release the old context if needed. - if (IsCachedContextValid(updateContext)) + if (CachedContextNeedsCleanup(updateContext)) { ref var cachedContext = ref m_CachedSkyContexts[updateContext.cachedSkyRenderingContextId]; if (newHash != cachedContext.hash || updateContext.skySettings.GetSkyRendererType() != cachedContext.type) @@ -998,6 +998,16 @@ bool IsCachedContextValid(SkyUpdateContext skyContext) return id != -1 && (skyContext.skySettings.GetSkyRendererType() == m_CachedSkyContexts[id].type) && (m_CachedSkyContexts[id].hash != 0); } + bool CachedContextNeedsCleanup(SkyUpdateContext skyContext) + { + if (skyContext.skySettings == null) // Sky set to None + return false; + + int id = skyContext.cachedSkyRenderingContextId; + // When the renderer changes, the cached context is no longer valid but needs to be cleaned up to allow for proper refCounting. + return id != -1 && (m_CachedSkyContexts[id].hash != 0); + } + int ComputeSkyHash(HDCamera camera, SkyUpdateContext skyContext, Light sunLight, SkyAmbientMode ambientMode, bool staticSky = false) { int sunHash = 0; diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Utilities/ProbeCameraCache.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Utilities/ProbeCameraCache.cs index 101eb0f8686..36825f1bcbb 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Utilities/ProbeCameraCache.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Utilities/ProbeCameraCache.cs @@ -89,7 +89,10 @@ public void Clear() } m_Cache.Clear(); foreach(var camera in m_CameraPool) - CoreUtils.Destroy(camera.gameObject); + { + if (camera != null) + CoreUtils.Destroy(camera.gameObject); + } m_CameraPool.Clear(); } diff --git a/Packages/com.unity.render-pipelines.high-definition/package.json b/Packages/com.unity.render-pipelines.high-definition/package.json index 0a3d870f278..bdeb4242028 100644 --- a/Packages/com.unity.render-pipelines.high-definition/package.json +++ b/Packages/com.unity.render-pipelines.high-definition/package.json @@ -1,7 +1,7 @@ { "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": "15.0.6", + "version": "15.0.7", "unity": "2023.1", "displayName": "High Definition RP", "dependencies": { @@ -12,10 +12,10 @@ "com.unity.modules.animation": "1.0.0", "com.unity.modules.imageconversion": "1.0.0", "com.unity.modules.terrain": "1.0.0", - "com.unity.render-pipelines.core": "15.0.6", - "com.unity.shadergraph": "15.0.6", - "com.unity.visualeffectgraph": "15.0.6", - "com.unity.render-pipelines.high-definition-config": "15.0.6" + "com.unity.render-pipelines.core": "15.0.7", + "com.unity.shadergraph": "15.0.7", + "com.unity.visualeffectgraph": "15.0.7", + "com.unity.render-pipelines.high-definition-config": "15.0.7" }, "keywords": [ "graphics", diff --git a/Packages/com.unity.render-pipelines.universal/CHANGELOG.md b/Packages/com.unity.render-pipelines.universal/CHANGELOG.md index 84308836fb9..410128d8ee8 100644 --- a/Packages/com.unity.render-pipelines.universal/CHANGELOG.md +++ b/Packages/com.unity.render-pipelines.universal/CHANGELOG.md @@ -9,6 +9,49 @@ 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. +## [15.0.6] - 2023-09-27 + +This version is compatible with Unity 2023.1.16f1. + +### Fixed +- Updated the documentation to mention that the Screen Space decal technique does not support blending of normals when using the Deferred rendering path with Accurate G-Buffer Normals enabled. The Automatic decal technique now prefers the D-Buffer technique if Accurate G-Buffer Normals are enabled. +- Fixed an issue where switching Volume Update modes between Every Frame and Via Scripting gave an error. +- Fixed an issue where changing RenderSettings just before camera rendering would not always take effect. +- 2D - Remove serialization and cache vertices and indices for sprite lights causing bloat in prefabs. +- Fixed TAA resource leak on entering/exiting the playmode. +- Fixed ShaderGraph preview window not showing anything when using DepthNormals pass. +- Fixed incorrect MSAA sample count when using Deferred renderer but rendering to a target texture. +- Fixed an issue where assets were incorrectly being saved when making builds. +- Changed the ScreenSpace Decals sorting criteria to None to fix flickering issues. +- Fixed redundant blit is used due to postFX, although it is disabled in rendererData. +- Fixed Screen space Overlay UI rendered at the wrong size for scaling mode "Constant Pixel Size" or "Constant Physical Size", when HDR output is active. +- Fixed Native RenderPass errors when using RendererFeature which is executed in between GBuffer and Deferred Lighting passes. +- Added missing G-buffer normal decoding for the "URP Sample Buffer" node in Fullscreen shadergraphs when using "Accurate G-buffer normals" in the deferred renderer (not background pixels will not match). +- 2D - Fix additional draw call when Foremost Sorting Layer is enabled during unlit. +- Fixed an issue where rendering layers keywords were not enabled correctly when using Decals & SSAO in Deferred. +- Fixed an issue where incorrect Shader Keyword Prefiltering was used with SSAO when AfterOpaque was used. +- Fixed Native RenderPass errors when using RenderingLayers. +- Fixed exception for missing _Color Shader Property. +- Fixed data-driven lens-flare missing occlusion. +- Fixed an issue where Shader ID's weren't reset properly in the DepthNormals pass. +- Fixed shader stripping when using APV. +- Fixed an issue where additional lights were not rendering correctly when using a mix of shadow settings in deferred. +- Fixed an issue where IndexOutOfRangeException was thrown when creating a stacked camera from script. +- Fixed an issue where NullReferenceException was thrown when camera prefab referenced a camera outside the prefab in the camera stack. +- Fixed color and depth mismatch when scaling is on. +- Fixed an issue with Screen Space Decals where dark artefacts appeared in the editor. +- Fixed per-vertex light layers. +- Fixed TAA Very High option flicker. +- Fixed an issue where Rendering Layers didn't work properly when opening a project. +- Fixed an issue causing 'implicit truncation of vector type' warning when using ShaderGraph shaders in the Forward+ Rendering Path. +- Added Shader Keywords for Soft Shadow quality levels and disable per-light quality level on untethered XR platforms. +- Fixed an issue where it wasn't possible to add a Renderer Feature on a renderer if another feature had a missing/broken script. +- Added GBuffer (fill) passes to ComplexLit and Unlit shader to prevent GBuffer data holes. +- Fixed an issue where reflection probes were not updating correctly when using Forward+. +- Fixed visible outline when composited ShadowCaster2Ds with transparency overlap. +- Fixed an issue where selecting a stacked camera caused the editor to freeze and sometimes crash. +- Fix using RenderTextureSubElement.Stencil in URP not binding properly + ## [15.0.5] - 2023-05-23 This version is compatible with Unity 2023.1.0b19. diff --git a/Packages/com.unity.render-pipelines.universal/Editor/ShaderGUI/BaseShaderGUI.cs b/Packages/com.unity.render-pipelines.universal/Editor/ShaderGUI/BaseShaderGUI.cs index a687c8ccc65..decb3416277 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/ShaderGUI/BaseShaderGUI.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/ShaderGUI/BaseShaderGUI.cs @@ -931,17 +931,12 @@ internal static void SetupMaterialBlendModeInternal(Material material, out int a SetMaterialSrcDstBlendProperties(material, UnityEngine.Rendering.BlendMode.One, UnityEngine.Rendering.BlendMode.Zero); zwrite = true; material.DisableKeyword(ShaderKeywordStrings._ALPHAPREMULTIPLY_ON); - material.DisableKeyword(ShaderKeywordStrings._SURFACE_TYPE_TRANSPARENT); material.DisableKeyword(ShaderKeywordStrings._ALPHAMODULATE_ON); } else // SurfaceType Transparent { BlendMode blendMode = (BlendMode)material.GetFloat(Property.BlendMode); - // Clear blend keyword state. - material.DisableKeyword(ShaderKeywordStrings._ALPHAPREMULTIPLY_ON); - material.DisableKeyword(ShaderKeywordStrings._ALPHAMODULATE_ON); - var srcBlendRGB = UnityEngine.Rendering.BlendMode.One; var dstBlendRGB = UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha; var srcBlendA = UnityEngine.Rendering.BlendMode.One; @@ -987,8 +982,6 @@ internal static void SetupMaterialBlendModeInternal(Material material, out int a dstBlendRGB = UnityEngine.Rendering.BlendMode.Zero; srcBlendA = UnityEngine.Rendering.BlendMode.Zero; dstBlendA = UnityEngine.Rendering.BlendMode.One; - - material.EnableKeyword(ShaderKeywordStrings._ALPHAMODULATE_ON); break; } @@ -1001,7 +994,6 @@ internal static void SetupMaterialBlendModeInternal(Material material, out int a if (preserveSpecular) { srcBlendRGB = UnityEngine.Rendering.BlendMode.One; - material.EnableKeyword(ShaderKeywordStrings._ALPHAPREMULTIPLY_ON); } // When doing off-screen transparency accumulation, we change blend factors as described here: https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch23.html @@ -1012,10 +1004,12 @@ internal static void SetupMaterialBlendModeInternal(Material material, out int a SetMaterialSrcDstBlendProperties(material, srcBlendRGB, dstBlendRGB, // RGB srcBlendA, dstBlendA); // Alpha + CoreUtils.SetKeyword(material, ShaderKeywordStrings._ALPHAPREMULTIPLY_ON, preserveSpecular); + CoreUtils.SetKeyword(material, ShaderKeywordStrings._ALPHAMODULATE_ON, blendMode == BlendMode.Multiply); + // General Transparent Material Settings material.SetOverrideTag("RenderType", "Transparent"); zwrite = false; - material.EnableKeyword(ShaderKeywordStrings._SURFACE_TYPE_TRANSPARENT); renderQueue = (int)RenderQueue.Transparent; } diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipelineCore.cs b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipelineCore.cs index 7ffea79b8e8..83115fc7b3a 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipelineCore.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipelineCore.cs @@ -1440,19 +1440,6 @@ static RenderTextureDescriptor CreateRenderTextureDescriptor(Camera camera, floa desc.bindMS = false; desc.useDynamicScale = camera.allowDynamicResolution; - // The way RenderTextures handle MSAA fallback when an unsupported sample count of 2 is requested (falling back to numSamples = 1), differs fom the way - // the fallback is handled when setting up the Vulkan swapchain (rounding up numSamples to 4, if supported). This caused an issue on Mali GPUs which don't support - // 2x MSAA. - // The following code makes sure that on Vulkan the MSAA unsupported fallback behaviour is consistent between RenderTextures and Swapchain. - // TODO: we should review how all backends handle MSAA fallbacks and move these implementation details in engine code. - if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Vulkan) - { - // if the requested number of samples is 2, and the supported value is 1x, it means that 2x is unsupported on this GPU. - // Then we bump up the requested value to 4. - if (desc.msaaSamples == 2 && SystemInfo.GetRenderTextureSupportedMSAASampleCount(desc) == 1) - desc.msaaSamples = 4; - } - // check that the requested MSAA samples count is supported by the current platform. If it's not supported, // replace the requested desc.msaaSamples value with the actual value the engine falls back to desc.msaaSamples = SystemInfo.GetRenderTextureSupportedMSAASampleCount(desc); diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderer.cs b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderer.cs index 123b28e955f..b4e666bfe1a 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderer.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderer.cs @@ -480,13 +480,24 @@ bool IsDepthPrimingEnabled(ref CameraData cameraData) if (!CanCopyDepth(ref cameraData)) return false; + // Depth Priming causes rendering errors with WebGL on Apple Arm64 GPUs. + bool isNotWebGL = !IsWebGL(); bool depthPrimingRequested = (m_DepthPrimingRecommended && m_DepthPrimingMode == DepthPrimingMode.Auto) || m_DepthPrimingMode == DepthPrimingMode.Forced; bool isForwardRenderingMode = m_RenderingMode == RenderingMode.Forward || m_RenderingMode == RenderingMode.ForwardPlus; bool isFirstCameraToWriteDepth = cameraData.renderType == CameraRenderType.Base || cameraData.clearDepth; // Enabled Depth priming when baking Reflection Probes causes artefacts (UUM-12397) bool isNotReflectionCamera = cameraData.cameraType != CameraType.Reflection; - return depthPrimingRequested && isForwardRenderingMode && isFirstCameraToWriteDepth && isNotReflectionCamera; + return depthPrimingRequested && isForwardRenderingMode && isFirstCameraToWriteDepth && isNotReflectionCamera && isNotWebGL; + } + + bool IsWebGL() + { +#if PLATFORM_WEBGL + return IsGLESDevice(); +#else + return false; +#endif } bool IsGLESDevice() diff --git a/Packages/com.unity.render-pipelines.universal/ValidationExceptions.json b/Packages/com.unity.render-pipelines.universal/ValidationExceptions.json index 152233864f8..103043450b3 100644 --- a/Packages/com.unity.render-pipelines.universal/ValidationExceptions.json +++ b/Packages/com.unity.render-pipelines.universal/ValidationExceptions.json @@ -2,7 +2,7 @@ "Exceptions": [ { "ValidationTest": "API Updater Configuration Validation", - "PackageVersion": "15.0.6" + "PackageVersion": "15.0.7" } ] } \ No newline at end of file diff --git a/Packages/com.unity.render-pipelines.universal/package.json b/Packages/com.unity.render-pipelines.universal/package.json index 44b98fa206b..e4260add7fd 100644 --- a/Packages/com.unity.render-pipelines.universal/package.json +++ b/Packages/com.unity.render-pipelines.universal/package.json @@ -1,14 +1,14 @@ { "name": "com.unity.render-pipelines.universal", "description": "The Universal Render Pipeline (URP) is a prebuilt Scriptable Render Pipeline, made by Unity. URP provides artist-friendly workflows that let you quickly and easily create optimized graphics across a range of platforms, from mobile to high-end consoles and PCs.", - "version": "15.0.6", + "version": "15.0.7", "unity": "2023.1", "displayName": "Universal RP", "dependencies": { "com.unity.mathematics": "1.2.1", "com.unity.burst": "1.8.4", - "com.unity.render-pipelines.core": "15.0.6", - "com.unity.shadergraph": "15.0.6" + "com.unity.render-pipelines.core": "15.0.7", + "com.unity.shadergraph": "15.0.7" }, "keywords": [ "graphics", diff --git a/Packages/com.unity.shadergraph/CHANGELOG.md b/Packages/com.unity.shadergraph/CHANGELOG.md index ec153d27728..c6fcad60d2f 100644 --- a/Packages/com.unity.shadergraph/CHANGELOG.md +++ b/Packages/com.unity.shadergraph/CHANGELOG.md @@ -9,6 +9,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. +## [15.0.6] - 2023-09-27 + +This version is compatible with Unity 2023.1.16f1. + +### Fixed +- Fixed Texture Size node causing compilation error in the Fullscreen ShaderGraph target. + ## [15.0.5] - 2023-05-23 This version is compatible with Unity 2023.1.0b19. diff --git a/Packages/com.unity.shadergraph/Editor/Generation/Targets/CustomRenderTexture/CustomTexture.hlsl b/Packages/com.unity.shadergraph/Editor/Generation/Targets/CustomRenderTexture/CustomTexture.hlsl index adf3685a591..67c5358eced 100644 --- a/Packages/com.unity.shadergraph/Editor/Generation/Targets/CustomRenderTexture/CustomTexture.hlsl +++ b/Packages/com.unity.shadergraph/Editor/Generation/Targets/CustomRenderTexture/CustomTexture.hlsl @@ -45,6 +45,16 @@ float4 _Time, _SinTime, _CosTime, unity_DeltaTime; // PER FRAME CONSTANTS // ================================ #if defined(USING_STEREO_MATRICES) + float4x4 unity_StereoMatrixP[2]; + float4x4 unity_StereoMatrixV[2]; + float4x4 unity_StereoMatrixInvV[2]; + float4x4 unity_StereoMatrixVP[2]; + + float4x4 unity_StereoCameraProjection[2]; + float4x4 unity_StereoCameraInvProjection[2]; + float4x4 unity_StereoWorldToCamera[2]; + float4x4 unity_StereoCameraToWorld[2]; + #define glstate_matrix_projection unity_StereoMatrixP[unity_StereoEyeIndex] #define unity_MatrixV unity_StereoMatrixV[unity_StereoEyeIndex] #define unity_MatrixInvV unity_StereoMatrixInvV[unity_StereoEyeIndex] @@ -55,14 +65,12 @@ float4 _Time, _SinTime, _CosTime, unity_DeltaTime; #define unity_WorldToCamera unity_StereoWorldToCamera[unity_StereoEyeIndex] #define unity_CameraToWorld unity_StereoCameraToWorld[unity_StereoEyeIndex] #else - #if !defined(USING_STEREO_MATRICES) - float4x4 glstate_matrix_projection; - float4x4 unity_MatrixV; - float4x4 unity_MatrixInvV; - float4x4 unity_MatrixVP; - float4x4 unity_ObjectToWorld; - float4 unity_StereoScaleOffset; - #endif + float4x4 glstate_matrix_projection; + float4x4 unity_MatrixV; + float4x4 unity_MatrixInvV; + float4x4 unity_MatrixVP; + float4x4 unity_ObjectToWorld; + float4 unity_StereoScaleOffset; #endif // Internal diff --git a/Packages/com.unity.shadergraph/package.json b/Packages/com.unity.shadergraph/package.json index 1f85c420fbc..6cd3af64fe5 100644 --- a/Packages/com.unity.shadergraph/package.json +++ b/Packages/com.unity.shadergraph/package.json @@ -1,11 +1,11 @@ { "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": "15.0.6", + "version": "15.0.7", "unity": "2023.1", "displayName": "Shader Graph", "dependencies": { - "com.unity.render-pipelines.core": "15.0.6", + "com.unity.render-pipelines.core": "15.0.7", "com.unity.searcher": "4.9.2" }, "samples": [ diff --git a/Packages/com.unity.visualeffectgraph/CHANGELOG.md b/Packages/com.unity.visualeffectgraph/CHANGELOG.md index 6dd69254c47..21ea585503c 100644 --- a/Packages/com.unity.visualeffectgraph/CHANGELOG.md +++ b/Packages/com.unity.visualeffectgraph/CHANGELOG.md @@ -9,6 +9,39 @@ 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. +## [15.0.6] - 2023-09-27 + +This version is compatible with Unity 2023.1.16f1. + +### Changed +- VFX systems receiving GPU events can now go into sleep state. +- Allows texture types to be used in branch operators. + +### Fixed +- Fixed panning and zooming a VFX Graph was synchronized between all opened tabs. Also when multiple VFX Graph tabs are opened they are now properly restored after Unity is restarted. +- Fixed strips tangents and buffer type with Shader Graph. +- Fixed an editor only memory leak with VFX Graph objects. +- Fixed data serialization that could lead to corrupted state. +- Fixed VFX assets being considered modified after creation. +- Fixed a potential crash with particle strips. +- Removed an error message when a point cache asset is missing, added an error feedback instead. +- Fixed crash when loading a subscene with VFX in DOTS. +- Fixed OutputUpdate warnings about spaces after end of line. +- Fixed potential infinite loop when opening VFX Graph due to space issue. +- Fixed crash when changing to custom batch capacity in computers with large GPU memory. +- Initialize VFX material indices to make all materials valid if used on Awake. +- Fixed a compilation error when using Cube outputs with a texture shared with another context. +- Blocks and operators sampling Depth or Color now work with Dynamic Resolution Scaling. +- Fixed console errors when deleting VFX asset in some configuration. +- Fixed HDRP Decal Output when system is in world space. +- Fixed VFX camera command culling failling when all effects are out of frustum. +- Fixed flickering and glitches when using Volumetric Fog Output on Metal devices. +- Fixed undefined behavior of SpawnerSetAttribute when an expression is connected to activation slot. +- Picking Overlay when the rotation is applied on VisualEffect component. +- Take search window mode user's preference into account for object fields in VFX Graph (classic / advanced) +- Fixed an error in the console when clicking on the [+] button in the blackboard in the "No Asset" window +- Prevent unexpected border highlight after clicking on VFX toolbar button + ## [15.0.5] - 2023-05-23 This version is compatible with Unity 2023.1.0b19. diff --git a/Packages/com.unity.visualeffectgraph/Documentation~/Context-OutputParticleHDRPLitDecal.md b/Packages/com.unity.visualeffectgraph/Documentation~/Context-OutputParticleHDRPLitDecal.md index 396b682c63b..575a8222001 100644 --- a/Packages/com.unity.visualeffectgraph/Documentation~/Context-OutputParticleHDRPLitDecal.md +++ b/Packages/com.unity.visualeffectgraph/Documentation~/Context-OutputParticleHDRPLitDecal.md @@ -14,6 +14,8 @@ The **Output Particle HDRP Lit Decal** Context can affect the following properti - Smoothness - Normal +The particles project their properties along their positive Z-axis. + Below is a list of settings and properties specific to the Output Particle HDRP Lit Decal Context. For information about the generic output settings this Context shares with all other Contexts, see [Output Lit Settings and Properties](Context-OutputLitSettings.md). # Context Settings diff --git a/Packages/com.unity.visualeffectgraph/Editor/Compiler/VFXCodeGenerator.cs b/Packages/com.unity.visualeffectgraph/Editor/Compiler/VFXCodeGenerator.cs index d01b497ad3b..bcf06e024c0 100644 --- a/Packages/com.unity.visualeffectgraph/Editor/Compiler/VFXCodeGenerator.cs +++ b/Packages/com.unity.visualeffectgraph/Editor/Compiler/VFXCodeGenerator.cs @@ -186,8 +186,8 @@ static internal VFXShaderWriter GenerateSetInstancingIndices(VFXContext context) var r = new VFXShaderWriter(); // Hardcoded, duplicated from VFXParticleCommon.template - r.WriteLine("uint instanceIndex, instanceActiveIndex;"); - r.WriteLine("index = VFXInitInstancing(index, instanceIndex, instanceActiveIndex);"); + r.WriteLine("uint instanceIndex, instanceActiveIndex, instanceCurrentIndex;"); + r.WriteLine("index = VFXInitInstancing(index, instanceIndex, instanceActiveIndex, instanceCurrentIndex);"); return r; } @@ -942,19 +942,24 @@ internal static IEnumerable GetInstancingAdditionalDefines(VFXContext co yield return "#define VFX_INSTANCING_FIXED_SIZE " + fixedSize; yield return "#pragma multi_compile_instancing"; } + else if (context is VFXBasicInitialize) + { + yield return "#define VFX_INSTANCING_VARIABLE_SIZE 1"; + } else { - if (context is VFXBasicInitialize) + if (particleData.IsAttributeStored(VFXAttribute.Alive)) { - yield return "#define VFX_INSTANCING_VARIABLE_SIZE 1"; + yield return "#define VFX_INSTANCING_FIXED_SIZE " + Math.Max(particleData.alignedCapacity, nbThreadsPerGroup); } else { - yield return "#define VFX_INSTANCING_FIXED_SIZE " + Math.Max(particleData.alignedCapacity, nbThreadsPerGroup); + yield return "#define VFX_INSTANCING_VARIABLE_SIZE 1"; } } bool hasActiveIndirection = context.contextType == VFXContextType.Filter || context.contextType == VFXContextType.Output; + hasActiveIndirection = true; // TODO: how can we know if there are variable expressions with textures/buffers? if (hasActiveIndirection) yield return "#define VFX_INSTANCING_ACTIVE_INDIRECTION 1"; diff --git a/Packages/com.unity.visualeffectgraph/Editor/Compiler/VFXGraphCompiledData.cs b/Packages/com.unity.visualeffectgraph/Editor/Compiler/VFXGraphCompiledData.cs index 421ea991aad..2972e265204 100644 --- a/Packages/com.unity.visualeffectgraph/Editor/Compiler/VFXGraphCompiledData.cs +++ b/Packages/com.unity.visualeffectgraph/Editor/Compiler/VFXGraphCompiledData.cs @@ -1410,16 +1410,6 @@ public VFXInstancingDisabledReason ValidateInstancing(IEnumerable co } } - foreach (var exposed in expressionSheet.exposed) - { - VFXExpression expression = m_ExpressionGraph.FlattenedExpressions[exposed.mapping.index]; - if (expression is VFXObjectValue) - { - reason |= VFXInstancingDisabledReason.ExposedObject; - break; - } - } - return reason; } diff --git a/Packages/com.unity.visualeffectgraph/Editor/Compiler/VFXShaderWriter.cs b/Packages/com.unity.visualeffectgraph/Editor/Compiler/VFXShaderWriter.cs index 76c3fd6b850..d8ba4017c9c 100644 --- a/Packages/com.unity.visualeffectgraph/Editor/Compiler/VFXShaderWriter.cs +++ b/Packages/com.unity.visualeffectgraph/Editor/Compiler/VFXShaderWriter.cs @@ -340,8 +340,8 @@ public void WriteTexture(VFXUniformMapper mapper, IEnumerable skipNames { var names = mapper.GetNames(texture); // TODO At the moment issue all names sharing the same texture as different texture slots. This is not optimized as it required more texture binding than necessary - // TODO : Investigate why we need Distinct in the first place - foreach (var name in names.Distinct()) + Debug.Assert(names.Distinct().Count() == names.Count); + foreach (var name in names) { if (skipNames != null && skipNames.Contains(name)) continue; diff --git a/Packages/com.unity.visualeffectgraph/Editor/Compiler/VFXUniformMapper.cs b/Packages/com.unity.visualeffectgraph/Editor/Compiler/VFXUniformMapper.cs index 8bc978a07d1..3625beb3092 100644 --- a/Packages/com.unity.visualeffectgraph/Editor/Compiler/VFXUniformMapper.cs +++ b/Packages/com.unity.visualeffectgraph/Editor/Compiler/VFXUniformMapper.cs @@ -70,9 +70,9 @@ private void CollectAndAddUniforms(VFXExpression exp, IEnumerable(); var uniformMappings = new List(); var additionalParameters = new List(); + var instanceSplitDescs = new List(); - List<(VFXContext context, VFXTask task, VFXContextCompiledData contextCompiledData, long sortKey)> sortedTaskList = new(); + AddInstanceSplitDesc(instanceSplitDescs, new List()); + + List<(VFXContext context, VFXTask task, VFXContextCompiledData contextCompiledData, long sortKey)> sortedTaskList = new(); for (int i = 0; i < m_Contexts.Count; ++i) { @@ -1189,6 +1192,7 @@ int GetBufferIndex(VFXTask task, string baseName) foreach (var (context, task, contextCompiledData, contextIndex) in sortedTaskList) { var temporaryBufferMappings = new List(); + var instanceSplitDescValues = new List(); bufferMappings.Clear(); additionalParameters.Clear(); @@ -1274,7 +1278,9 @@ int GetBufferIndex(VFXTask task, string baseName) if (hasInstancing) { - if (instancesPrefixSumBufferIndex != -1 && (context.contextType == VFXContextType.Init || context.contextType == VFXContextType.Output)) + bool needsInstancePrefixSum = context.contextType == VFXContextType.Init; + needsInstancePrefixSum |= !hasKill && task.doesGenerateShader && task.shaderType == VFXTaskShaderType.ComputeShader; + if (instancesPrefixSumBufferIndex != -1 && needsInstancePrefixSum) bufferMappings.Add(new VFXMapping("instancingPrefixSum", instancesPrefixSumBufferIndex)); bool mapIndirectBuffers = contextCompiledData.tasks.Any(t => (t.type & (VFXTaskType.Update | VFXTaskType.Initialize)) != 0); @@ -1364,12 +1370,25 @@ int GetBufferIndex(VFXTask task, string baseName) uniformMappings.Clear(); foreach (var buffer in contextData.uniformMapper.buffers) - uniformMappings.Add(new VFXMapping(contextData.uniformMapper.GetName(buffer), expressionGraph.GetFlattenedIndex(buffer))); + { + int index = expressionGraph.GetFlattenedIndex(buffer); + if (!buffer.IsAny(VFXExpression.Flags.Constant | VFXExpression.Flags.Foldable)) + { + instanceSplitDescValues.Add((uint)index); + } + var name = contextData.uniformMapper.GetName(buffer); + uniformMappings.Add(new VFXMapping(name, index)); + } foreach (var texture in contextData.uniformMapper.textures) { + int index = expressionGraph.GetFlattenedIndex(texture); + if (!texture.IsAny(VFXExpression.Flags.Constant | VFXExpression.Flags.Foldable)) + { + instanceSplitDescValues.Add((uint)index); + } // TODO At the moment issue all names sharing the same texture as different texture slots. This is not optimized as it required more texture binding than necessary foreach (var name in contextData.uniformMapper.GetNames(texture)) - uniformMappings.Add(new VFXMapping(name, expressionGraph.GetFlattenedIndex(texture))); + uniformMappings.Add(new VFXMapping(name, index)); } // Retrieve all cpu mappings at context level (-1) @@ -1390,8 +1409,9 @@ int GetBufferIndex(VFXTask task, string baseName) taskDesc.buffers = bufferMappings.ToArray(); taskDesc.temporaryBuffers = temporaryBufferMappings.ToArray(); - taskDesc.values = uniformMappings.ToArray(); + taskDesc.values = uniformMappings.OrderBy(mapping => mapping.index).ToArray(); taskDesc.parameters = cpuMappings.Concat(contextData.parameters).Concat(additionalParameters).ToArray(); + taskDesc.instanceSplitIndex = AddInstanceSplitDesc(instanceSplitDescs, instanceSplitDescValues); taskDesc.shaderSourceIndex = compiledData.taskToCompiledData[task].indexInShaderSource; taskDesc.model = context; @@ -1443,7 +1463,6 @@ int GetBufferIndex(VFXTask task, string baseName) } } - string nativeName = string.Empty; if (systemNames != null) nativeName = systemNames.GetUniqueSystemName(this); @@ -1458,6 +1477,7 @@ int GetBufferIndex(VFXTask task, string baseName) name = nativeName, buffers = systemBufferMappings.ToArray(), values = systemValueMappings.ToArray(), + instanceSplitDescs = instanceSplitDescs.ToArray(), type = VFXSystemType.Particle, layer = m_Layer }); @@ -1515,6 +1535,30 @@ public override void OnEnable() } } + private static uint AddInstanceSplitDesc(List instanceSplitDescs, List instanceSplitDescValues) + { + int index = -1; + + instanceSplitDescValues.Sort(); + + for (int i = 0; i < instanceSplitDescs.Count; ++i) + { + if (instanceSplitDescValues.SequenceEqual(instanceSplitDescs[i].values)) + { + index = i; + break; + } + } + if (index < 0) + { + index = instanceSplitDescs.Count; + var newEntry = new VFXInstanceSplitDesc(); + newEntry.values = instanceSplitDescValues.ToArray(); + instanceSplitDescs.Add(newEntry); + } + return (uint)index; + } + public override void Sanitize(int version) { if (version < 8) diff --git a/Packages/com.unity.visualeffectgraph/Editor/GraphView/Blackboard/VFXBlackboard.cs b/Packages/com.unity.visualeffectgraph/Editor/GraphView/Blackboard/VFXBlackboard.cs index fba0b137b8a..a4ab79aa5fa 100644 --- a/Packages/com.unity.visualeffectgraph/Editor/GraphView/Blackboard/VFXBlackboard.cs +++ b/Packages/com.unity.visualeffectgraph/Editor/GraphView/Blackboard/VFXBlackboard.cs @@ -91,6 +91,7 @@ public VFXBlackboard(VFXView view) m_AddButton = this.Q