Skip to content

Commit 0718f13

Browse files
committed
Probe Volumes:
Probe Volumes: Delete meta file for empty folder accidentially created a while back. Cleans up a warning when the project is first imported (#34) Co-authored-by: pastasfuture <[email protected]> Probe Volumes: Cleanup the state when HDRP has Probe Volumes disabled in the HDRenderPipelineAsset or FrameSettings. Previously we would hit some null reference errors because the disabled paths were not well tested. These fixes should improve the process of setting up Probe Volumes / Mask Volumes in a new project Probe Volumes: Upadte ProbeVolumeAtlasKey to additionally unique on volume position if the volume is simulating dynamic GI. If dynamic GI is enabled, two probe volumes that point to the same asset, streamed in at different locations need unique space in the atlas (because their dynamic GI component is different). If dynamic GI is disabled, two probe volumes that point to the same asset, streamed in at different locations should share space in the atlas, since their baked data is identical. Probe Volume: VolumeGlobalUniqueID and atlas allocation stats Probe Volumes: Probe Volumes: Remove Ambient Sky fallback which was used when accumulated probe volume weight was < 1. In our project we never want to fall back to the ambient sky, we want to fallback to black. (#40) Co-authored-by: pastasfuture <[email protected]> Probe Volumes: Fix bug where tiles would receive no probe volume lighting if they contained no direct light sources, and if compute based deferred was enabled. (#41) Co-authored-by: pastasfuture <[email protected]> Probe Volume: Fix Probe Volume Visibility API Probe Volume: Fixed compilation error when Probe Volumes are not encoded with SHL2.
1 parent c2e70d3 commit 0718f13

21 files changed

+656
-400
lines changed

com.unity.render-pipelines.high-definition/Runtime/Lighting/AdditionalGIBakeRequestsManager.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using UnityEngine.SceneManagement;
66
using Unity.Collections;
77
using UnityEditor;
8+
using static UnityEngine.Rendering.HighDefinition.VolumeGlobalUniqueIDUtils;
89

910
namespace UnityEngine.Rendering.HighDefinition
1011
{
@@ -55,11 +56,11 @@ private AdditionalGIBakeRequestsManager()
5556

5657
// Lightmapper API uses ints as keys, but we want to use full, stable, GlobalObjectIds as keys.
5758
// Rather than hashing and hoping we don't collide, lets handle this robustly by
58-
// keeping a dictionary of ProbeVolumeGlobalUniqueID->int bit keys.
59-
private Dictionary<ProbeVolumeGlobalUniqueID, int> lightmapperBakeIDFromBakeID = new Dictionary<ProbeVolumeGlobalUniqueID, int>(32);
59+
// keeping a dictionary of VolumeGlobalUniqueID->int bit keys.
60+
private Dictionary<VolumeGlobalUniqueID, int> lightmapperBakeIDFromBakeID = new Dictionary<VolumeGlobalUniqueID, int>(32);
6061
private int lightmapperBakeIDNext = s_LightmapperBakeIDStart;
6162

62-
internal void SetAdditionalBakedProbes(ProbeVolumeGlobalUniqueID bakeID, Vector3[] positions)
63+
internal void SetAdditionalBakedProbes(VolumeGlobalUniqueID bakeID, Vector3[] positions)
6364
{
6465
if (TryGetLightmapperBakeIDFromBakeID(bakeID, out int lightmapperBakeID))
6566
{
@@ -82,7 +83,7 @@ internal void SetAdditionalBakedProbes(ProbeVolumeGlobalUniqueID bakeID, Vector3
8283
}
8384
}
8485

85-
internal bool GetAdditionalBakedProbes(ProbeVolumeGlobalUniqueID bakeID, NativeArray<SphericalHarmonicsL2> outBakedProbeSH, NativeArray<float> outBakedProbeValidity, NativeArray<float> outBakedProbeOctahedralDepth)
86+
internal bool GetAdditionalBakedProbes(VolumeGlobalUniqueID bakeID, NativeArray<SphericalHarmonicsL2> outBakedProbeSH, NativeArray<float> outBakedProbeValidity, NativeArray<float> outBakedProbeOctahedralDepth)
8687
{
8788
bool success = false;
8889
if (TryGetLightmapperBakeIDFromBakeID(bakeID, out int lightmapperBakeID))
@@ -92,7 +93,7 @@ internal bool GetAdditionalBakedProbes(ProbeVolumeGlobalUniqueID bakeID, NativeA
9293
return success;
9394
}
9495

95-
private bool TryGetLightmapperBakeIDFromBakeID(ProbeVolumeGlobalUniqueID bakeID, out int lightmapperBakeID)
96+
private bool TryGetLightmapperBakeIDFromBakeID(VolumeGlobalUniqueID bakeID, out int lightmapperBakeID)
9697
{
9798
bool success = false;
9899
if (lightmapperBakeIDFromBakeID.TryGetValue(bakeID, out lightmapperBakeID))
@@ -117,7 +118,7 @@ private bool TryGetLightmapperBakeIDFromBakeID(ProbeVolumeGlobalUniqueID bakeID,
117118
return success;
118119
}
119120

120-
private void IncrementLightmapperBakeIDGeneration(ProbeVolumeGlobalUniqueID bakeID, out int lightmapperBakeID)
121+
private void IncrementLightmapperBakeIDGeneration(VolumeGlobalUniqueID bakeID, out int lightmapperBakeID)
121122
{
122123
lightmapperBakeID = -1;
123124
if (lightmapperBakeIDFromBakeID.TryGetValue(bakeID, out lightmapperBakeID))

com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,8 +2227,7 @@ bool PrepareLightsForGPU(CommandBuffer cmd, HDCamera hdCamera, CullingResults cu
22272227

22282228
for (int i = 0, n = m_ProbeVolumeCount; i < n; i++)
22292229
{
2230-
// Probe volumes are not lights and therefore should not affect light classification.
2231-
LightFeatureFlags featureFlags = 0;
2230+
LightFeatureFlags featureFlags = LightFeatureFlags.ProbeVolume;
22322231
float probeVolumeMaxBiasWS = probeVolumeNormalBiasEnabled ? (probeVolumes.data[i].normalBiasWS + probeVolumes.data[i].viewBiasWS) : 0.0f;
22332232
CreateBoxVolumeDataAndBound(probeVolumes.bounds[i], LightCategory.ProbeVolume, featureFlags, worldToViewCR, probeVolumeMaxBiasWS, out LightVolumeData volumeData, out SFiniteLightBound bound);
22342233
if (ShaderConfig.s_ProbeVolumesEvaluationMode == ProbeVolumesEvaluationModes.MaterialPass)
@@ -2599,16 +2598,6 @@ static void BuildPerTileLightList(in BuildGPULightListParameters parameters, in
25992598
baseFeatureFlags |= LightDefinitions.s_MaterialFeatureMaskFlags;
26002599
}
26012600

2602-
if (parameters.probeVolumeEnabled)
2603-
{
2604-
// If probe volume feature is enabled, we toggle this feature on for all tiles.
2605-
// This is necessary because all tiles must sample ambient probe fallback.
2606-
// It is possible we could save a little bit of work by having 2x feature flags for probe volumes:
2607-
// one specifiying which tiles contain probe volumes,
2608-
// and another triggered for all tiles to handle fallback.
2609-
baseFeatureFlags |= (uint)LightFeatureFlags.ProbeVolume;
2610-
}
2611-
26122601
localLightListCB.g_BaseFeatureFlags = baseFeatureFlags;
26132602

26142603
cmd.SetComputeBufferParam(parameters.buildPerTileLightListShader, parameters.buildPerTileLightListKernel, HDShaderIDs.g_TileFeatureFlags, resources.tileFeatureFlags);
@@ -2672,11 +2661,6 @@ static void BuildDispatchIndirectArguments(in BuildGPULightListParameters parame
26722661
{
26732662
baseFeatureFlags |= LightDefinitions.s_LightFeatureMaskFlags;
26742663
}
2675-
if (parameters.probeVolumeEnabled)
2676-
{
2677-
// TODO: Verify that we should be globally enabling ProbeVolume feature for all tiles here, or if we should be using per-tile culling.
2678-
baseFeatureFlags |= (uint)LightFeatureFlags.ProbeVolume;
2679-
}
26802664

26812665
// If we haven't run the light list building, we are missing some basic lighting flags.
26822666
if (!tileFlagsWritten)

com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/DynamicGI/ProbeVolumeDynamicGIEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ internal void DebugDrawNeighborhood(ProbeVolumeHandle probeVolume, Camera camera
122122
if (hdrp != null)
123123
{
124124
var obb = probeVolume.ConstructOBBEngineData( Vector3.zero);
125-
var data = probeVolume.parameters.ConvertToEngineData(hdrp.GetProbeVolumeAtlasSHRTDepthSliceCount());
125+
var data = probeVolume.parameters.ConvertToEngineData(hdrp.GetProbeVolumeAtlasSHRTDepthSliceCount(), probeVolume.parameters.distanceFadeStart, probeVolume.parameters.distanceFadeEnd);
126126

127127
Shader.SetGlobalFloat("_ProbeVolumeDGIMaxNeighborDistance", data.maxNeighborDistance);
128128
Shader.SetGlobalInt("_ProbeVolumeDGIResolutionXY", (int)data.resolutionXY);

com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/IProbeVolumeList.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using static UnityEngine.Rendering.HighDefinition.VolumeGlobalUniqueIDUtils;
2+
13
namespace UnityEngine.Rendering.HighDefinition
24
{
35
interface IProbeVolumeList
@@ -15,7 +17,7 @@ interface IProbeVolumeList
1517

1618
ref ProbeVolumeArtistParameters GetParameters(int i);
1719

18-
ProbeVolumeGlobalUniqueID GetAtlasID(int i);
20+
VolumeGlobalUniqueID GetAtlasID(int i);
1921
ProbeVolume.ProbeVolumeAtlasKey ComputeProbeVolumeAtlasKey(int i);
2022
ProbeVolume.ProbeVolumeAtlasKey GetProbeVolumeAtlasKeyPrevious(int i);
2123
void SetProbeVolumeAtlasKeyPrevious(int i, ProbeVolume.ProbeVolumeAtlasKey key);

0 commit comments

Comments
 (0)