Skip to content

Commit 4636bbe

Browse files
adrien-de-tocquevilleEvergreen
authored andcommitted
[APV] Various Fixes
Fixed missing option to offset probe at runtime, can be used for camera relative rendering on large worlds, or when loading scene at a different location than where it was baked Fixed baking when using terrain trees with LOD groups Fixed warnings in various shaders Fixed dispatches too large for sky occlusion that would result in errors when baking Slightly changed the thread group size and batch size to reduce time spend in baking shaders to avoid windows TDR errors Fixed to debug modes when using baking offset Fix error when we try to delete temp directory but it was marked as readonly by the OS Increase test coverage
1 parent 0bbcd45 commit 4636bbe

29 files changed

+1066
-87
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal
2+
13
#define UNIFIED_RT_BACKEND_COMPUTE
2-
#define UNIFIED_RT_GROUP_SIZE_X 16
4+
#define UNIFIED_RT_GROUP_SIZE_X 64
35
#define UNIFIED_RT_GROUP_SIZE_Y 1
46
#include "DynamicGISkyOcclusion.hlsl"
57
#include_with_pragmas "Packages/com.unity.rendering.light-transport/Runtime/UnifiedRayTracing/Compute/ComputeRaygenShader.hlsl"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ internal static class Styles
3636
internal static readonly GUIContent s_Mode = new GUIContent("Mode", "Choose which type of adjustment to apply to probes covered by this volume.");
3737
internal static readonly GUIContent s_DilationThreshold = new GUIContent("Dilation Validity Threshold", "Override the Dilation Validity Threshold for probes covered by this Probe Adjustment Volume. Higher values increase the chance of probes being considered invalid.");
3838
internal static readonly GUIContent virtualOffsetThreshold = new GUIContent("Validity Threshold", "Override the Virtual Offset Validity Threshold for probes covered by this Probe Adjustment Volume. Higher values increase the chance of probes being considered invalid.");
39-
internal static readonly GUIContent s_VODirection = new GUIContent("Direction", "Rotate the axis along which probes will be pushed when applying Virtual Offset.");
39+
internal static readonly GUIContent s_VODirection = new GUIContent("Rotation", "Rotate the axis along which probes will be pushed when applying Virtual Offset.");
4040
internal static readonly GUIContent s_VODistance = new GUIContent("Distance", "Determines how far probes are pushed in the direction of the Virtual Offset.");
4141
internal static readonly GUIContent renderingLayerMaskOperation = new GUIContent("Operation", "The operation to combine the Rendering Layer Mask set by this adjustment volume with the Rendering Layer Mask of the probes covered by this volume.");
4242
internal static readonly GUIContent renderingLayerMask = new GUIContent("Rendering Layer Mask", "Sets the Rendering Layer Mask to be combined with the Rendering Layer Mask of the probes covered by this volume.");

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ static void PerformDilation(ProbeReferenceVolume.Cell cell, ProbeVolumeBakingSet
357357
parameters.skyOcclusionShadingDirection = bakingSet.skyOcclusionShadingDirection ? true : false;
358358
parameters.regionCount = 1;
359359
parameters.regionLayerMasks = 1;
360+
parameters.worldOffset = Vector3.zero;
360361
ProbeReferenceVolume.instance.UpdateConstantBuffer(cmd, parameters);
361362

362363

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,8 @@ internal static void BakeAdjustmentVolume(ProbeVolumeBakingSet bakingSet, ProbeA
804804
m_CellsToDilate.Clear();
805805
}
806806

807+
Debug.Assert(bakingSet.CheckCompatibleCellLayout());
808+
807809
// Clear loaded data
808810
foreach (var data in prv.perSceneDataList)
809811
data.QueueSceneRemoval();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ internal static uint EncodeSkyShadingDirection(Vector3 direction)
115115

116116
class DefaultSkyOcclusion : SkyOcclusionBaker
117117
{
118-
const int k_MaxProbeCountPerBatch = 65535 * 64;
118+
const int k_MaxProbeCountPerBatch = 128 * 1024;
119119
const float k_SkyOcclusionOffsetRay = 0.015f;
120120
const int k_SampleCountPerStep = 16;
121121

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static internal void CompressSH(ref SphericalHarmonicsL2 shv, float intensitySca
102102
shv[rgb, 8] = shv[rgb, 8] / (l0 * l2scale * 2.0f) + 0.5f;
103103

104104
for (int coeff = 1; coeff < 9; ++coeff)
105-
Debug.Assert(shv[rgb, coeff] >= 0.0f && shv[rgb, coeff] <= 1.0f);
105+
shv[rgb, coeff] = Mathf.Clamp01(shv[rgb, coeff]);
106106
}
107107
}
108108
}

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,17 @@ public override void PrepareForBuild(BuildPlayerContext buildPlayerContext)
7373

7474
// Delete previously built data. This way we remove any data from scenes that are no longer in the build.
7575
if (Directory.Exists(tempStreamingAssetsPath))
76-
Directory.Delete(tempStreamingAssetsPath, recursive: true);
76+
{
77+
try
78+
{
79+
Directory.Delete(tempStreamingAssetsPath, recursive: true);
80+
}
81+
catch
82+
{
83+
// This can happen if for example the folder is write protected
84+
// This is not ideal but don't block project build
85+
}
86+
}
7787

7888
Directory.CreateDirectory(tempStreamingAssetsPath);
7989

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,9 +1003,7 @@ internal bool PrepareAPVBake()
10031003
activeSet.SetActiveScenario(activeSet.m_LightingScenarios[0], false);
10041004

10051005
// Layout has changed and is incompatible.
1006-
if (activeSet.HasValidSharedData() && !activeSet.freezePlacement &&
1007-
(activeSet.bakedMinDistanceBetweenProbes != activeSet.minDistanceBetweenProbes ||
1008-
activeSet.bakedSimplificationLevels != activeSet.simplificationLevels))
1006+
if (activeSet.HasValidSharedData() && !activeSet.freezePlacement && !activeSet.CheckCompatibleCellLayout())
10091007
{
10101008
if (AdaptiveProbeVolumes.partialBakeSceneList != null)
10111009
{

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ sealed class ProbeVolumesOptionsEditor : VolumeComponentEditor
1515

1616
SerializedDataParameter m_IntensityMultiplier;
1717
SerializedDataParameter m_SkyOcclusionIntensityMultiplier;
18+
SerializedDataParameter m_WorldOffset;
1819

1920
public override void OnEnable()
2021
{
@@ -30,6 +31,7 @@ public override void OnEnable()
3031

3132
m_IntensityMultiplier = Unpack(o.Find(x => x.intensityMultiplier));
3233
m_SkyOcclusionIntensityMultiplier = Unpack(o.Find(x => x.skyOcclusionIntensityMultiplier));
34+
m_WorldOffset = Unpack(o.Find(x => x.worldOffset));
3335

3436
base.OnEnable();
3537
}
@@ -46,6 +48,7 @@ public override void OnInspectorGUI()
4648

4749
PropertyField(m_IntensityMultiplier);
4850
PropertyField(m_SkyOcclusionIntensityMultiplier);
51+
PropertyField(m_WorldOffset);
4952
}
5053
}
5154
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal
2+
13
#define UNIFIED_RT_BACKEND_COMPUTE
2-
#define UNIFIED_RT_GROUP_SIZE_X 16
4+
#define UNIFIED_RT_GROUP_SIZE_X 64
35
#define UNIFIED_RT_GROUP_SIZE_Y 1
46
#include "TraceVirtualOffset.hlsl"
57
#include_with_pragmas "Packages/com.unity.rendering.light-transport/Runtime/UnifiedRayTracing/Compute/ComputeRaygenShader.hlsl"

0 commit comments

Comments
 (0)