Skip to content

Commit 6a723ff

Browse files
authored
Merge pull request #8109 from Unity-Technologies/internal/6000.0/staging
Internal/6000.0/staging
2 parents 828256b + eb2b453 commit 6a723ff

File tree

1,391 files changed

+35082
-30396
lines changed

Some content is hidden

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

1,391 files changed

+35082
-30396
lines changed

Packages/com.unity.render-pipelines.core/Editor/Gizmo/HierarchicalSphere.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ public HierarchicalSphere(Color baseColor, HierarchicalSphere parent = null)
118118
/// <param name="filled">If true, also draw the surface of the hull's sphere</param>
119119
public void DrawHull(bool filled)
120120
{
121+
if (Event.current.type != EventType.Repaint)
122+
return;
123+
121124
Color wireframeColor = m_HandleColor;
122125
wireframeColor.a = 0.8f;
123126
using (new Handles.DrawingScope(m_WireframeColor, Matrix4x4.TRS((Vector3)Handles.matrix.GetColumn(3) + center, Quaternion.identity, Vector3.one)))

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

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,12 +1233,16 @@ static void FixSeams(NativeArray<int> positionRemap, NativeArray<Vector3> positi
12331233
// The idea is to find first them and do a kind of dilation to smooth the values on the boundary
12341234
// the dilation process consits in doing a trilinear sample of the higher subdivision brick and override the lower subdiv with that
12351235
// We have to mark the probes on the boundary as valid otherwise leak reduction at runtime will interfere with this method
1236-
// This isn't perfect and also doesn't work on cell boundary, but could easily be fix if it's an issue
1237-
12381236

1237+
12391238
// Use an indirection structure to ensure mem usage stays reasonable
12401239
VoxelToBrickCache cache = new VoxelToBrickCache();
12411240

1241+
// Create a map from cell position to index for fast lookup across cells
1242+
var cellPositionToIndex = new Dictionary<Vector3Int, int>();
1243+
for (int i = 0; i < m_BakingBatch.cells.Count; i++)
1244+
cellPositionToIndex[m_BakingBatch.cells[i].position] = i;
1245+
12421246
for (int c = 0; c < m_BakingBatch.cells.Count; c++)
12431247
{
12441248
var cell = m_BakingBatch.cells[c];
@@ -1265,7 +1269,32 @@ static void FixSeams(NativeArray<int> positionRemap, NativeArray<Vector3> positi
12651269
Vector3Int voxel = Vector3Int.FloorToInt((pos - sampleOffset) / minBrickSize);
12661270
int hashCode = m_BakingBatch.GetBrickPositionHash(voxel);
12671271
if (!voxelToBrick.TryGetValue(hashCode, out var brick))
1268-
continue;
1272+
{
1273+
// If the brick was not found in the current cell, find it in the neighbouring cells
1274+
Vector3Int GetCellPositionFromVoxel(Vector3Int voxelToLookup, int cellSizeInBricks)
1275+
{
1276+
return new Vector3Int(
1277+
FloorDivide(voxelToLookup.x, cellSizeInBricks),
1278+
FloorDivide(voxelToLookup.y, cellSizeInBricks),
1279+
FloorDivide(voxelToLookup.z, cellSizeInBricks)
1280+
);
1281+
int FloorDivide(int a, int b) => a >= 0 ? a / b : (a - b + 1) / b;
1282+
}
1283+
1284+
// Find the position of the neighbouring cell that would contain the voxel
1285+
bool foundInOtherCell = false;
1286+
var cellToLookupPos = GetCellPositionFromVoxel(voxel, m_ProfileInfo.cellSizeInBricks);
1287+
if(cellPositionToIndex.TryGetValue(cellToLookupPos, out var cellIndex))
1288+
{
1289+
var currentCell = m_BakingBatch.cells[cellIndex];
1290+
var voxelToBrickNeighbouringCell = cache.GetMap(currentCell);
1291+
if (voxelToBrickNeighbouringCell.TryGetValue(hashCode, out brick))
1292+
foundInOtherCell = true;
1293+
}
1294+
1295+
if(!foundInOtherCell)
1296+
continue;
1297+
}
12691298

12701299
if (brick.subdivisionLevel > maxSubdiv)
12711300
largestBrick = brick;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,8 @@ void UseTemporaryBakingSet(string sceneGUID, ProbeVolumeBakingSet set = null)
490490
{
491491
set = ScriptableObject.CreateInstance<ProbeVolumeBakingSet>();
492492
set.SetDefaults();
493+
494+
ProbeReferenceVolume.instance.AddPendingSceneRemoval(sceneGUID);
493495
}
494496

495497
EditorUtility.SetDirty(set);

Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeSubdivide.compute

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ void JumpFlooding(uint3 id : SV_DispatchThreadID)
129129
o.x += (o.x < 0) ? _Size.x : 0;
130130
o.y += (o.y < 0) ? _Size.x : 0;
131131
o.z += (o.z < 0) ? _Size.x : 0;
132-
float4 n1 = _Output[o];
132+
float4 n1 = _Input[o];
133133

134134
// Discard invalid samples
135135
if (n1.w < 0.5)

Packages/com.unity.render-pipelines.core/Editor/Material/MaterialEditorExtension.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ static Rect GetRect(MaterialProperty prop)
8080
public static void IntShaderProperty(this MaterialEditor editor, MaterialProperty prop, GUIContent label, System.Func<int, int> transform = null)
8181
{
8282
MaterialEditor.BeginProperty(prop);
83+
editor.BeginAnimatedCheck(prop);
8384

8485
EditorGUI.BeginChangeCheck();
8586
EditorGUI.showMixedValue = prop.hasMixedValue;
@@ -92,6 +93,7 @@ public static void IntShaderProperty(this MaterialEditor editor, MaterialPropert
9293
prop.floatValue = newValue;
9394
}
9495

96+
editor.EndAnimatedCheck();
9597
MaterialEditor.EndProperty();
9698
}
9799

@@ -118,6 +120,7 @@ public static void IntSliderShaderProperty(this MaterialEditor editor, MaterialP
118120
public static void IntSliderShaderProperty(this MaterialEditor editor, MaterialProperty prop, int min, int max, GUIContent label)
119121
{
120122
MaterialEditor.BeginProperty(prop);
123+
editor.BeginAnimatedCheck(prop);
121124

122125
EditorGUI.BeginChangeCheck();
123126
EditorGUI.showMixedValue = prop.hasMixedValue;
@@ -129,6 +132,7 @@ public static void IntSliderShaderProperty(this MaterialEditor editor, MaterialP
129132
prop.floatValue = newValue;
130133
}
131134

135+
editor.EndAnimatedCheck();
132136
MaterialEditor.EndProperty();
133137
}
134138

@@ -142,6 +146,7 @@ public static void IntSliderShaderProperty(this MaterialEditor editor, MaterialP
142146
public static void MinFloatShaderProperty(this MaterialEditor editor, MaterialProperty prop, GUIContent label, float min)
143147
{
144148
MaterialEditor.BeginProperty(prop);
149+
editor.BeginAnimatedCheck(prop);
145150

146151
EditorGUI.BeginChangeCheck();
147152
EditorGUI.showMixedValue = prop.hasMixedValue;
@@ -151,6 +156,7 @@ public static void MinFloatShaderProperty(this MaterialEditor editor, MaterialPr
151156
if (EditorGUI.EndChangeCheck())
152157
prop.floatValue = newValue;
153158

159+
editor.EndAnimatedCheck();
154160
MaterialEditor.EndProperty();
155161
}
156162

@@ -163,6 +169,7 @@ public static void MinFloatShaderProperty(this MaterialEditor editor, MaterialPr
163169
public static void Vector3ShaderProperty(this MaterialEditor editor, MaterialProperty prop, GUIContent label)
164170
{
165171
MaterialEditor.BeginProperty(prop);
172+
editor.BeginAnimatedCheck(prop);
166173

167174
EditorGUI.BeginChangeCheck();
168175
EditorGUI.showMixedValue = prop.hasMixedValue;
@@ -171,6 +178,7 @@ public static void Vector3ShaderProperty(this MaterialEditor editor, MaterialPro
171178
if (EditorGUI.EndChangeCheck())
172179
prop.vectorValue = vector;
173180

181+
editor.EndAnimatedCheck();
174182
MaterialEditor.EndProperty();
175183
}
176184

@@ -185,6 +193,7 @@ public static void Vector3ShaderProperty(this MaterialEditor editor, MaterialPro
185193
public static int PopupShaderProperty(this MaterialEditor editor, MaterialProperty prop, GUIContent label, string[] displayedOptions)
186194
{
187195
MaterialEditor.BeginProperty(prop);
196+
editor.BeginAnimatedCheck(prop);
188197

189198
int val = (int)prop.floatValue;
190199

@@ -198,6 +207,7 @@ public static int PopupShaderProperty(this MaterialEditor editor, MaterialProper
198207
prop.floatValue = val = newValue;
199208
}
200209

210+
editor.EndAnimatedCheck();
201211
MaterialEditor.EndProperty();
202212

203213
return val;
@@ -215,6 +225,7 @@ public static int PopupShaderProperty(this MaterialEditor editor, MaterialProper
215225
public static int IntPopupShaderProperty(this MaterialEditor editor, MaterialProperty prop, string label, string[] displayedOptions, int[] optionValues)
216226
{
217227
MaterialEditor.BeginProperty(prop);
228+
editor.BeginAnimatedCheck(prop);
218229

219230
int val = (int)prop.floatValue;
220231

@@ -228,6 +239,7 @@ public static int IntPopupShaderProperty(this MaterialEditor editor, MaterialPro
228239
prop.floatValue = val = newValue;
229240
}
230241

242+
editor.EndAnimatedCheck();
231243
MaterialEditor.EndProperty();
232244

233245
return val;
@@ -246,6 +258,8 @@ public static void MinMaxShaderProperty(this MaterialEditor editor, MaterialProp
246258
{
247259
MaterialEditor.BeginProperty(min);
248260
MaterialEditor.BeginProperty(max);
261+
editor.BeginAnimatedCheck(min);
262+
editor.BeginAnimatedCheck(max);
249263

250264
float minValue = min.floatValue;
251265
float maxValue = max.floatValue;
@@ -257,6 +271,8 @@ public static void MinMaxShaderProperty(this MaterialEditor editor, MaterialProp
257271
max.floatValue = maxValue;
258272
}
259273

274+
editor.EndAnimatedCheck();
275+
editor.EndAnimatedCheck();
260276
MaterialEditor.EndProperty();
261277
MaterialEditor.EndProperty();
262278
}
@@ -272,6 +288,7 @@ public static void MinMaxShaderProperty(this MaterialEditor editor, MaterialProp
272288
public static void MinMaxShaderProperty(this MaterialEditor editor, MaterialProperty remapProp, float minLimit, float maxLimit, GUIContent label)
273289
{
274290
MaterialEditor.BeginProperty(remapProp);
291+
editor.BeginAnimatedCheck(remapProp);
275292

276293
Vector2 remap = remapProp.vectorValue;
277294

@@ -280,6 +297,7 @@ public static void MinMaxShaderProperty(this MaterialEditor editor, MaterialProp
280297
if (EditorGUI.EndChangeCheck())
281298
remapProp.vectorValue = remap;
282299

300+
editor.EndAnimatedCheck();
283301
MaterialEditor.EndProperty();
284302
}
285303
#endregion

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

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using UnityEngine;
33
using System;
44
using UnityEngine.Rendering;
5+
using System.Text;
56

67
namespace UnityEditor.Rendering
78
{
@@ -64,7 +65,6 @@ public string NewShaderPath
6465
List<string> m_TexturesToRemove = new List<string>();
6566
Dictionary<string, Texture> m_TexturesToSet = new Dictionary<string, Texture>();
6667

67-
6868
class KeywordFloatRename
6969
{
7070
public string keyword;
@@ -357,6 +357,72 @@ static bool ShouldUpgradeShader(Material material, HashSet<string> shaderNamesTo
357357
return !shaderNamesToIgnore.Contains(material.shader.name);
358358
}
359359

360+
/// <summary>
361+
/// Check if the materials in the list are variants of upgradable materials, and logs a infomative message to the user..
362+
/// </summary>
363+
/// <param name="materialGUIDs">Array of materials GUIDs.</param>
364+
/// <param name="upgraders">List or available upgraders.</param>
365+
static void LogMaterialVariantMessage(string[] materialGUIDs, List<MaterialUpgrader> upgraders)
366+
{
367+
List<Material> materials = new List<Material>();
368+
foreach (var guid in materialGUIDs)
369+
materials.Add(AssetDatabase.LoadAssetAtPath<Material>(AssetDatabase.GUIDToAssetPath(guid)));
370+
371+
LogMaterialVariantMessage(materials, upgraders);
372+
}
373+
374+
/// <summary>
375+
/// Check if the materials in the list are variants of upgradable materials, and logs a infomative message to the user..
376+
/// </summary>
377+
/// <param name="objects">Array of objects.</param>
378+
/// <param name="upgraders">List or available upgraders.</param>
379+
static void LogMaterialVariantMessage(UnityEngine.Object[] objects, List<MaterialUpgrader> upgraders)
380+
{
381+
Material mat;
382+
List<Material> materials = new List<Material>();
383+
for (int i = 0; i<objects.Length; i++)
384+
{
385+
mat = objects[i] as Material;
386+
if (mat != null)
387+
materials.Add(mat);
388+
}
389+
390+
LogMaterialVariantMessage(materials, upgraders);
391+
}
392+
393+
/// <summary>
394+
/// Check if the materials in the list are variants of upgradable materials, and logs a infomative message to the user..
395+
/// </summary>
396+
/// <param name="materials">List of materials.</param>
397+
/// <param name="upgraders">List or available upgraders.</param>
398+
static void LogMaterialVariantMessage(List<Material> materials, List<MaterialUpgrader> upgraders)
399+
{
400+
StringBuilder sb = new StringBuilder();
401+
sb.AppendLine("Can not upgrade Material Variants, the following assets were skipped:");
402+
bool needsLogging = false;
403+
404+
Material rootMaterial;
405+
406+
foreach (Material material in materials)
407+
{
408+
if (material.isVariant)
409+
{
410+
rootMaterial = material;
411+
while (rootMaterial.isVariant)
412+
rootMaterial = rootMaterial.parent;
413+
414+
if (GetUpgrader(upgraders, rootMaterial) != null)
415+
{
416+
needsLogging = true;
417+
sb.AppendLine($"- <a href=\"{AssetDatabase.GetAssetPath(material)}\" >{material.name}</a>, variant of {material.parent.name} with shader {rootMaterial.shader.name}.");
418+
}
419+
}
420+
}
421+
422+
if (needsLogging)
423+
Debug.Log(sb.ToString(), null);
424+
}
425+
360426

361427
private static bool IsNotAutomaticallyUpgradable(List<MaterialUpgrader> upgraders, Material material)
362428
{
@@ -407,6 +473,8 @@ public static void UpgradeProjectFolder(List<MaterialUpgrader> upgraders, HashSe
407473
var materialAssets = AssetDatabase.FindAssets($"t:{nameof(Material)} glob:\"**/*.mat\"");
408474
int materialIndex = 0;
409475

476+
LogMaterialVariantMessage(materialAssets, upgraders);
477+
410478
foreach (var guid in materialAssets)
411479
{
412480
Material material = AssetDatabase.LoadAssetAtPath<Material>(AssetDatabase.GUIDToAssetPath(guid));
@@ -417,6 +485,9 @@ public static void UpgradeProjectFolder(List<MaterialUpgrader> upgraders, HashSe
417485
if (!ShouldUpgradeShader(material, shaderNamesToIgnore))
418486
continue;
419487

488+
if (material.isVariant)
489+
continue;
490+
420491
Upgrade(material, upgraders, flags);
421492

422493
}
@@ -524,10 +595,13 @@ public static void UpgradeSelection(List<MaterialUpgrader> upgraders, HashSet<st
524595
}
525596

526597
List<Material> selectedMaterials = new List<Material>(selection.Length);
598+
599+
LogMaterialVariantMessage(selection, upgraders);
600+
527601
for (int i = 0; i < selection.Length; ++i)
528602
{
529603
Material mat = selection[i] as Material;
530-
if (mat != null)
604+
if (mat != null && !mat.isVariant)
531605
selectedMaterials.Add(mat);
532606
}
533607

Packages/com.unity.render-pipelines.core/Editor/PostProcessing/LensFlareDataSRPEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ void OnEnable()
174174

175175
if (m_PreviewTexture == null)
176176
{
177-
m_PreviewTexture = RTHandles.Alloc(Styles.thumbnailSizeWidth, Styles.thumbnailSizeHeight, colorFormat: UnityEngine.Experimental.Rendering.GraphicsFormat.R8G8B8A8_SRGB);
177+
m_PreviewTexture = RTHandles.Alloc(Styles.thumbnailSizeWidth, Styles.thumbnailSizeHeight, UnityEngine.Experimental.Rendering.GraphicsFormat.R8G8B8A8_SRGB);
178178
}
179179
if (m_PreviewTextureCache == null)
180180
{

0 commit comments

Comments
 (0)