Skip to content

Commit 64b601d

Browse files
Merge pull request #8207 from Unity-Technologies/internal/6000.2/staging
Internal/6000.2/staging
2 parents 41da72b + fff297c commit 64b601d

File tree

133 files changed

+2997
-381
lines changed

Some content is hidden

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

133 files changed

+2997
-381
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,13 @@ static ProbeSubdivisionResult GetBricksFromLoaded()
257257
var dataList = GetPerSceneDataList();
258258
var result = new ProbeSubdivisionResult();
259259

260+
// We read bricks from the asset rather than using the currently loaded cells.
261+
// This is because not all bricks from the previous bake are guaranteed to be currently loaded,
262+
// we may for example have hit the max brick count given the selected memory budget.
263+
ProbeVolumeStreamableAsset bricksDataAsset = m_BakingSet.cellBricksDataAsset;
264+
bricksDataAsset.EnsureAssetLoaded();
265+
using NativeArray<Brick> previousBricks = bricksDataAsset.asset.GetData<Brick>();
266+
260267
foreach (var data in dataList)
261268
{
262269
var cellSize = m_ProfileInfo.minDistanceBetweenProbes * 3.0f * m_ProfileInfo.cellSizeInBricks;
@@ -268,15 +275,20 @@ static ProbeSubdivisionResult GetBricksFromLoaded()
268275
foreach (var cellIndex in cells)
269276
{
270277
var cellDesc = m_BakingSet.GetCellDesc(cellIndex);
271-
var cellData = m_BakingSet.GetCellData(cellIndex);
272278
var cellPos = cellDesc.position;
273279

274280
if (!result.scenesPerCells.ContainsKey(cellPos))
275281
{
276282
result.scenesPerCells[cellPos] = new HashSet<string>();
277283

278284
var center = new Vector3((cellPos.x + 0.5f) * cellSize, (cellPos.y + 0.5f) * cellSize, (cellPos.z + 0.5f) * cellSize);
279-
result.cells.Add((cellPos, new Bounds(center, cellDimensions), cellData.bricks.ToArray()));
285+
286+
var cellStreamingDesc = bricksDataAsset.streamableCellDescs[cellIndex];
287+
int bricksOffset = cellStreamingDesc.offset / bricksDataAsset.elementSize;
288+
int bricksCount = Mathf.Min(cellStreamingDesc.elementCount, cellDesc.bricksCount);
289+
Brick[] bricks = previousBricks.GetSubArray(bricksOffset, bricksCount).ToArray();
290+
291+
result.cells.Add((cellPos, new Bounds(center, cellDimensions), bricks));
280292
}
281293
result.scenesPerCells[cellPos].Add(data.sceneGUID);
282294
}

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.IO;
23
using System.Collections.Generic;
34
using UnityEditor.Build;
@@ -120,10 +121,16 @@ public override void PrepareForBuild(BuildPlayerContext buildPlayerContext)
120121
// APV doesn't work with WebGL, so let's warn the user.
121122
if (buildPlayerContext.BuildPlayerOptions.target == BuildTarget.WebGL)
122123
{
123-
Debug.LogError(
124-
$"The scene '{scene}' contains baked Adaptive Probe Volumes, but the build target is WebGL. " +
125-
"Adaptive Probe Volumes are not supported when targeting WebGL.");
126-
continue;
124+
// WebGPU does support APV so only warn if WebGPU is not enabled.
125+
GraphicsDeviceType[] apis = PlayerSettings.GetGraphicsAPIs(BuildTarget.WebGL);
126+
var index = Array.FindIndex(apis, x => x == GraphicsDeviceType.WebGPU);
127+
if (index == -1)
128+
{
129+
Debug.LogError(
130+
$"The scene '{scene}' contains baked Adaptive Probe Volumes, but the build target is WebGL. " +
131+
"Adaptive Probe Volumes are not supported when targeting WebGL.");
132+
continue;
133+
}
127134
}
128135

129136
var bakingSetGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(bakingSet));

Packages/com.unity.render-pipelines.core/Editor/MaterialUpgrader.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class KeywordFloatRename
7474
public float setVal, unsetVal;
7575
}
7676
List<KeywordFloatRename> m_KeywordFloatRename = new List<KeywordFloatRename>();
77+
Dictionary<string, (string, System.Func<float, bool>)> m_ConditionalFloatRename;
7778

7879
/// <summary>
7980
/// Type of property to rename.
@@ -222,6 +223,20 @@ public virtual void Convert(Material srcMaterial, Material dstMaterial)
222223

223224
dstMaterial.SetFloat(t.property, srcMaterial.IsKeywordEnabled(t.keyword) ? t.setVal : t.unsetVal);
224225
}
226+
227+
// Handle conditional float renaming
228+
if (m_ConditionalFloatRename != null)
229+
{
230+
foreach (var (oldName, (newName, condition)) in m_ConditionalFloatRename)
231+
{
232+
if (srcMaterial.HasProperty(oldName) &&
233+
condition(srcMaterial.GetFloat(oldName)) &&
234+
dstMaterial.HasProperty(newName))
235+
{
236+
dstMaterial.SetFloat(newName, 1.0f);
237+
}
238+
}
239+
}
225240
}
226241

227242
/// <summary>
@@ -318,6 +333,17 @@ public void RenameKeywordToFloat(string oldName, string newName, float setVal, f
318333
m_KeywordFloatRename.Add(new KeywordFloatRename { keyword = oldName, property = newName, setVal = setVal, unsetVal = unsetVal });
319334
}
320335

336+
/// <summary>
337+
/// Rename a float property conditionally based on its value
338+
/// </summary>
339+
/// <param name="oldName">Old property name</param>
340+
/// <param name="newName">New property name</param>
341+
/// <param name="condition">Condition function that takes the float value and returns true if renaming should occur</param>
342+
protected void RenameFloat(string oldName, string newName, System.Func<float, bool> condition)
343+
{
344+
(m_ConditionalFloatRename ??= new Dictionary<string, (string, System.Func<float, bool>)>())[oldName] = (newName, condition);
345+
}
346+
321347
static MaterialUpgrader GetUpgrader(List<MaterialUpgrader> upgraders, Material material)
322348
{
323349
if (material == null || material.shader == null)

Packages/com.unity.render-pipelines.core/Editor/Settings/DefaultVolumeProfileEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ void OnVolumeComponentContextClick(Vector2 position, VolumeComponentEditor targe
242242
menu.AddItem(VolumeProfileUtils.Styles.copySettings, false, () => VolumeComponentCopyPaste.CopySettings(targetComponent));
243243

244244
if (VolumeComponentCopyPaste.CanPaste(targetComponent))
245-
menu.AddItem(VolumeProfileUtils.Styles.pasteSettings, false, () => VolumeComponentCopyPaste.PasteSettings(targetComponent));
245+
menu.AddItem(VolumeProfileUtils.Styles.pasteSettings, false, () => VolumeComponentCopyPaste.PasteSettings(targetComponent, m_Profile));
246246
else
247247
menu.AddDisabledItem(VolumeProfileUtils.Styles.pasteSettings);
248248

Packages/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentCopyPaste.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static void CopySettings(VolumeComponent targetComponent)
6262
EditorGUIUtility.systemCopyBuffer = writer.ToString();
6363
}
6464

65-
public static void PasteSettings(VolumeComponent targetComponent)
65+
public static void PasteSettings(VolumeComponent targetComponent, VolumeProfile asset)
6666
{
6767
if (targetComponent == null)
6868
return;
@@ -72,6 +72,11 @@ public static void PasteSettings(VolumeComponent targetComponent)
7272
using var reader = new StringReader(EditorGUIUtility.systemCopyBuffer);
7373
if (TryReadCopyBuffer(reader, out var typeAndValue))
7474
JsonUtility.FromJsonOverwrite(typeAndValue[1], targetComponent);
75+
76+
if (EditorUtility.IsPersistent(asset))
77+
{
78+
EditorUtility.SetDirty(asset);
79+
}
7580
}
7681

7782
public static void CopySettings(List<VolumeComponent> targetComponents)
@@ -87,7 +92,7 @@ public static void CopySettings(List<VolumeComponent> targetComponents)
8792
EditorGUIUtility.systemCopyBuffer = writer.ToString();
8893
}
8994

90-
public static void PasteSettings(List<VolumeComponent> targetComponents)
95+
public static void PasteSettings(List<VolumeComponent> targetComponents, VolumeProfile asset)
9196
{
9297
if (targetComponents == null || targetComponents.Count == 0)
9398
return;
@@ -113,6 +118,11 @@ public static void PasteSettings(List<VolumeComponent> targetComponents)
113118
JsonUtility.FromJsonOverwrite(typeAndValue[1], targetComponent);
114119
}
115120
}
121+
122+
if (EditorUtility.IsPersistent(asset))
123+
{
124+
EditorUtility.SetDirty(asset);
125+
}
116126
}
117127
}
118128
}

Packages/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ void OnContextClick(Vector2 position, VolumeComponentEditor targetEditor, int id
470470
if (VolumeComponentCopyPaste.CanPaste(targetComponent))
471471
menu.AddItem(EditorGUIUtility.TrTextContent("Paste Settings"), false, () =>
472472
{
473-
VolumeComponentCopyPaste.PasteSettings(targetComponent);
473+
VolumeComponentCopyPaste.PasteSettings(targetComponent, asset);
474474
VolumeManager.instance.OnVolumeProfileChanged(asset);
475475
});
476476
else

Packages/com.unity.render-pipelines.core/Editor/Volume/VolumeEditor.cs

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -266,29 +266,62 @@ void OnVolumeProfileContextClick()
266266

267267
if (profileRef != null)
268268
{
269+
bool hasNoComponents = profileRef.components.Count == 0;
270+
269271
var cloneLabel = targetVolume.HasInstantiatedProfile() ? Styles.saveLabel : Styles.cloneLabel;
270272
menu.AddItem(cloneLabel, false, CloneProfile);
271273
menu.AddSeparator(string.Empty);
272-
menu.AddItem(VolumeProfileUtils.Styles.collapseAll, false, () =>
274+
275+
if (hasNoComponents)
273276
{
274-
VolumeProfileUtils.SetComponentEditorsExpanded(m_ComponentList.editors, false);
275-
});
276-
menu.AddItem(VolumeProfileUtils.Styles.expandAll, false, () =>
277+
menu.AddDisabledItem(VolumeProfileUtils.Styles.collapseAll);
278+
menu.AddDisabledItem(VolumeProfileUtils.Styles.expandAll);
279+
}
280+
else
277281
{
278-
VolumeProfileUtils.SetComponentEditorsExpanded(m_ComponentList.editors, true);
279-
});
282+
menu.AddItem(VolumeProfileUtils.Styles.collapseAll, false, () =>
283+
{
284+
VolumeProfileUtils.SetComponentEditorsExpanded(m_ComponentList.editors, false);
285+
});
286+
menu.AddItem(VolumeProfileUtils.Styles.expandAll, false, () =>
287+
{
288+
VolumeProfileUtils.SetComponentEditorsExpanded(m_ComponentList.editors, true);
289+
});
290+
}
291+
280292
menu.AddSeparator(string.Empty);
281-
menu.AddItem(Styles.enableAll, false, () => SetComponentsActive(true));
282-
menu.AddItem(Styles.disableAll, false, () => SetComponentsActive(false));
283-
menu.AddItem(Styles.removeAll, false, () => m_ComponentList.RemoveAllComponents());
284-
menu.AddItem(VolumeProfileUtils.Styles.resetAll, false, () => m_ComponentList.ResetAllComponents());
293+
294+
if (hasNoComponents)
295+
{
296+
menu.AddDisabledItem(Styles.enableAll);
297+
menu.AddDisabledItem(Styles.disableAll);
298+
menu.AddDisabledItem(Styles.removeAll);
299+
menu.AddDisabledItem(VolumeProfileUtils.Styles.resetAll);
300+
}
301+
else
302+
{
303+
menu.AddItem(Styles.enableAll, false, () => SetComponentsActive(true));
304+
menu.AddItem(Styles.disableAll, false, () => SetComponentsActive(false));
305+
menu.AddItem(Styles.removeAll, false, () => m_ComponentList.RemoveAllComponents());
306+
menu.AddItem(VolumeProfileUtils.Styles.resetAll, false, () => m_ComponentList.ResetAllComponents());
307+
}
308+
285309
menu.AddSeparator(string.Empty);
286-
menu.AddItem(VolumeProfileUtils.Styles.copyAllSettings, false,
287-
() => VolumeComponentCopyPaste.CopySettings(profileRef.components));
310+
311+
if (hasNoComponents)
312+
{
313+
menu.AddDisabledItem(VolumeProfileUtils.Styles.copyAllSettings);
314+
}
315+
else
316+
{
317+
menu.AddItem(VolumeProfileUtils.Styles.copyAllSettings, false,
318+
() => VolumeComponentCopyPaste.CopySettings(profileRef.components));
319+
}
320+
288321
if (VolumeComponentCopyPaste.CanPaste(profileRef.components))
289322
menu.AddItem(VolumeProfileUtils.Styles.pasteSettings, false, () =>
290323
{
291-
VolumeComponentCopyPaste.PasteSettings(profileRef.components);
324+
VolumeComponentCopyPaste.PasteSettings(profileRef.components, profileRef);
292325
VolumeManager.instance.OnVolumeProfileChanged(profileRef);
293326
});
294327
else

Packages/com.unity.render-pipelines.core/Editor/Volume/VolumeProfileUtils.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ public static void AddVolumeProfileContextMenuItems(
325325
if (VolumeComponentCopyPaste.CanPaste(volumeProfile.components))
326326
menu.AddItem(Styles.pasteSettings, false, () =>
327327
{
328-
VolumeComponentCopyPaste.PasteSettings(volumeProfile.components);
328+
VolumeComponentCopyPaste.PasteSettings(volumeProfile.components, volumeProfile);
329329
VolumeManager.instance.OnVolumeProfileChanged(volumeProfile);
330330
});
331331
else
@@ -411,7 +411,7 @@ public static void OnVolumeProfileContextClick(
411411
if (VolumeComponentCopyPaste.CanPaste(volumeProfile.components))
412412
menu.AddItem(Styles.pasteSettings, false, () =>
413413
{
414-
VolumeComponentCopyPaste.PasteSettings(volumeProfile.components);
414+
VolumeComponentCopyPaste.PasteSettings(volumeProfile.components, volumeProfile);
415415
VolumeManager.instance.OnVolumeProfileChanged(volumeProfile);
416416
});
417417
else

Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugUI.Fields.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ public void SetValue(object value)
8585
/// <param name="value">Input value.</param>
8686
public virtual void SetValue(T value)
8787
{
88-
Assert.IsNotNull(setter);
88+
if (setter == null)
89+
return;
90+
8991
var v = ValidateValue(value);
9092

9193
if (v == null || !v.Equals(getter()))

Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/GPUResidentDrawer.Validator.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ static class Strings
1818
public static readonly string batchRendererGroupShaderStrippingModeInvalid = $"{nameof(GPUResidentDrawer)} \"BatchRendererGroup Variants\" setting must be \"Keep All\". " +
1919
" The current setting will cause errors when building a player because all DOTS instancing shaders will be stripped" +
2020
" To fix, modify Graphics settings and set \"BatchRendererGroup Variants\" to \"Keep All\".";
21+
public static readonly string visionOSNotSupported = $"{nameof(GPUResidentDrawer)} Disabled on VisionOS as it is non applicable. This platform uses a custom rendering path and doesn't go through the resident drawer.";
2122
}
2223

2324
internal static bool IsProjectSupported()
@@ -30,6 +31,13 @@ internal static bool IsProjectSupported(out string message, out LogType severity
3031
message = string.Empty;
3132
severity = LogType.Log;
3233

34+
if (Application.platform == RuntimePlatform.VisionOS)
35+
{
36+
message = Strings.visionOSNotSupported;
37+
severity = LogType.Log;
38+
return false;
39+
}
40+
3341
// The GPUResidentDrawer only has support when the RawBuffer path of providing data
3442
// ConstantBuffer path and any other unsupported platforms early out here
3543
if (BatchRendererGroup.BufferTarget != BatchBufferTarget.RawBuffer)

0 commit comments

Comments
 (0)