Skip to content

Commit 3d8ba58

Browse files
adrien-de-tocquevilleEvergreen
authored andcommitted
[APV] Fixes and documentation
- Add missing APIs requested by users: - get baking set for scene - load baking set for scene - trigger APV bake from script - Fix warning when baking dilation on URP - Fix missing wait on opencl buffer upload - Added Validity Based leak reduction mode to fix sampling artefacts - Fixed blending section in rendering debugger Update Documentation - Renamed 'Probe Volume' -> 'Adaptive Probe Volumes' - Added page for documenting the various APIs
1 parent 5e10a43 commit 3d8ba58

34 files changed

+448
-302
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ static void PerformDilation(ProbeReferenceVolume.Cell cell, ProbeVolumeBakingSet
318318
cmd.SetGlobalTexture(ProbeReferenceVolume.ShaderIDs._APVResL2_2, rr.L2_2);
319319
cmd.SetGlobalTexture(ProbeReferenceVolume.ShaderIDs._APVResL2_3, rr.L2_3);
320320

321-
cmd.SetComputeTextureParam(dilationShader, dilationKernel, ProbeReferenceVolume.ShaderIDs._SkyOcclusionTexL0L1, rr.SkyOcclusionL0L1 ?? (RenderTargetIdentifier)TextureXR.GetBlackTexture3D());
322-
cmd.SetComputeTextureParam(dilationShader, dilationKernel, ProbeReferenceVolume.ShaderIDs._SkyShadingDirectionIndicesTex, rr.SkyShadingDirectionIndices ?? (RenderTargetIdentifier)TextureXR.GetBlackTexture3D());
321+
cmd.SetComputeTextureParam(dilationShader, dilationKernel, ProbeReferenceVolume.ShaderIDs._SkyOcclusionTexL0L1, rr.SkyOcclusionL0L1 ?? (RenderTargetIdentifier)CoreUtils.blackVolumeTexture);
322+
cmd.SetComputeTextureParam(dilationShader, dilationKernel, ProbeReferenceVolume.ShaderIDs._SkyShadingDirectionIndicesTex, rr.SkyShadingDirectionIndices ?? (RenderTargetIdentifier)CoreUtils.blackVolumeTexture);
323323
cmd.SetComputeBufferParam(dilationShader, dilationKernel, ProbeReferenceVolume.ShaderIDs._SkyPrecomputedDirections, rr.SkyPrecomputedDirections);
324324
}
325325

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#ifndef PROBEGIBAKING_DILATE_CS_HLSL
66
#define PROBEGIBAKING_DILATE_CS_HLSL
7-
// Generated from UnityEngine.Rendering.ProbeGIBaking+DilatedProbe
7+
// Generated from UnityEngine.Rendering.AdaptiveProbeVolumes+DilatedProbe
88
// PackingRules = Exact
99
struct DilatedProbe
1010
{

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ public static BakeContext New(InputExtraction.BakeInput input, NativeArray<Vecto
286286

287287
// Upload probe positions
288288
var positionsSlice = new BufferSlice<Vector3>(ctx.positionsBufferID, 0);
289-
ctx.ctx.WriteBuffer(positionsSlice, probePositions);
289+
var writeEvent = ctx.ctx.WriteBuffer(positionsSlice, probePositions);
290+
ctx.ctx.Wait(writeEvent);
290291

291292
return ctx;
292293
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static internal bool CanFreezePlacement()
120120

121121
foreach (var sceneData in sceneDataList)
122122
{
123-
if (sceneData.bakingSet == null || sceneData.bakingSet.GetSceneCellIndexList(sceneData.sceneGUID) == null)
123+
if (sceneData.serializedBakingSet == null || sceneData.serializedBakingSet.GetSceneCellIndexList(sceneData.sceneGUID) == null)
124124
return false;
125125
}
126126

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ static void GenerateScenesCellLists(List<ProbeVolumePerSceneData> bakedSceneData
134134
Debug.Assert(ProbeVolumeBakingSet.SceneHasProbeVolumes(data.sceneGUID));
135135
bakedSceneGUIDList.Add(data.sceneGUID);
136136

137-
if (m_BakingSet != data.bakingSet)
137+
if (m_BakingSet != data.serializedBakingSet)
138138
{
139-
data.bakingSet = m_BakingSet;
139+
data.serializedBakingSet = m_BakingSet;
140140
EditorUtility.SetDirty(data);
141141
}
142142
}
@@ -194,7 +194,7 @@ static void PrepareCellsForWriting(bool isBakingSubset)
194194
// Remap if needed existing Cell descriptors in the baking set.
195195
var cellRemapTable = RemapBakedCells(isBakingSubset);
196196

197-
// Generate list of cells for all cells being baked and remap untouched existing scenes if needed.
197+
// Generate list of cells for all scenes being baked and remap untouched existing scenes if needed.
198198
GenerateScenesCellLists(GetPerSceneDataList(), cellRemapTable);
199199

200200
if (isBakingSubset)
@@ -207,8 +207,8 @@ static void PrepareCellsForWriting(bool isBakingSubset)
207207
// If a scene was baked
208208
if (m_BakingSet.perSceneCellLists.TryGetValue(sceneGUID, out var cellList))
209209
{
210-
// And the scene is not loaded
211-
if (!loadedSceneDataList.Exists((x) => x.sceneGUID == sceneGUID) && cellList.Count != 0)
210+
// And the scene is not in the baked subset
211+
if (cellList.Count != 0 && !partialBakeSceneList.Contains(sceneGUID))
212212
{
213213
// Resolve its data in CPU memory.
214214
bool resolved = m_BakingSet.ResolveCellData(cellList);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ static internal void RecomputeVOForDebugOnly()
362362

363363
foreach (var sceneData in prv.perSceneDataList)
364364
{
365-
prv.AddPendingSceneLoading(sceneData.sceneGUID, sceneData.bakingSet);
365+
prv.AddPendingSceneLoading(sceneData.sceneGUID, sceneData.serializedBakingSet);
366366
}
367367

368368
prv.PerformPendingOperations();

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ static void CellCountInDirections(out Vector3Int minCellPositionXYZ, out Vector3
785785
{
786786
minCellPositionXYZ = Vector3Int.zero;
787787
maxCellPositionXYZ = Vector3Int.zero;
788-
788+
789789
var centeredMin = globalBounds.min - worldOffset;
790790
var centeredMax = globalBounds.max - worldOffset;
791791

@@ -928,7 +928,7 @@ static bool InitializeBake()
928928
foreach (var data in ProbeReferenceVolume.instance.perSceneDataList)
929929
{
930930
// It can be null if the scene was never added to a baking set and we are baking in single scene mode, in that case we don't have a baking set for it yet and we need to skip
931-
if (data.bakingSet != null)
931+
if (data.serializedBakingSet != null)
932932
data.Initialize();
933933
}
934934

@@ -1179,7 +1179,7 @@ internal static void AsyncBakeCallback()
11791179
/// Starts an asynchronous bake job for Adaptive Probe Volumes.
11801180
/// </summary>
11811181
/// <returns>Returns true if the bake was successfully started.</returns>
1182-
internal static bool BakeAsync()
1182+
public static bool BakeAsync()
11831183
{
11841184
if (Lightmapping.isRunning || AdaptiveProbeVolumes.isRunning || !PrepareBaking())
11851185
return false;
@@ -1200,13 +1200,13 @@ internal static bool BakeAsync()
12001200
/// <summary>
12011201
/// Returns true when the bake job is running, false otherwise (Read Only).
12021202
/// </summary>
1203-
internal static bool isRunning => s_AsyncBakeTaskID != -1;
1203+
public static bool isRunning => s_AsyncBakeTaskID != -1;
12041204

12051205
/// <summary>
12061206
/// Cancels the currently running asynchronous bake job.
12071207
/// </summary>
1208-
/// <returns></returns>
1209-
internal static bool Cancel() => Progress.Cancel(s_AsyncBakeTaskID);
1208+
/// <returns>Returns true if baking was successfully cancelled.</returns>
1209+
public static bool Cancel() => Progress.Cancel(s_AsyncBakeTaskID);
12101210

12111211
/// <summary>
12121212
/// Request additional bake request manager to recompute baked data for an array of requests
@@ -1252,7 +1252,7 @@ public static void BakeAdditionalRequest(int probeInstanceID)
12521252

12531253
BakeAdditionalRequests(probeInstanceIDs);
12541254
}
1255-
1255+
12561256
static VirtualOffsetBaker virtualOffsetOverride = null;
12571257
static LightingBaker lightingOverride = null;
12581258
static SkyOcclusionBaker skyOcclusionOverride = null;
@@ -1263,26 +1263,26 @@ public static void SetVirtualOffsetBakerOverride(VirtualOffsetBaker baker)
12631263
{
12641264
virtualOffsetOverride = baker;
12651265
}
1266-
/// <summary>Used to override the sky occlusion baking system.</summary>
1266+
/// <summary>Used to override the lighting baking system.</summary>
12671267
/// <param name="baker">The baker override or null to use the default system.</param>
12681268
public static void SetLightingBakerOverride(LightingBaker baker)
12691269
{
12701270
lightingOverride = baker;
12711271
}
1272-
/// <summary>Used to override the probe volume light baking system.</summary>
1272+
/// <summary>Used to override the sky occlusion baking system.</summary>
12731273
/// <param name="baker">The baker override or null to use the default system.</param>
12741274
public static void SetSkyOcclusionBakerOverride(SkyOcclusionBaker baker)
12751275
{
12761276
skyOcclusionOverride = baker;
12771277
}
1278-
1278+
12791279
/// <summary>Used to override the virtual offset baking system.</summary>
12801280
/// <returns>The baker override or null if none is set.</returns>
12811281
public static VirtualOffsetBaker GetVirtualOffsetBakerOverride()
12821282
{
12831283
return virtualOffsetOverride;
12841284
}
1285-
/// <summary>Used to override the virtual offset baking system.</summary>
1285+
/// <summary>Used to override the lighting baking system.</summary>
12861286
/// <returns>The baker override or null if none is set.</returns>
12871287
public static LightingBaker GetLightingBakerOverride()
12881288
{

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ ProbeVolumeBakingSet CreateBakingSet()
539539

540540
void CreateProbeVolume()
541541
{
542-
var probeVolume = CoreEditorUtils.CreateGameObject(null, "Probe Volume");
542+
var probeVolume = CoreEditorUtils.CreateGameObject(null, "Adaptive Probe Volume");
543543
var pv = probeVolume.AddComponent<ProbeVolume>();
544544
pv.mode = ProbeVolume.Mode.Scene;
545545
EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
@@ -957,8 +957,8 @@ internal bool PrepareAPVBake()
957957
{
958958
if(!activeSet.DialogNoProbeVolumeInSetShown())
959959
{
960-
if(EditorUtility.DisplayDialog("No Probe Volume in Scene", "Adaptive Probe Volumes are enabled for this Project, but none exist in the Scene.\n\n" +
961-
"Do you wish to add a Probe Volume to the Active Scene?", "Yes", "No"))
960+
if(EditorUtility.DisplayDialog("No Adaptive Probe Volume in Scene", "Adaptive Probe Volumes are enabled for this Project, but none exist in the Scene.\n\n" +
961+
"Do you wish to add an Adaptive Probe Volume to the Active Scene?", "Yes", "No"))
962962
CreateProbeVolume();
963963
activeSet.SetDialogNoProbeVolumeInSetShown(true);
964964
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ public override void OnInspectorGUI()
4444
PropertyField(m_SamplingNoise);
4545
PropertyField(m_AnimateNoise);
4646
PropertyField(m_LeakReductionMode);
47-
if (m_LeakReductionMode.value.intValue != 0)
47+
if (m_LeakReductionMode.value.intValue == (int)APVLeakReductionMode.ValidityBased)
48+
{
49+
}
50+
else if (m_LeakReductionMode.value.intValue == (int)APVLeakReductionMode.ValidityAndNormalBased)
4851
{
4952
using (new IndentLevelScope())
5053
PropertyField(m_MinValidDotProdValue);

Packages/com.unity.render-pipelines.core/Runtime/Debug/ProbeVolumeDebugFunctions.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
{
7676
return float4(CalculateDiffuseLighting(i) * exp2(_ExposureCompensation) * GetCurrentExposureMultiplier(), 1);
7777
}
78-
else if (_ShadingMode == DEBUGPROBESHADINGMODE_INVALIDATED_BY_TOUCHUP_VOLUMES)
78+
else if (_ShadingMode == DEBUGPROBESHADINGMODE_INVALIDATED_BY_ADJUSTMENT_VOLUMES)
7979
{
8080
float4 defaultCol = float4(CalculateDiffuseLighting(i) * exp2(_ExposureCompensation) * GetCurrentExposureMultiplier(), 1);
8181
float touchupAction = UNITY_ACCESS_INSTANCED_PROP(Props, _TouchupedByVolume);

0 commit comments

Comments
 (0)