Skip to content

Commit a7f96d2

Browse files
authored
Merge pull request #8278 from Unity-Technologies/internal/master
mirror Internal/master
2 parents 8c77b80 + ca2a322 commit a7f96d2

File tree

610 files changed

+53680
-8084
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

610 files changed

+53680
-8084
lines changed

Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/AssetsConverter.cs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Text;
4+
using UnityEngine;
45

56
namespace UnityEditor.Rendering.Converter
67
{
@@ -24,16 +25,42 @@ void OnSearchFinish()
2425
onScanFinish?.Invoke(returnList);
2526
}
2627

28+
var processedIds = new HashSet<string>();
29+
2730
SearchServiceUtils.RunQueuedSearch
2831
(
2932
SearchServiceUtils.IndexingOptions.DeepSearch,
3033
contextSearchQueriesAndIds,
3134
(item, description) =>
3235
{
33-
var assetItem = new RenderPipelineConverterAssetItem(item.id)
36+
// Direct conversion - works for both assets and scene objects
37+
var unityObject = item.ToObject();
38+
39+
if (unityObject == null)
40+
return;
41+
42+
// Ensure we're always working with GameObjects
43+
GameObject go = null;
44+
45+
if (unityObject is GameObject gameObject)
46+
go = gameObject;
47+
else if (unityObject is Component component)
48+
go = component.gameObject;
49+
else
50+
return; // Not a GameObject or Component
51+
52+
var gid = GlobalObjectId.GetGlobalObjectIdSlow(go);
53+
if (!processedIds.Add(gid.ToString()))
54+
return;
55+
56+
int type = gid.identifierType; // 1=Asset, 2=SceneObject
57+
58+
var assetItem = new RenderPipelineConverterAssetItem(gid.ToString())
3459
{
35-
info = description
60+
name = $"{unityObject.name} ({(type == 1 ? "Prefab" : "SceneObject")})",
61+
info = type == 1 ? AssetDatabase.GetAssetPath(unityObject) : go.scene.path,
3662
};
63+
3764
assets.Add(assetItem);
3865
},
3966
OnSearchFinish

Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/RenderPipelineConverterAssetItem.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ public string guid
3030

3131
public string GlobalObjectId => m_GlobalObjectId;
3232

33-
public string name => System.IO.Path.GetFileNameWithoutExtension(assetPath);
33+
[SerializeField]
34+
private string m_Name;
35+
public string name
36+
{
37+
get => string.IsNullOrEmpty(m_Name) ? System.IO.Path.GetFileNameWithoutExtension(assetPath) : m_Name;
38+
set => m_Name = value;
39+
}
3440

3541
[SerializeField]
3642
private string m_Info;

Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/RenderPipelineConverterMaterialUpgrader.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ public void OnClicked()
7676
[Serializable]
7777
internal abstract class RenderPipelineConverterMaterialUpgrader : IRenderPipelineConverter
7878
{
79+
public virtual bool isEnabled => m_UpgradersCache != null && m_UpgradersCache.Count > 0;
80+
public virtual string isDisabledMessage => "No material upgraders specified for this converter.";
81+
7982
/// <summary>
8083
/// List of material upgraders to use for this converter.
8184
/// </summary>

Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/Window/RenderPipelineConverterVisualElement.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ internal class RenderPipelineConverterVisualElement : VisualElement
3737

3838
public Action converterSelected;
3939

40+
private bool m_IsEnabled;
41+
42+
private void SetEnabled(bool value, bool force = false)
43+
{
44+
if (m_IsEnabled != value || force)
45+
{
46+
m_IsEnabled = value;
47+
m_HeaderFoldout.tooltip = (m_IsEnabled) ? description : converter.isDisabledMessage;
48+
m_HeaderFoldout.SetEnabled(m_IsEnabled);
49+
}
50+
}
51+
4052
public RenderPipelineConverterVisualElement(Node<ConverterInfo> converterInfo)
4153
{
4254
m_ConverterInfo = converterInfo;
@@ -47,8 +59,10 @@ public RenderPipelineConverterVisualElement(Node<ConverterInfo> converterInfo)
4759

4860
m_HeaderFoldout = m_RootVisualElement.Q<HeaderFoldout>("conveterFoldout");
4961
m_HeaderFoldout.text = displayName;
50-
m_HeaderFoldout.tooltip = (converter.isEnabled) ? description : converter.isDisabledMessage;
51-
m_HeaderFoldout.SetEnabled(converter.isEnabled);
62+
63+
SetEnabled(converter.isEnabled, true);
64+
m_HeaderFoldout.schedule.Execute(() => SetEnabled(converter.isEnabled)).Every(500);
65+
5266
m_HeaderFoldout.value = state.isExpanded;
5367
m_HeaderFoldout.RegisterCallback<ChangeEvent<bool>>((evt) =>
5468
{

Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/Window/RenderPipelineConvertersEditor.cs

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,16 @@ public static void ShowWindow()
8282
[MenuItem("Window/Rendering/Render Pipeline Converter", true, 50)]
8383
public static bool CanShowWindow()
8484
{
85-
return !EditorApplication.isPlaying;
85+
if (EditorApplication.isPlaying)
86+
return false;
87+
88+
foreach (var converterType in TypeCache.GetTypesDerivedFrom<IRenderPipelineConverter>())
89+
{
90+
if (!converterType.IsAbstract && !converterType.IsInterface)
91+
return true;
92+
}
93+
94+
return false;
8695
}
8796

8897
internal static void DontSaveToLayout(EditorWindow wnd)
@@ -212,7 +221,8 @@ public void CreateGUI()
212221
if (converterNodeCategory.name == to.label)
213222
currentContainer = converterNodeCategory;
214223
}
215-
HideUnhideConverters();
224+
225+
ConfigureUI();
216226
};
217227

218228
m_SourcePipelineDropDown.RegisterCallback<ChangeEvent<string>>((evt) =>
@@ -225,40 +235,51 @@ public void CreateGUI()
225235
HideUnhideConverters();
226236
});
227237

238+
ConfigureUI();
239+
240+
UpdateUiForPlayMode(EditorApplication.isPlaying);
241+
}
242+
243+
private void ConfigureUI()
244+
{
228245
HideUnhideConverters();
229246
EnableOrDisableScanButton();
230247
EnableOrDisableConvertButton();
231-
232-
UpdateUiForPlayMode(EditorApplication.isPlaying);
233248
}
234249

235250
private bool CanEnableScan()
236251
{
237-
foreach (var kvp in m_ConvertersVisualElements)
252+
foreach (var child in currentContainer.children)
238253
{
239-
var ve = kvp.Value;
240-
if (ve.isSelectedAndEnabled &&
241-
!ve.state.isInitialized)
254+
if (m_ConvertersVisualElements.TryGetValue(child, out var ve))
242255
{
243-
return true;
256+
if (ve.isSelectedAndEnabled &&
257+
!ve.state.isInitialized)
258+
{
259+
return true;
260+
}
244261
}
245262
}
263+
246264
return false;
247265
}
248266

249267
private bool CanEnableConvert()
250268
{
251-
foreach (var kvp in m_ConvertersVisualElements)
269+
foreach (var child in currentContainer.children)
252270
{
253-
var ve = kvp.Value;
254-
if (ve.isSelectedAndEnabled &&
255-
ve.state.isInitialized &&
256-
ve.state.selectedItemsCount > 0 &&
257-
ve.state.pending > 0)
271+
if (m_ConvertersVisualElements.TryGetValue(child, out var ve))
258272
{
259-
return true;
273+
if (ve.isSelectedAndEnabled &&
274+
ve.state.isInitialized &&
275+
ve.state.selectedItemsCount > 0 &&
276+
ve.state.pending > 0)
277+
{
278+
return true;
279+
}
260280
}
261281
}
282+
262283
return false;
263284
}
264285

Packages/com.unity.render-pipelines.core/Editor/Lighting/LightingSearchSelectors.cs renamed to Packages/com.unity.render-pipelines.core/Editor/Lighting/LightingSearchColumnProviders.cs

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace UnityEditor.Lighting
88
{
9-
static class CoreLightingSearchSelectors
9+
static class CoreLightingSearchColumnProviders
1010
{
1111
internal const string k_SceneProvider = "scene";
1212
internal const string k_BakingSetPath = "BakingSets/";
@@ -18,8 +18,7 @@ static class CoreLightingSearchSelectors
1818
internal const string k_VolumeModePath = k_VolumePath + "Mode";
1919
internal const string k_VolumeProfilePath = k_VolumePath + "Profile";
2020

21-
const string k_StyleSheetPath = "StyleSheets/LightingSearchSelectors.uss";
22-
const int k_DefaultSearchSelectorPriority = 99;
21+
const string k_StyleSheetPath = "StyleSheets/LightingSearchColumnProviders.uss";
2322
const int k_MinBakingSamples = 1;
2423
const int k_MaxBakingSamples = 8192;
2524
static StyleSheet s_StyleSheet;
@@ -33,26 +32,6 @@ static StyleSheet LoadStyleSheet()
3332
return s_StyleSheet;
3433
}
3534

36-
[SearchSelector(k_VolumeModePath, provider: k_SceneProvider, priority: k_DefaultSearchSelectorPriority)]
37-
static object VolumeModeSearchSelector(SearchSelectorArgs args)
38-
{
39-
var go = args.current.ToObject<GameObject>();
40-
if (go == null)
41-
return null;
42-
43-
return LightingSearchDataAccessors.GetVolumeMode(go);
44-
}
45-
46-
[SearchSelector(k_VolumeProfilePath, provider: k_SceneProvider, priority: k_DefaultSearchSelectorPriority)]
47-
static object VolumeProfileSearchSelector(SearchSelectorArgs args)
48-
{
49-
var go = args.current.ToObject<GameObject>();
50-
if (go == null)
51-
return null;
52-
53-
return LightingSearchDataAccessors.GetVolumeProfile(go);
54-
}
55-
5635
[SearchColumnProvider(k_BakingModePath)]
5736
public static void BakingModeSearchColumnProvider(SearchColumn column)
5837
{
@@ -396,7 +375,7 @@ internal static void SetLightShape(GameObject go, LightType value)
396375

397376
internal static bool IsLightShapeApplicable(LightType lightType)
398377
{
399-
return IsAreaLight(lightType);
378+
return lightType is LightType.Rectangle or LightType.Disc;
400379
}
401380

402381
static bool IsAreaLight(LightType lightType)
@@ -407,8 +386,7 @@ static bool IsAreaLight(LightType lightType)
407386
enum AreaLightShape
408387
{
409388
Rectangle = LightType.Rectangle,
410-
Disc = LightType.Disc,
411-
Tube = LightType.Tube
389+
Disc = LightType.Disc
412390
}
413391

414392
class LightShapeField : EnumField
@@ -452,7 +430,9 @@ void UpdateEnumField()
452430
{
453431
if (IsAreaLight(m_Value))
454432
{
455-
Init((AreaLightShape)m_Value, false);
433+
// Tube is not offered as an option; display as Rectangle
434+
var displayType = m_Value == LightType.Tube ? LightType.Rectangle : m_Value;
435+
Init((AreaLightShape)displayType, false);
456436
}
457437
}
458438
}

Packages/com.unity.render-pipelines.core/Editor/Lighting/LightingSearchSelectors.cs.meta renamed to Packages/com.unity.render-pipelines.core/Editor/Lighting/LightingSearchColumnProviders.cs.meta

File renamed without changes.

Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.LightTransport.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,13 @@ public void Create(ProbeVolumeBakingSet bakingSet, LightingSettings lightingSett
241241
skyOcclusionBakingSamples = bakingSet != null ? bakingSet.skyOcclusionBakingSamples : 0;
242242
skyOcclusionBakingBounces = bakingSet != null ? bakingSet.skyOcclusionBakingBounces : 0;
243243

244-
#if UNIFIED_BAKER
245-
int indirectSampleCount = lightingSettings.indirectSampleCount;
246-
#else
247-
int indirectSampleCount = Math.Max(lightingSettings.indirectSampleCount, lightingSettings.environmentSampleCount);
248-
#endif
244+
var usingComputeLightBaker = UnityEditor.Rendering.EditorGraphicsSettings.defaultLightBaker == UnityEditor.Rendering.LightBaker.UnityComputeLightBaker;
245+
int indirectSampleCount = 0;
246+
if (usingComputeLightBaker)
247+
indirectSampleCount = lightingSettings.indirectSampleCount;
248+
else
249+
indirectSampleCount = Math.Max(lightingSettings.indirectSampleCount, lightingSettings.environmentSampleCount);
250+
249251
Create(lightingSettings, ignoreEnvironement, lightingSettings.directSampleCount, indirectSampleCount, lightingSettings.environmentSampleCount,
250252
(int)lightingSettings.lightProbeSampleCountMultiplier, lightingSettings.maxBounces);
251253
}
@@ -670,7 +672,7 @@ internal static void BakeAdjustmentVolume(ProbeVolumeBakingSet bakingSet, ProbeA
670672
failed |= !layerMaskJob.Step();
671673

672674
// Bake probe SH
673-
s_BakeData.InitLightingJob(m_BakingSet, uniquePositions, BakeType.ApvOnly);
675+
s_BakeData.InitLightingJob(bakingSet, touchup, uniquePositions, BakeType.ApvOnly);
674676
LightingBaker lightingJob = s_BakeData.lightingJob;
675677
while (!failed && lightingJob.currentStep < lightingJob.stepCount)
676678
failed |= !lightingJob.Step();
@@ -680,7 +682,7 @@ internal static void BakeAdjustmentVolume(ProbeVolumeBakingSet bakingSet, ProbeA
680682
foreach ((int uniqueProbeIndex, int cellIndex, int i) in bakedProbes)
681683
{
682684
ref var cell = ref bakingCells[cellIndex];
683-
cell.SetBakedData(m_BakingSet, m_BakingBatch, cellVolumes[cellIndex], i, uniqueProbeIndex,
685+
cell.SetBakedData(bakingSet, m_BakingBatch, cellVolumes[cellIndex], i, uniqueProbeIndex,
684686
lightingJob.irradiance[uniqueProbeIndex], lightingJob.validity[uniqueProbeIndex],
685687
layerMaskJob.renderingLayerMasks, virtualOffsetJob.offsets,
686688
skyOcclusionJob.occlusion, skyOcclusionJob.encodedDirections, lightingJob.occlusion);
@@ -696,8 +698,8 @@ internal static void BakeAdjustmentVolume(ProbeVolumeBakingSet bakingSet, ProbeA
696698
{
697699
// Validate baking cells size before any global state modifications
698700
var chunkSizeInProbes = ProbeBrickPool.GetChunkSizeInProbeCount();
699-
var hasVirtualOffsets = m_BakingSet.settings.virtualOffsetSettings.useVirtualOffset;
700-
var hasRenderingLayers = m_BakingSet.useRenderingLayers;
701+
var hasVirtualOffsets = bakingSet.settings.virtualOffsetSettings.useVirtualOffset;
702+
var hasRenderingLayers = bakingSet.useRenderingLayers;
701703

702704
if (ValidateBakingCellsSize(bakingCells, chunkSizeInProbes, hasVirtualOffsets, hasRenderingLayers))
703705
{
@@ -707,8 +709,8 @@ internal static void BakeAdjustmentVolume(ProbeVolumeBakingSet bakingSet, ProbeA
707709
ComputeValidityMasks(cell);
708710
}
709711

710-
// Attempt to write the result to disk
711-
if (WriteBakingCells(bakingCells))
712+
// Attempt to write the result to disk.
713+
if (WriteBakingCells(bakingSet, bakingCells))
712714
{
713715
// Reload everything
714716
AssetDatabase.SaveAssets();

0 commit comments

Comments
 (0)