-
Notifications
You must be signed in to change notification settings - Fork 867
Expand file tree
/
Copy pathProbeVolumeSceneData.cs
More file actions
596 lines (503 loc) · 25.1 KB
/
ProbeVolumeSceneData.cs
File metadata and controls
596 lines (503 loc) · 25.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
using System.Linq;
using System.Reflection;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace UnityEngine.Rendering
{
// Add Profile and baking settings.
/// <summary> A class containing info about the bounds defined by the probe volumes in various scenes. </summary>
[System.Serializable]
public class ProbeVolumeSceneData : ISerializationCallbackReceiver
{
static PropertyInfo s_SceneGUID = typeof(Scene).GetProperty("guid", System.Reflection.BindingFlags.NonPublic | BindingFlags.Instance);
static internal string GetSceneGUID(Scene scene)
{
Debug.Assert(s_SceneGUID != null, "Reflection for scene GUID failed");
return (string)s_SceneGUID.GetValue(scene);
}
[System.Serializable]
struct SerializableBoundItem
{
[SerializeField] public string sceneGUID;
[SerializeField] public Bounds bounds;
}
[System.Serializable]
struct SerializableHasPVItem
{
[SerializeField] public string sceneGUID;
[SerializeField] public bool hasProbeVolumes;
}
[System.Serializable]
struct SerializablePVProfile
{
[SerializeField] public string sceneGUID;
[SerializeField] public ProbeReferenceVolumeProfile profile;
}
[System.Serializable]
struct SerializablePVBakeSettings
{
public string sceneGUID;
public ProbeVolumeBakingProcessSettings settings;
}
[System.Serializable]
internal class BakingSet
{
public string name;
public List<string> sceneGUIDs = new List<string>();
public ProbeVolumeBakingProcessSettings settings;
public ProbeReferenceVolumeProfile profile;
public List<string> lightingScenarios = new List<string>();
internal string CreateScenario(string name)
{
if (lightingScenarios.Contains(name))
{
string renamed;
int index = 1;
do
renamed = $"{name} ({index++})";
while (lightingScenarios.Contains(renamed));
name = renamed;
}
lightingScenarios.Add(name);
return name;
}
internal bool RemoveScenario(string name)
{
return lightingScenarios.Remove(name);
}
}
[SerializeField] List<SerializableBoundItem> serializedBounds;
[SerializeField] List<SerializableHasPVItem> serializedHasVolumes;
[SerializeField] List<SerializablePVProfile> serializedProfiles;
[SerializeField] List<SerializablePVBakeSettings> serializedBakeSettings;
[SerializeField] List<BakingSet> serializedBakingSets;
internal Object parentAsset = null;
internal string parentSceneDataPropertyName;
/// <summary> A dictionary containing the Bounds defined by probe volumes for each scene (scene path is the key of the dictionary). </summary>
public Dictionary<string, Bounds> sceneBounds;
internal Dictionary<string, bool> hasProbeVolumes;
internal Dictionary<string, ProbeReferenceVolumeProfile> sceneProfiles;
internal Dictionary<string, ProbeVolumeBakingProcessSettings> sceneBakingSettings;
internal List<BakingSet> bakingSets;
[SerializeField] string m_LightingScenario = ProbeReferenceVolume.defaultLightingScenario;
string m_OtherScenario = null;
float m_ScenarioBlendingFactor = 0.0f;
internal string lightingScenario => m_LightingScenario;
internal string otherScenario => m_OtherScenario;
internal float scenarioBlendingFactor => m_ScenarioBlendingFactor;
internal void SetActiveScenario(string scenario)
{
if (m_LightingScenario == scenario && m_ScenarioBlendingFactor == 0.0f)
return;
m_LightingScenario = scenario;
m_OtherScenario = null;
m_ScenarioBlendingFactor = 0.0f;
foreach (var data in ProbeReferenceVolume.instance.perSceneDataList)
data.UpdateActiveScenario(m_LightingScenario, m_OtherScenario);
if (ProbeReferenceVolume.instance.enableScenarioBlending)
{
// Trigger blending system to replace old cells with the one from the new active scenario.
// Although we technically don't need blending for that, it is better than unloading all cells
// because it will replace them progressively. There is no real performance cost to using blending
// rather than regular load thanks to the bypassBlending branch in AddBlendingBricks.
ProbeReferenceVolume.instance.ScenarioBlendingChanged(true);
}
else
ProbeReferenceVolume.instance.UnloadAllCells();
}
internal void BlendLightingScenario(string otherScenario, float blendingFactor)
{
if (!ProbeReferenceVolume.instance.enableScenarioBlending)
{
if (!ProbeBrickBlendingPool.isSupported)
Debug.LogError("Blending between lighting scenarios is not supported by this render pipeline.");
else
Debug.LogError("Blending between lighting scenarios is disabled in the render pipeline settings.");
return;
}
blendingFactor = Mathf.Clamp01(blendingFactor);
if (otherScenario == m_LightingScenario || string.IsNullOrEmpty(otherScenario))
otherScenario = null;
if (otherScenario == null)
blendingFactor = 0.0f;
if (otherScenario == m_OtherScenario && Mathf.Approximately(blendingFactor, m_ScenarioBlendingFactor))
return;
bool scenarioChanged = otherScenario != m_OtherScenario;
m_OtherScenario = otherScenario;
m_ScenarioBlendingFactor = blendingFactor;
if (scenarioChanged)
{
foreach (var data in ProbeReferenceVolume.instance.perSceneDataList)
data.UpdateActiveScenario(m_LightingScenario, m_OtherScenario);
}
ProbeReferenceVolume.instance.ScenarioBlendingChanged(scenarioChanged);
}
/// <summary>
/// Constructor for ProbeVolumeSceneData.
/// </summary>
/// <param name="parentAsset">The asset holding this ProbeVolumeSceneData, it will be dirtied every time scene bounds or settings are changed.</param>
/// <param name="parentSceneDataPropertyName">The name of the property holding the ProbeVolumeSceneData in the parentAsset.</param>
public ProbeVolumeSceneData(Object parentAsset, string parentSceneDataPropertyName)
{
this.parentAsset = parentAsset;
this.parentSceneDataPropertyName = parentSceneDataPropertyName;
sceneBounds = new Dictionary<string, Bounds>();
hasProbeVolumes = new Dictionary<string, bool>();
sceneProfiles = new Dictionary<string, ProbeReferenceVolumeProfile>();
sceneBakingSettings = new Dictionary<string, ProbeVolumeBakingProcessSettings>();
bakingSets = new List<BakingSet>();
serializedBounds = new List<SerializableBoundItem>();
serializedHasVolumes = new List<SerializableHasPVItem>();
serializedProfiles = new List<SerializablePVProfile>();
serializedBakeSettings = new List<SerializablePVBakeSettings>();
UpdateBakingSets();
}
/// <summary>Set a reference to the object holding this ProbeVolumeSceneData.</summary>
/// <param name="parent">The object holding this ProbeVolumeSceneData, it will be dirtied every time scene bounds or settings are changed. </param>
/// <param name="parentSceneDataPropertyName">The name of the property holding the ProbeVolumeSceneData in the parentAsset.</param>
public void SetParentObject(Object parent, string parentSceneDataPropertyName)
{
parentAsset = parent;
this.parentSceneDataPropertyName = parentSceneDataPropertyName;
UpdateBakingSets();
}
/// <summary>
/// OnAfterDeserialize implementation.
/// </summary>
public void OnAfterDeserialize()
{
// We haven't initialized the bounds, no need to do anything here.
if (serializedBounds == null || serializedHasVolumes == null ||
serializedProfiles == null || serializedBakeSettings == null) return;
sceneBounds = new Dictionary<string, Bounds>();
hasProbeVolumes = new Dictionary<string, bool>();
sceneProfiles = new Dictionary<string, ProbeReferenceVolumeProfile>();
sceneBakingSettings = new Dictionary<string, ProbeVolumeBakingProcessSettings>();
bakingSets = new List<BakingSet>();
foreach (var boundItem in serializedBounds)
{
sceneBounds.Add(boundItem.sceneGUID, boundItem.bounds);
}
foreach (var boundItem in serializedHasVolumes)
{
hasProbeVolumes.Add(boundItem.sceneGUID, boundItem.hasProbeVolumes);
}
foreach (var profileItem in serializedProfiles)
{
sceneProfiles.Add(profileItem.sceneGUID, profileItem.profile);
}
foreach (var settingsItem in serializedBakeSettings)
{
sceneBakingSettings.Add(settingsItem.sceneGUID, settingsItem.settings);
}
if (string.IsNullOrEmpty(m_LightingScenario))
m_LightingScenario = ProbeReferenceVolume.defaultLightingScenario;
foreach (var set in serializedBakingSets)
{
// Ensure baking set settings are up to date
set.settings.Upgrade();
bakingSets.Add(set);
}
if (m_OtherScenario == "")
m_OtherScenario = null;
}
// This function must not be called during the serialization (because of asset creation)
void UpdateBakingSets()
{
foreach (var set in serializedBakingSets)
{
// Small migration code to ensure that old sets have correct settings
if (set.profile == null)
InitializeBakingSet(set, set.name);
if (set.lightingScenarios.Count == 0)
InitializeScenarios(set);
}
// Initialize baking set in case it's empty:
if (bakingSets.Count == 0)
{
var set = CreateNewBakingSet("Default");
set.sceneGUIDs = serializedProfiles.Select(s => s.sceneGUID).ToList();
}
SyncBakingSetSettings();
}
/// <summary>
/// OnBeforeSerialize implementation.
/// </summary>
public void OnBeforeSerialize()
{
// We haven't initialized the bounds, no need to do anything here.
if (sceneBounds == null || hasProbeVolumes == null || sceneBakingSettings == null || sceneProfiles == null ||
serializedBounds == null || serializedHasVolumes == null || serializedBakeSettings == null || serializedProfiles == null
|| serializedBakingSets == null) return;
serializedBounds.Clear();
serializedHasVolumes.Clear();
serializedProfiles.Clear();
serializedBakeSettings.Clear();
serializedBakingSets.Clear();
foreach (var k in sceneBounds.Keys)
{
SerializableBoundItem item;
item.sceneGUID = k;
item.bounds = sceneBounds[k];
serializedBounds.Add(item);
}
foreach (var k in hasProbeVolumes.Keys)
{
SerializableHasPVItem item;
item.sceneGUID = k;
item.hasProbeVolumes = hasProbeVolumes[k];
serializedHasVolumes.Add(item);
}
foreach (var k in sceneBakingSettings.Keys)
{
SerializablePVBakeSettings item;
item.sceneGUID = k;
item.settings = sceneBakingSettings[k];
serializedBakeSettings.Add(item);
}
foreach (var k in sceneProfiles.Keys)
{
SerializablePVProfile item;
item.sceneGUID = k;
item.profile = sceneProfiles[k];
serializedProfiles.Add(item);
}
serializedBakingSets.AddRange(bakingSets);
}
internal BakingSet CreateNewBakingSet(string name)
{
BakingSet set = new BakingSet();
// Initialize new baking set settings
InitializeBakingSet(set, name);
bakingSets.Add(set);
return set;
}
void InitializeBakingSet(BakingSet set, string name)
{
var newProfile = ScriptableObject.CreateInstance<ProbeReferenceVolumeProfile>();
#if UNITY_EDITOR
ProjectWindowUtil.CreateAsset(newProfile, name + ".asset");
#endif
set.name = name;
set.profile = newProfile;
set.settings = ProbeVolumeBakingProcessSettings.Default;
InitializeScenarios(set);
}
void InitializeScenarios(BakingSet set)
{
set.lightingScenarios = new List<string>() { ProbeReferenceVolume.defaultLightingScenario };
}
internal void SyncBakingSetSettings()
{
// Sync all the scene settings in the set to avoid config mismatch.
foreach (var set in bakingSets)
{
foreach (var guid in set.sceneGUIDs)
{
sceneBakingSettings[guid] = set.settings;
sceneProfiles[guid] = set.profile;
}
}
}
#if UNITY_EDITOR
static internal int MaxSubdivLevelInProbeVolume(Vector3 volumeSize, int maxSubdiv)
{
float maxSizedDim = Mathf.Max(volumeSize.x, Mathf.Max(volumeSize.y, volumeSize.z));
float maxSideInBricks = maxSizedDim / ProbeReferenceVolume.instance.MinDistanceBetweenProbes();
int absoluteMaxSubdiv = ProbeReferenceVolume.instance.GetMaxSubdivision() - 1;
int subdivLevel = Mathf.FloorToInt(Mathf.Log(maxSideInBricks, 3)) - 1;
return Mathf.Max(subdivLevel, absoluteMaxSubdiv - maxSubdiv);
}
private void InflateBound(ref Bounds bounds, ProbeVolume pv)
{
Bounds originalBounds = bounds;
// Round the probe volume bounds to cell size
float cellSize = ProbeReferenceVolume.instance.MaxBrickSize();
// Expand the probe volume bounds to snap on the cell size grid
bounds.Encapsulate(new Vector3(cellSize * Mathf.Floor(bounds.min.x / cellSize),
cellSize * Mathf.Floor(bounds.min.y / cellSize),
cellSize * Mathf.Floor(bounds.min.z / cellSize)));
bounds.Encapsulate(new Vector3(cellSize * Mathf.Ceil(bounds.max.x / cellSize),
cellSize * Mathf.Ceil(bounds.max.y / cellSize),
cellSize * Mathf.Ceil(bounds.max.z / cellSize)));
// calculate how much padding we need to remove according to the brick generation in ProbePlacement.cs:
var cellSizeVector = new Vector3(cellSize, cellSize, cellSize);
var minPadding = (bounds.min - originalBounds.min);
var maxPadding = (bounds.max - originalBounds.max);
minPadding = cellSizeVector - new Vector3(Mathf.Abs(minPadding.x), Mathf.Abs(minPadding.y), Mathf.Abs(minPadding.z));
maxPadding = cellSizeVector - new Vector3(Mathf.Abs(maxPadding.x), Mathf.Abs(maxPadding.y), Mathf.Abs(maxPadding.z));
// Find the size of the brick we can put for every axis given the padding size
int maxSubdiv = (pv.overridesSubdivLevels ? pv.highestSubdivLevelOverride : 0);
float rightPaddingSubdivLevel = ProbeReferenceVolume.instance.BrickSize(MaxSubdivLevelInProbeVolume(new Vector3(maxPadding.x, originalBounds.size.y, originalBounds.size.z), maxSubdiv));
float leftPaddingSubdivLevel = ProbeReferenceVolume.instance.BrickSize(MaxSubdivLevelInProbeVolume(new Vector3(minPadding.x, originalBounds.size.y, originalBounds.size.z), maxSubdiv));
float topPaddingSubdivLevel = ProbeReferenceVolume.instance.BrickSize(MaxSubdivLevelInProbeVolume(new Vector3(originalBounds.size.x, maxPadding.y, originalBounds.size.z), maxSubdiv));
float bottomPaddingSubdivLevel = ProbeReferenceVolume.instance.BrickSize(MaxSubdivLevelInProbeVolume(new Vector3(originalBounds.size.x, minPadding.y, originalBounds.size.z), maxSubdiv));
float forwardPaddingSubdivLevel = ProbeReferenceVolume.instance.BrickSize(MaxSubdivLevelInProbeVolume(new Vector3(originalBounds.size.x, originalBounds.size.y, maxPadding.z), maxSubdiv));
float backPaddingSubdivLevel = ProbeReferenceVolume.instance.BrickSize(MaxSubdivLevelInProbeVolume(new Vector3(originalBounds.size.x, originalBounds.size.y, minPadding.z), maxSubdiv));
// Remove the extra padding caused by cell rounding
bounds.min = bounds.min + new Vector3(
leftPaddingSubdivLevel * Mathf.Floor(Mathf.Abs(bounds.min.x - originalBounds.min.x) / (float)leftPaddingSubdivLevel),
bottomPaddingSubdivLevel * Mathf.Floor(Mathf.Abs(bounds.min.y - originalBounds.min.y) / (float)bottomPaddingSubdivLevel),
backPaddingSubdivLevel * Mathf.Floor(Mathf.Abs(bounds.min.z - originalBounds.min.z) / (float)backPaddingSubdivLevel)
);
bounds.max = bounds.max - new Vector3(
rightPaddingSubdivLevel * Mathf.Floor(Mathf.Abs(bounds.max.x - originalBounds.max.x) / (float)rightPaddingSubdivLevel),
topPaddingSubdivLevel * Mathf.Floor(Mathf.Abs(bounds.max.y - originalBounds.max.y) / (float)topPaddingSubdivLevel),
forwardPaddingSubdivLevel * Mathf.Floor(Mathf.Abs(bounds.max.z - originalBounds.max.z) / (float)forwardPaddingSubdivLevel)
);
}
// Should be called after EnsureSceneIsInBakingSet otherwise GetProfileForScene might be out of date
internal void UpdateSceneBounds(Scene scene)
{
var volumes = Object.FindObjectsOfType<ProbeVolume>();
float prevBrickSize = ProbeReferenceVolume.instance.MinBrickSize();
int prevMaxSubdiv = ProbeReferenceVolume.instance.GetMaxSubdivision();
{
var profile = GetProfileForScene(scene);
if (profile == null)
{
if (volumes.Length > 0)
Debug.LogWarning("A probe volume is present in the scene but a profile has not been set. Please configure a profile for your scene in the Probe Volume Baking settings.");
return;
}
ProbeReferenceVolume.instance.SetMinBrickAndMaxSubdiv(profile.minBrickSize, profile.maxSubdivision);
}
var sceneGUID = GetSceneGUID(scene);
bool boundFound = false;
Bounds newBound = new Bounds();
foreach (var volume in volumes)
{
if (volume.gameObject.scene != scene)
continue;
if (volume.globalVolume)
volume.UpdateGlobalVolume();
var transform = volume.gameObject.transform;
var obb = new ProbeReferenceVolume.Volume(Matrix4x4.TRS(transform.position, transform.rotation, volume.GetExtents()), 0, 0);
Bounds localBounds = obb.CalculateAABB();
InflateBound(ref localBounds, volume);
if (!boundFound)
{
newBound = localBounds;
boundFound = true;
}
else
{
newBound.Encapsulate(localBounds);
}
}
hasProbeVolumes[sceneGUID] = boundFound;
if (boundFound)
sceneBounds[sceneGUID] = newBound;
ProbeReferenceVolume.instance.SetMinBrickAndMaxSubdiv(prevBrickSize, prevMaxSubdiv);
if (parentAsset != null)
EditorUtility.SetDirty(parentAsset);
}
// It is important this is called after UpdateSceneBounds is called otherwise SceneHasProbeVolumes might be out of date
internal void EnsurePerSceneData(Scene scene)
{
var sceneGUID = GetSceneGUID(scene);
if (SceneHasProbeVolumes(sceneGUID))
{
bool foundPerSceneData = false;
foreach (var data in ProbeReferenceVolume.instance.perSceneDataList)
{
if (GetSceneGUID(data.gameObject.scene) == sceneGUID)
{
foundPerSceneData = true;
break;
}
}
if (!foundPerSceneData)
{
GameObject go = new GameObject("ProbeVolumePerSceneData");
go.hideFlags |= HideFlags.HideInHierarchy;
go.AddComponent<ProbeVolumePerSceneData>();
SceneManager.MoveGameObjectToScene(go, scene);
}
}
}
internal void EnsureSceneIsInBakingSet(Scene scene)
{
var sceneGUID = GetSceneGUID(scene);
foreach (var set in bakingSets)
if (set.sceneGUIDs.Contains(sceneGUID))
return;
// The scene is not in a baking set, we need to add it
if (bakingSets.Count == 0)
return; // Technically shouldn't be possible since it's blocked in the UI
bakingSets[0].sceneGUIDs.Add(sceneGUID);
SyncBakingSetSettings();
}
internal string GetFirstProbeVolumeSceneGUID(ProbeVolumeSceneData.BakingSet set)
{
foreach (var guid in set.sceneGUIDs)
{
if (sceneBakingSettings.ContainsKey(guid) && sceneProfiles.ContainsKey(guid))
return guid;
}
return null;
}
internal void OnSceneSaved(Scene scene)
{
EnsureSceneIsInBakingSet(scene);
UpdateSceneBounds(scene);
EnsurePerSceneData(scene);
}
internal void SetProfileForScene(Scene scene, ProbeReferenceVolumeProfile profile)
{
if (sceneProfiles == null) sceneProfiles = new Dictionary<string, ProbeReferenceVolumeProfile>();
var sceneGUID = GetSceneGUID(scene);
sceneProfiles[sceneGUID] = profile;
}
internal void SetProfileForScene(string sceneGUID, ProbeReferenceVolumeProfile profile)
{
if (sceneProfiles == null) sceneProfiles = new Dictionary<string, ProbeReferenceVolumeProfile>();
sceneProfiles[sceneGUID] = profile;
}
internal void SetBakeSettingsForScene(Scene scene, ProbeDilationSettings dilationSettings, VirtualOffsetSettings virtualOffsetSettings)
{
if (sceneBakingSettings == null) sceneBakingSettings = new Dictionary<string, ProbeVolumeBakingProcessSettings>();
var sceneGUID = GetSceneGUID(scene);
sceneBakingSettings[sceneGUID] = new ProbeVolumeBakingProcessSettings(dilationSettings, virtualOffsetSettings);
}
internal ProbeReferenceVolumeProfile GetProfileForScene(Scene scene)
{
var sceneGUID = GetSceneGUID(scene);
if (sceneProfiles != null && sceneProfiles.ContainsKey(sceneGUID))
return sceneProfiles[sceneGUID];
return null;
}
internal bool BakeSettingsDefinedForScene(Scene scene)
{
var sceneGUID = GetSceneGUID(scene);
return sceneBakingSettings.ContainsKey(sceneGUID);
}
internal ProbeVolumeBakingProcessSettings GetBakeSettingsForScene(Scene scene)
{
var sceneGUID = GetSceneGUID(scene);
if (sceneBakingSettings != null && sceneBakingSettings.ContainsKey(sceneGUID))
return sceneBakingSettings[sceneGUID];
return ProbeVolumeBakingProcessSettings.Default;
}
// This is sub-optimal, but because is called once when kicking off a bake
internal BakingSet GetBakingSetForScene(Scene scene)
{
var sceneGUID = GetSceneGUID(scene);
foreach (var set in bakingSets)
{
foreach (var guidInSet in set.sceneGUIDs)
{
if (guidInSet == sceneGUID)
return set;
}
}
return null;
}
internal bool SceneHasProbeVolumes(string sceneGUID) => hasProbeVolumes != null && hasProbeVolumes.TryGetValue(sceneGUID, out var hasPV) && hasPV;
internal bool SceneHasProbeVolumes(Scene scene) => SceneHasProbeVolumes(GetSceneGUID(scene));
#endif
}
}