diff --git a/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/AssemblyInfo.cs b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/AssemblyInfo.cs index 6d18d055f26..a37f6f47f9c 100644 --- a/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/AssemblyInfo.cs +++ b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/AssemblyInfo.cs @@ -1,6 +1,10 @@ using System.Runtime.CompilerServices; +// HDRP [assembly: InternalsVisibleTo("Unity.RenderPipelines.HighDefinition.Editor")] +[assembly: InternalsVisibleTo("Unity.RenderPipelines.HighDefinition.Editor.Tests")] + +// URP [assembly: InternalsVisibleTo("Unity.RenderPipelines.Universal.Editor")] [assembly: InternalsVisibleTo("Unity.RenderPipelines.Universal.Editor.Tests")] diff --git a/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/AssetCallbacks/AssetCreationUtil.cs b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/AssetCallbacks/AssetCreationUtil.cs index 618d21e7b9d..70bbf164dc4 100644 --- a/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/AssetCallbacks/AssetCreationUtil.cs +++ b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/AssetCallbacks/AssetCreationUtil.cs @@ -92,7 +92,7 @@ static void CreateAsset(string name, Action callback = null, string exte assetCreationCallback.extension = extension; var icon = AssetPreview.GetMiniTypeThumbnail(type); - ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, assetCreationCallback, name, icon, null, false); + ProjectWindowUtil.StartNameEditingIfProjectWindowExists(EntityId.None, assetCreationCallback, name, icon, null, false); } class AssetCreationCallback : ProjectWindowCallback.AssetCreationEndAction diff --git a/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/AssetsConverter.cs b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/AssetsConverter.cs index f420824415a..94c6c2105cf 100644 --- a/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/AssetsConverter.cs +++ b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/AssetsConverter.cs @@ -30,7 +30,10 @@ void OnSearchFinish() contextSearchQueriesAndIds, (item, description) => { - var assetItem = new RenderPipelineConverterAssetItem(item.id); + var assetItem = new RenderPipelineConverterAssetItem(item.id) + { + info = description + }; assets.Add(assetItem); }, OnSearchFinish diff --git a/Packages/com.unity.render-pipelines.universal/Editor/Tools/Converters/ReadonlyMaterialConverter.meta b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter.meta similarity index 77% rename from Packages/com.unity.render-pipelines.universal/Editor/Tools/Converters/ReadonlyMaterialConverter.meta rename to Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter.meta index 9b03df62702..0dbae95fcf6 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/Tools/Converters/ReadonlyMaterialConverter.meta +++ b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d0cbb8c1758af77469e1b602c122282c +guid: aadf028af331ea641b01fdf6c4089315 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Packages/com.unity.render-pipelines.universal/Editor/Tools/Converters/ReadonlyMaterialConverter/ReadonlyMaterialConverter.MaterialReferenceBuilder.cs b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter/ReadonlyMaterialConverter.MaterialReferenceBuilder.cs similarity index 99% rename from Packages/com.unity.render-pipelines.universal/Editor/Tools/Converters/ReadonlyMaterialConverter/ReadonlyMaterialConverter.MaterialReferenceBuilder.cs rename to Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter/ReadonlyMaterialConverter.MaterialReferenceBuilder.cs index a256d3371ed..5026ecc9a56 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/Tools/Converters/ReadonlyMaterialConverter/ReadonlyMaterialConverter.MaterialReferenceBuilder.cs +++ b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter/ReadonlyMaterialConverter.MaterialReferenceBuilder.cs @@ -3,7 +3,7 @@ using System; using UnityEngine; -namespace UnityEditor.Rendering.Universal +namespace UnityEditor.Rendering.Converter { internal class MaterialReferenceBuilder : IDisposable { diff --git a/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter/ReadonlyMaterialConverter.MaterialReferenceBuilder.cs.meta b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter/ReadonlyMaterialConverter.MaterialReferenceBuilder.cs.meta new file mode 100644 index 00000000000..04d06e483b4 --- /dev/null +++ b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter/ReadonlyMaterialConverter.MaterialReferenceBuilder.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 5a08f69627b72e0488199be67df80530 \ No newline at end of file diff --git a/Packages/com.unity.render-pipelines.universal/Editor/Tools/Converters/ReadonlyMaterialConverter/ReadonlyMaterialConverter.MaterialReferenceChanger.cs b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter/ReadonlyMaterialConverter.MaterialReferenceChanger.cs similarity index 90% rename from Packages/com.unity.render-pipelines.universal/Editor/Tools/Converters/ReadonlyMaterialConverter/ReadonlyMaterialConverter.MaterialReferenceChanger.cs rename to Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter/ReadonlyMaterialConverter.MaterialReferenceChanger.cs index 31f4a444887..7c9a20ac876 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/Tools/Converters/ReadonlyMaterialConverter/ReadonlyMaterialConverter.MaterialReferenceChanger.cs +++ b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter/ReadonlyMaterialConverter.MaterialReferenceChanger.cs @@ -1,22 +1,23 @@ using System; -using System.ComponentModel; using System.Reflection; using System.Text; using UnityEditor.SceneManagement; using UnityEngine; using UnityEngine.SceneManagement; -using static UnityEditor.Rendering.Universal.MaterialReferenceBuilder; +using static UnityEditor.Rendering.Converter.MaterialReferenceBuilder; using Object = UnityEngine.Object; -namespace UnityEditor.Rendering.Universal +namespace UnityEditor.Rendering.Converter { internal class MaterialReferenceChanger : IDisposable { MaterialReferenceBuilder m_Builder; + ReadonlyMaterialMap m_Mappings; - public MaterialReferenceChanger() + public MaterialReferenceChanger(ReadonlyMaterialMap mappings) { m_Builder = new MaterialReferenceBuilder(); + m_Mappings = mappings; } public void Dispose() @@ -47,7 +48,7 @@ internal static bool AreMaterialsEqual(Material[] a, Material[] b) return true; } - private static bool TryChangeMaterialArray(Func getter, Action setter) + private bool TryChangeMaterialArray(Func getter, Action setter) { var materials = getter() as Material[]; if (materials == null) @@ -56,7 +57,7 @@ private static bool TryChangeMaterialArray(Func getter, Action s bool setIsNeeded = false; for (int i = 0; i < materials.Length; ++i) { - if (ReadonlyMaterialMap.TryGetMappingMaterial(materials[i], out var mappingMaterial)) + if (m_Mappings.TryGetMappingMaterial(materials[i], out var mappingMaterial)) { materials[i] = mappingMaterial; setIsNeeded = true; @@ -72,10 +73,10 @@ private static bool TryChangeMaterialArray(Func getter, Action s return true; } - private static bool TryChangeMaterial(Func getter, Action setter) + private bool TryChangeMaterial(Func getter, Action setter) { var material = getter() as Material; - if (ReadonlyMaterialMap.TryGetMappingMaterial(material, out var mappingMaterial)) + if (m_Mappings.TryGetMappingMaterial(material, out var mappingMaterial)) { setter(mappingMaterial); var updated = getter() as Material; @@ -85,7 +86,7 @@ private static bool TryChangeMaterial(Func getter, Action setter return true; } - private static bool ReassignMaterialsFromInstance(object obj, MemberInfo member, bool isArray) + private bool ReassignMaterialsFromInstance(object obj, MemberInfo member, bool isArray) { if (obj == null || member == null) return false; @@ -206,7 +207,6 @@ public bool ReassignUnityObjectMaterials(Object obj, StringBuilder errors) { // Make sure the changes get saved EditorUtility.SetDirty(obj); - EditorSceneManager.SaveScene(SceneManager.GetActiveScene()); } else errors.AppendLine($"Could not reassign materials of {obj} with {obj.GetType()} type."); diff --git a/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter/ReadonlyMaterialConverter.MaterialReferenceChanger.cs.meta b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter/ReadonlyMaterialConverter.MaterialReferenceChanger.cs.meta new file mode 100644 index 00000000000..2619542c7ad --- /dev/null +++ b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter/ReadonlyMaterialConverter.MaterialReferenceChanger.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 8d43dcf0c0580c74485954c1a2447f4a \ No newline at end of file diff --git a/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter/ReadonlyMaterialConverter.cs b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter/ReadonlyMaterialConverter.cs new file mode 100644 index 00000000000..50ac547a280 --- /dev/null +++ b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter/ReadonlyMaterialConverter.cs @@ -0,0 +1,129 @@ +using System; +using System.Collections.Generic; +using System.Text; +using UnityEngine; + +namespace UnityEditor.Rendering.Converter +{ + internal class ReadonlyMaterialMap + { + public bool TryGetMappingMaterial(Material material, out Material mappingMaterial) + { + mappingMaterial = material; + + if (m_BuiltInMaterialsMappings.TryGetValue(material.name, out var mapping)) + mappingMaterial = mapping(); + + return mappingMaterial != null; + } + + public int count => m_BuiltInMaterialsMappings.Count; + + public IEnumerable Keys => m_BuiltInMaterialsMappings.Keys; + + Dictionary> m_BuiltInMaterialsMappings = new(); + + public List<(string materialName, string searchQuery)> GetMaterialSearchList() + { + List<(string materialName, string searchQuery)> list = new(); + foreach (var mat in GetBuiltInMaterials()) + { + string formattedId = $"<$object:{GlobalObjectId.GetGlobalObjectIdSlow(mat)},UnityEngine.Object$>"; + list.Add(($"p: ref={formattedId}", $"{mat.name} is being referenced")); + } + return list; + } + + public ReadonlyMaterialMap(Dictionary> mappings) + { + m_BuiltInMaterialsMappings = mappings; + } + + public Material[] GetBuiltInMaterials() + { + using (UnityEngine.Pool.ListPool.Get(out var tmp)) + { + foreach (var materialName in Keys) + { + var name = materialName + ".mat"; + + Material mat = null; + foreach (var material in AssetDatabaseHelper.FindAssets()) + { + if (material.name == materialName) + { + mat = material; + break; + } + } + + if (mat == null) + { + mat = AssetDatabase.GetBuiltinExtraResource(name); + if (mat == null) + { + mat = Resources.GetBuiltinResource(name); + if (mat == null) + { + mat = Resources.Load(name); + } + } + } + + if (mat == null) + { + Debug.LogError($"Material '{materialName}' not found in built-in resources or project assets."); + continue; + } + + tmp.Add(mat); + } + return tmp.ToArray(); + } + } + } + + [Serializable] + internal abstract class ReadonlyMaterialConverter : AssetsConverter + { + protected virtual Dictionary> materialMappings { get; } + + protected override List<(string query, string description)> contextSearchQueriesAndIds + { + get => mappings.GetMaterialSearchList(); + } + + internal MaterialReferenceChanger m_MaterialReferenceChanger; + private ReadonlyMaterialMap m_Mappings; + + internal ReadonlyMaterialMap mappings + { + get + { + m_Mappings ??= new ReadonlyMaterialMap(materialMappings); + return m_Mappings; + } + } + + public override void BeforeConvert() + { + m_MaterialReferenceChanger = new MaterialReferenceChanger(mappings); + } + + public override void AfterConvert() + { + m_MaterialReferenceChanger?.Dispose(); + m_MaterialReferenceChanger = null; + } + + protected override Status ConvertObject(UnityEngine.Object obj, StringBuilder message) + { + if (!m_MaterialReferenceChanger.ReassignUnityObjectMaterials(obj, message)) + { + return Status.Error; + } + + return Status.Success; + } + } +} diff --git a/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter/ReadonlyMaterialConverter.cs.meta b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter/ReadonlyMaterialConverter.cs.meta new file mode 100644 index 00000000000..3cff46d9d98 --- /dev/null +++ b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter/ReadonlyMaterialConverter.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: ef285673d8dffb04686591a94181fbdb \ No newline at end of file diff --git a/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/RenderPipelineConverterAssetItem.cs b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/RenderPipelineConverterAssetItem.cs index 81b07d5208f..f73d71016c1 100644 --- a/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/RenderPipelineConverterAssetItem.cs +++ b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/RenderPipelineConverterAssetItem.cs @@ -23,7 +23,8 @@ public string name } } - public string info => assetPath; + [field:SerializeField] + public string info {get; set; } public bool isEnabled { get; set; } = true; public string isDisabledMessage { get; set; } = string.Empty; diff --git a/Packages/com.unity.render-pipelines.core/Editor/BuildProcessors/CoreBuildData.cs b/Packages/com.unity.render-pipelines.core/Editor/BuildProcessors/CoreBuildData.cs index c11ff6e1809..3f675d9c7c2 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/BuildProcessors/CoreBuildData.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/BuildProcessors/CoreBuildData.cs @@ -34,7 +34,7 @@ public class CoreBuildData : IDisposable /// public List renderPipelineAssets { get; private set; } = new(); - internal Dictionary computeShaderCache { get; private set; } = new(); + internal Dictionary computeShaderCache { get; private set; } = new(); internal bool pipelineSupportGPUResidentDrawer { get; private set; } = false; internal bool playerNeedGPUResidentDrawer { get; private set; } = false; @@ -80,8 +80,10 @@ private void CheckGPUResidentDrawerUsage() if (!playerNeedGPUResidentDrawer) return; + #pragma warning disable 618 // Todo(@daniel.andersen): Remove deprecated API usage GraphicsSettings.GetRenderPipelineSettings() .ForEachFieldOfType(computeShader => computeShaderCache.Add(computeShader.GetEntityId(), computeShader)); + #pragma warning restore 618 } /// diff --git a/Packages/com.unity.render-pipelines.core/Editor/BuildProcessors/ShaderStrippers/SRPDisabledComputeShaderVariantStripper.cs b/Packages/com.unity.render-pipelines.core/Editor/BuildProcessors/ShaderStrippers/SRPDisabledComputeShaderVariantStripper.cs index 49bdc1aa997..d4e71d90c1a 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/BuildProcessors/ShaderStrippers/SRPDisabledComputeShaderVariantStripper.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/BuildProcessors/ShaderStrippers/SRPDisabledComputeShaderVariantStripper.cs @@ -7,7 +7,9 @@ class SRPDisabledComputeShaderVariantStripper : IComputeShaderVariantStripper { public bool active => !CoreBuildData.instance.buildingPlayerForRenderPipeline; +#pragma warning disable 618 // Todo(@daniel.andersen): Remove deprecated API usage public bool CanRemoveVariant([DisallowNull] ComputeShader shader, string _, ShaderCompilerData __) => CoreBuildData.instance.computeShaderCache.ContainsKey(shader.GetEntityId()); +#pragma warning restore 618 } } \ No newline at end of file diff --git a/Packages/com.unity.render-pipelines.core/Editor/InternalBridge/AssemblyInfo.cs b/Packages/com.unity.render-pipelines.core/Editor/InternalBridge/AssemblyInfo.cs index 1e5964a9fcc..8ea160f1dec 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/InternalBridge/AssemblyInfo.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/InternalBridge/AssemblyInfo.cs @@ -1,3 +1,4 @@ using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("Unity.RenderPipelines.Core.Editor")] +[assembly: InternalsVisibleTo("Unity.RenderPipelines.HighDefinition.Editor")] diff --git a/Packages/com.unity.render-pipelines.core/Editor/InternalBridge/ObjectSelector.cs b/Packages/com.unity.render-pipelines.core/Editor/InternalBridge/ObjectSelector.cs new file mode 100644 index 00000000000..8c398439214 --- /dev/null +++ b/Packages/com.unity.render-pipelines.core/Editor/InternalBridge/ObjectSelector.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using System; +using UnityEngine; + +namespace UnityEditor.Rendering +{ + static class ObjectSelector + { + public static void Show(UnityEngine.Object obj, Type requiredType, UnityEngine.Object objectBeingEdited, bool allowSceneObjects, List allowedEntityIds = null, Action onObjectSelectorClosed = null, Action onObjectSelectedUpdated = null, bool showNoneItem = true) + { + UnityEditor.ObjectSelector.get.Show(obj, requiredType, objectBeingEdited, allowSceneObjects, allowedEntityIds, onObjectSelectorClosed, onObjectSelectedUpdated, showNoneItem); + } + } +} diff --git a/Packages/com.unity.render-pipelines.core/Editor/InternalBridge/ObjectSelector.cs.meta b/Packages/com.unity.render-pipelines.core/Editor/InternalBridge/ObjectSelector.cs.meta new file mode 100644 index 00000000000..97069b18bcb --- /dev/null +++ b/Packages/com.unity.render-pipelines.core/Editor/InternalBridge/ObjectSelector.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: cc3e1b4fa05dd864a960b9708102285b \ No newline at end of file diff --git a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.RenderingLayers.cs b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.RenderingLayers.cs index 954dc148af1..78fe73ff26c 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.RenderingLayers.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.RenderingLayers.cs @@ -104,7 +104,7 @@ public override void Initialize(ProbeVolumeBakingSet bakingSet, NativeArray perSubMeshOpaqueness = stackalloc bool[subMeshCount]; perSubMeshOpaqueness.Fill(true); - accelStruct.AddInstance(renderer.component.GetEntityId(), renderer.component, perSubMeshMask, matIndices, perSubMeshOpaqueness, 1); + accelStruct.AddInstance(renderer.component.GetEntityId().GetRawData(), renderer.component, perSubMeshMask, matIndices, perSubMeshOpaqueness, 1); } foreach (var terrain in contributors.terrains) { uint mask = GetInstanceMask(terrain.component.shadowCastingMode); uint materialID = terrain.component.renderingLayerMask; // repurpose the material id as we don't need it here - accelStruct.AddInstance(terrain.component.GetEntityId(), terrain.component, new uint[1] { mask }, new uint[1] { materialID }, new bool[1] { true }, 1); + accelStruct.AddInstance(terrain.component.GetEntityId().GetRawData(), terrain.component, new uint[1] { mask }, new uint[1] { materialID }, new bool[1] { true }, 1); } return accelStruct; diff --git a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.SkyOcclusion.cs b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.SkyOcclusion.cs index 37eb01539a1..a1a3439789e 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.SkyOcclusion.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.SkyOcclusion.cs @@ -223,13 +223,13 @@ static AccelStructAdapter BuildAccelerationStructure() Span perSubMeshOpaqueness = stackalloc bool[subMeshCount]; perSubMeshOpaqueness.Fill(true); - accelStruct.AddInstance((int)renderer.component.GetEntityId().GetRawData(), renderer.component, perSubMeshMask, matIndices, perSubMeshOpaqueness, 1); + accelStruct.AddInstance(renderer.component.GetEntityId().GetRawData(), renderer.component, perSubMeshMask, matIndices, perSubMeshOpaqueness, 1); } foreach (var terrain in contributors.terrains) { uint mask = GetInstanceMask(terrain.component.shadowCastingMode); - accelStruct.AddInstance(terrain.component.GetEntityId(), terrain.component, new uint[1] { mask }, new uint[1] { 0 }, new bool[1] { true }, 1); + accelStruct.AddInstance(terrain.component.GetEntityId().GetRawData(), terrain.component, new uint[1] { mask }, new uint[1] { 0 }, new bool[1] { true }, 1); } return accelStruct; diff --git a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.VirtualOffset.cs b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.VirtualOffset.cs index 6c86eddc9c3..16968c6f7a7 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.VirtualOffset.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.VirtualOffset.cs @@ -149,7 +149,7 @@ static AccelStructAdapter BuildAccelerationStructure(int mask) Span perSubMeshOpaqueness = stackalloc bool[subMeshCount]; perSubMeshOpaqueness.Fill(true); - accelStruct.AddInstance(renderer.component.GetEntityId(), renderer.component, maskAndMatDummy, maskAndMatDummy, perSubMeshOpaqueness, 1); + accelStruct.AddInstance(renderer.component.GetEntityId().GetRawData(), renderer.component, maskAndMatDummy, maskAndMatDummy, perSubMeshOpaqueness, 1); } foreach (var terrain in contributors.terrains) @@ -158,7 +158,7 @@ static AccelStructAdapter BuildAccelerationStructure(int mask) if ((layerMask & mask) == 0) continue; - accelStruct.AddInstance(terrain.component.GetEntityId(), terrain.component, new uint[1] { 0xFFFFFFFF }, new uint[1] { 0xFFFFFFFF }, new bool[1] { true }, 1); + accelStruct.AddInstance(terrain.component.GetEntityId().GetRawData(), terrain.component, new uint[1] { 0xFFFFFFFF }, new uint[1] { 0xFFFFFFFF }, new bool[1] { true }, 1); } return accelStruct; diff --git a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.cs b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.cs index a6621e271af..c4de5688616 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.cs @@ -1643,13 +1643,15 @@ public static bool BakeAsync() /// Request additional bake request manager to recompute baked data for an array of requests /// /// Array of instance IDs of the probes doing the request. - public static void BakeAdditionalRequests(int[] probeInstanceIDs) + public static void BakeAdditionalRequests(EntityId[] probeInstanceIDs) { - List validProbeInstanceIDs = new List(); + List validProbeInstanceIDs = new List(); List positions = new List(); foreach (var probeInstanceID in probeInstanceIDs) { +#pragma warning disable 618 // Todo(@daniel.andersen): Remove deprecated API usage if (AdditionalGIBakeRequestsManager.GetPositionForRequest(probeInstanceID, out var position)) +#pragma warning restore 618 { validProbeInstanceIDs.Add(probeInstanceID); positions.Add(position); @@ -1667,21 +1669,47 @@ public static void BakeAdditionalRequests(int[] probeInstanceIDs) for (int probeIndex = 0; probeIndex < numValidProbes; ++probeIndex) { +#pragma warning disable 618 // Todo(@daniel.andersen): Remove deprecated API usage AdditionalGIBakeRequestsManager.SetSHCoefficients(validProbeInstanceIDs[probeIndex], sh[probeIndex], validity[probeIndex]); +#pragma warning restore 618 } } } + /// + /// Request additional bake request manager to recompute baked data for a given request + /// + /// The instance ID of the probe doing the request. + public static void BakeAdditionalRequest(EntityId probeEntityId) + { + EntityId[] probeEntityIds = new EntityId[1]; + probeEntityIds[0] = probeEntityId; + + BakeAdditionalRequests(probeEntityIds); + } + + // Obsolete wrapper methods for backward compatibility + /// + /// Request additional bake request manager to recompute baked data for an array of requests + /// + /// Array of instance IDs of the probes doing the request. + [System.Obsolete("Use BakeAdditionalRequests(EntityId[]) instead. This method will be removed in a future version.")] + public static void BakeAdditionalRequests(int[] probeInstanceIDs) + { + var entityIds = new EntityId[probeInstanceIDs.Length]; + for (int i = 0; i < probeInstanceIDs.Length; i++) + entityIds[i] = probeInstanceIDs[i]; + BakeAdditionalRequests(entityIds); + } + /// /// Request additional bake request manager to recompute baked data for a given request /// /// The instance ID of the probe doing the request. + [System.Obsolete("Use BakeAdditionalRequest(EntityId) instead. This method will be removed in a future version.")] public static void BakeAdditionalRequest(int probeInstanceID) { - int[] probeInstanceIDs = new int[1]; - probeInstanceIDs[0] = probeInstanceID; - - BakeAdditionalRequests(probeInstanceIDs); + BakeAdditionalRequest((EntityId)probeInstanceID); } static RenderingLayerBaker renderingLayerOverride = null; diff --git a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeLightingTab.cs b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeLightingTab.cs index ab94e7d8f23..bb2045301a0 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeLightingTab.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeLightingTab.cs @@ -361,6 +361,7 @@ void BakingGUI() activeSet = newSet; ProbeReferenceVolume.instance.Clear(); + ProbeReferenceVolume.instance.SetActiveBakingSet(newSet); } if (activeSet != null) diff --git a/Packages/com.unity.render-pipelines.core/Editor/PathTracing/BakeInputToWorldConversion.cs b/Packages/com.unity.render-pipelines.core/Editor/PathTracing/BakeInputToWorldConversion.cs index 04a0a20bec3..803b4060b6a 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/PathTracing/BakeInputToWorldConversion.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/PathTracing/BakeInputToWorldConversion.cs @@ -503,7 +503,7 @@ internal static void PopulateWorld(InputExtraction.BakeInput input, UnityCompute Dictionary> lodInstances; Dictionary> lodgroupToContributorInstances; WorldHelpers.AddContributingInstancesToWorld(world.PathTracingWorld, in fatInstances, out lodInstances, out lodgroupToContributorInstances); - world.PathTracingWorld.Build(sceneBounds, cmd, ref world.ScratchBuffer, samplingResources, true); + world.PathTracingWorld.Build(sceneBounds, cmd, ref world.ScratchBuffer, samplingResources, true, 1024); } internal static void DeserializeAndInjectBakeInputData( diff --git a/Packages/com.unity.render-pipelines.core/Editor/PathTracing/LightBakerStrangler.cs b/Packages/com.unity.render-pipelines.core/Editor/PathTracing/LightBakerStrangler.cs index a2b22365781..a6502d92fc1 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/PathTracing/LightBakerStrangler.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/PathTracing/LightBakerStrangler.cs @@ -415,7 +415,7 @@ internal static bool Bake(string bakeInputPath, string lightmapRequestsPath, str // Build world with extracted data const bool emissiveSampling = true; - world.PathTracingWorld.Build(sceneBounds, deviceContext.GetCommandBuffer(), ref world.ScratchBuffer, samplingResources, emissiveSampling); + world.PathTracingWorld.Build(sceneBounds, deviceContext.GetCommandBuffer(), ref world.ScratchBuffer, samplingResources, emissiveSampling, 1024); LightmapBakeSettings lightmapBakeSettings = GetLightmapBakeSettings(bakeInput); // Build array of lightmap descriptors based on the atlassing data and instances. diff --git a/Packages/com.unity.render-pipelines.core/Editor/PostProcessing/LensFlareEditorUtils.cs b/Packages/com.unity.render-pipelines.core/Editor/PostProcessing/LensFlareEditorUtils.cs index 8b24f9eed68..b043b254ba8 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/PostProcessing/LensFlareEditorUtils.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/PostProcessing/LensFlareEditorUtils.cs @@ -35,7 +35,7 @@ public override void Action(EntityId entityId, string pathName, string resourceF internal static void CreateLensFlareDataSRPAsset() { const string relativePath = "New Lens Flare (SRP).asset"; - ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance(), relativePath, Icons.generic, null); + ProjectWindowUtil.StartNameEditingIfProjectWindowExists(EntityId.None, ScriptableObject.CreateInstance(), relativePath, Icons.generic, null); } internal static LensFlareDataSRP CreateLensFlareDataSRPAsset(Scene scene, string targetName) diff --git a/Packages/com.unity.render-pipelines.core/Editor/RenderGraph/RenderGraphViewer.cs b/Packages/com.unity.render-pipelines.core/Editor/RenderGraph/RenderGraphViewer.cs index 3e361812514..71c60e43fb7 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/RenderGraph/RenderGraphViewer.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/RenderGraph/RenderGraphViewer.cs @@ -124,7 +124,7 @@ internal static partial class Classes bool m_Paused = false; - static int s_EditorWindowInstanceId; + static EntityId s_EditorWindowEntityId; DateTime m_LastDataCaptureTime = DateTime.MinValue; string m_ConnectedDeviceName = "Local Editor"; bool m_IsDeviceConnected = true; @@ -2086,7 +2086,7 @@ void DelayedRefresh() void CreateGUI() { - s_EditorWindowInstanceId = GetEntityId(); + s_EditorWindowEntityId = GetEntityId(); if (EditorPrefs.HasKey(kPassFilterLegacyEditorPrefsKey)) m_PassFilterLegacy = (PassFilterLegacy)EditorPrefs.GetInt(kPassFilterLegacyEditorPrefsKey); @@ -2142,7 +2142,7 @@ void OnDisable() // maximized, seemingly nothing happens. When it gets unmaximized, both OnEnable() and OnDisable() get called // on a new EditorWindow instance, which I guess was the maximized one? Anyway we need to ignore this event // because the DebugSession is static and we don't want to unsubscribe because the window is still open. - if (s_EditorWindowInstanceId != GetEntityId()) + if (s_EditorWindowEntityId != GetEntityId()) return; m_CurrentDebugData?.Clear(); diff --git a/Packages/com.unity.render-pipelines.core/Editor/SampleDependencyImportSystem/SampleDependencyImporter.cs b/Packages/com.unity.render-pipelines.core/Editor/SampleDependencyImportSystem/SampleDependencyImporter.cs index d2a8bef4d18..2c2fad2aeb9 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/SampleDependencyImportSystem/SampleDependencyImporter.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/SampleDependencyImportSystem/SampleDependencyImporter.cs @@ -77,7 +77,7 @@ VisualElement IPackageManagerExtension.CreateExtensionUI() Button samplesButton; const string samplesButtonName = "samplesButton"; const string sampleContainerClassName = "sampleContainer"; - const string importButtonClassName = "importButton"; + const string importButtonClassName = "actionButton"; const string injectedButtonClassName = "importWithDependenciesButton"; void RefreshSampleButtons() @@ -114,6 +114,8 @@ void RefreshSampleButtons() if (injectedButton == null) { // Get and hide the original import button. + // WARNING! There are now two buttons - "Import" and "Locate". The Import button is first in the hierarchy + // so this happens to work, but it's really brittle so we need to find a better way to do this. var importButton = sampleContainer.Q