Skip to content

Commit 6c6a7cc

Browse files
committed
Probe Volume Improvements
Probe Volumes: Force the lightmapper to free old additionalbakedata jobs in a few cases, such as when probe volumes are disabled, or when probe volumes are hidden. Previously, it looks like the lightmapper could hang onto this data until you quit. (#19) Probe Volumes: Lots of bugfixes and improvements to bilateral filtering modes. Octahedral Depth data now working (requires changes on the C++ side). Added support for comparing filtering the texel coordinates and then taking a single sample, vs taking 8x samples and then filtering the results. Ported over from unity graphics repo 3c3b091 Probe Volumes: Lots of bugfixes around baking. Reflection Probes and Density Volumes: now respect scene visibility toggles in regards to their contribution to the scene. TODO: Remove debug logging that was added! Backing up WIP work. SceneObjectIDMap: Fix bug where index from gameobject dictionary would get out of sync from entries after an insertion occurred to fill a hole. This resulted in a nasty bug where reflection probes would occasionally generate the same filename as eachother, would overwrite eachothers textures, and would point to the same texture after the bake completed. Probe Volume: Comment out log spam. Planning to clean it out completely in a follow up commit Probe Volume: Remove log spam from ProbeVolumeManager Added HDRP_STRIP_LEGACY_AMBIENT_PROBE_BAKING define for enabling legacy ambient probe bake feature stripping - requires custom build with backport of https://ono.unity3d.com/unity/unity/pull-request/123092/_/lighting/SRP-opt-out-skymanager Make HDBakedReflectionSystem public for baking API Co-authored-by: pastasfuture <[email protected]>
1 parent c9e375d commit 6c6a7cc

24 files changed

+1106
-365
lines changed

com.unity.render-pipelines.high-definition/Editor/Lighting/ProbeVolume/ProbeVolumeUI.Drawer.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ static void Drawer_BakeToolBar(SerializedProbeVolume serialized, Editor owner)
8484
var asset = serialized.probeVolumeAsset.objectReferenceValue as ProbeVolumeAsset;
8585

8686
if (ShaderConfig.s_ProbeVolumesBilateralFilteringMode == ProbeVolumesBilateralFilteringModes.OctahedralDepth
87-
&& asset != null && asset.payload.dataOctahedralDepth == null)
87+
&& asset != null && (asset.payload.dataOctahedralDepth == null || asset.payload.dataOctahedralDepth.Length == 0))
8888
{
8989
EditorGUILayout.HelpBox(Styles.k_FeatureOctahedralDepthEnabledNoData, MessageType.Error);
9090
}
9191

9292
if (ShaderConfig.s_ProbeVolumesBilateralFilteringMode != ProbeVolumesBilateralFilteringModes.OctahedralDepth
93-
&& asset != null && asset.payload.dataOctahedralDepth != null)
93+
&& asset != null && (asset.payload.dataOctahedralDepth != null && asset.payload.dataOctahedralDepth.Length > 0))
9494
{
9595
EditorGUILayout.HelpBox(Styles.k_FeatureOctahedralDepthDisableYesData, MessageType.Error);
9696
}
@@ -130,6 +130,20 @@ static void Drawer_ToolBar(SerializedProbeVolume serialized, Editor owner)
130130
static void Drawer_PrimarySettings(SerializedProbeVolume serialized, Editor owner)
131131
{
132132
EditorGUILayout.PropertyField(serialized.drawProbes, Styles.s_DrawProbesLabel);
133+
EditorGUILayout.PropertyField(serialized.drawOctahedralDepthRays, Styles.s_DrawOctahedralDepthRays);
134+
if (serialized.drawOctahedralDepthRays.boolValue)
135+
{
136+
EditorGUI.BeginChangeCheck();
137+
EditorGUILayout.DelayedIntField(serialized.drawOctahedralDepthRayIndexX, Styles.s_DrawOctahedralDepthRayIndexX);
138+
EditorGUILayout.DelayedIntField(serialized.drawOctahedralDepthRayIndexY, Styles.s_DrawOctahedralDepthRayIndexY);
139+
EditorGUILayout.DelayedIntField(serialized.drawOctahedralDepthRayIndexZ, Styles.s_DrawOctahedralDepthRayIndexZ);
140+
if (EditorGUI.EndChangeCheck())
141+
{
142+
serialized.drawOctahedralDepthRayIndexX.intValue = Mathf.Clamp(serialized.drawOctahedralDepthRayIndexX.intValue, 0, serialized.resolutionX.intValue - 1);
143+
serialized.drawOctahedralDepthRayIndexY.intValue = Mathf.Clamp(serialized.drawOctahedralDepthRayIndexY.intValue, 0, serialized.resolutionY.intValue - 1);
144+
serialized.drawOctahedralDepthRayIndexZ.intValue = Mathf.Clamp(serialized.drawOctahedralDepthRayIndexZ.intValue, 0, serialized.resolutionZ.intValue - 1);
145+
}
146+
}
133147
EditorGUILayout.PropertyField(serialized.probeSpacingMode, Styles.s_ProbeSpacingModeLabel);
134148
switch ((ProbeSpacingMode)serialized.probeSpacingMode.enumValueIndex)
135149
{

com.unity.render-pipelines.high-definition/Editor/Lighting/ProbeVolume/ProbeVolumeUI.Skin.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ internal static class Styles
2525
internal static readonly GUIContent s_Size = new GUIContent("Size", "Modify the size of this Probe Volume. This is independent of the Transform's Scale.");
2626
internal static readonly GUIContent s_DebugColorLabel = new GUIContent("Debug Color", "This color is used to visualize per-pixel probe volume weights in the render pipeline debugger.");
2727
internal static readonly GUIContent s_DrawProbesLabel = new GUIContent("Draw Probes", "Enable or disable drawing probes.");
28+
internal static readonly GUIContent s_DrawOctahedralDepthRays = new GUIContent("Draw Octahedral Depth Rays", "Enable or disable drawing rays to visualize to the octahedral depth data.");
29+
internal static readonly GUIContent s_DrawOctahedralDepthRayIndexX = new GUIContent("Octahedral Depth Rays Probe X", "Specifies the x index of the probe to visualize octahedral depth rays for.");
30+
internal static readonly GUIContent s_DrawOctahedralDepthRayIndexY = new GUIContent("Octahedral Depth Rays Probe Y", "Specifies the y index of the probe to visualize octahedral depth rays for.");
31+
internal static readonly GUIContent s_DrawOctahedralDepthRayIndexZ = new GUIContent("Octahedral Depth Rays Probe Z", "Specifies the z index of the probe to visualize octahedral depth rays for.");
32+
2833
internal static readonly GUIContent s_BlendLabel = new GUIContent("Blend Distance", "Interior distance from the Size where the contribution fades in completely.");
2934
internal static readonly GUIContent s_NormalModeContent = new GUIContent("Normal", "Exposes standard parameters.");
3035
internal static readonly GUIContent s_AdvancedModeContent = new GUIContent("Advanced", "Exposes advanced parameters.");

com.unity.render-pipelines.high-definition/Editor/Lighting/ProbeVolume/SerializedProbeVolume.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ class SerializedProbeVolume
66
internal SerializedProperty probeVolumeAsset;
77
internal SerializedProperty debugColor;
88
internal SerializedProperty drawProbes;
9+
internal SerializedProperty drawOctahedralDepthRays;
10+
internal SerializedProperty drawOctahedralDepthRayIndexX;
11+
internal SerializedProperty drawOctahedralDepthRayIndexY;
12+
internal SerializedProperty drawOctahedralDepthRayIndexZ;
913

1014
internal SerializedProperty probeSpacingMode;
1115

@@ -48,6 +52,11 @@ internal SerializedProbeVolume(SerializedObject serializedObject)
4852
debugColor = probeVolumeParams.FindPropertyRelative("debugColor");
4953
drawProbes = probeVolumeParams.FindPropertyRelative("drawProbes");
5054

55+
drawOctahedralDepthRays = probeVolumeParams.FindPropertyRelative("drawOctahedralDepthRays");
56+
drawOctahedralDepthRayIndexX = probeVolumeParams.FindPropertyRelative("drawOctahedralDepthRayIndexX");
57+
drawOctahedralDepthRayIndexY = probeVolumeParams.FindPropertyRelative("drawOctahedralDepthRayIndexY");
58+
drawOctahedralDepthRayIndexZ = probeVolumeParams.FindPropertyRelative("drawOctahedralDepthRayIndexZ");
59+
5160
probeSpacingMode = probeVolumeParams.FindPropertyRelative("probeSpacingMode");
5261

5362
resolutionX = probeVolumeParams.FindPropertyRelative("resolutionX");

com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDBakedReflectionSystem.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515

1616
namespace UnityEditor.Rendering.HighDefinition
1717
{
18+
// custom-begin
19+
public
20+
// custom-end
1821
unsafe class HDBakedReflectionSystem : ScriptableBakedReflectionSystem
1922
{
2023
struct HDProbeBakingState

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2628,6 +2628,14 @@ bool TrivialRejectProbe(in ProcessedProbeData processedProbe, HDCamera hdCamera)
26282628
if (processedProbe.hdProbe.texture == null)
26292629
return true;
26302630

2631+
// custom-begin:
2632+
#if UNITY_EDITOR
2633+
// Skip reflection probes that are hidden by the scene visibility toggle.
2634+
if (UnityEditor.SceneVisibilityManager.instance.IsHidden(processedProbe.hdProbe.gameObject))
2635+
return true;
2636+
#endif
2637+
// custom-end
2638+
26312639
return false;
26322640
}
26332641

com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/DebugDisplayProbeVolume.shader

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Shader "Hidden/ScriptableRenderPipeline/DebugDisplayProbeVolume"
1919
float3 _TextureViewResolution;
2020
float2 _ValidRange;
2121
int _ProbeVolumeAtlasSliceMode;
22+
float4 _AtlasTextureOctahedralDepthScaleBias;
2223
// float _RcpGlobalScaleFactor;
2324
SamplerState ltc_linear_clamp_sampler;
2425

@@ -105,8 +106,9 @@ Shader "Hidden/ScriptableRenderPipeline/DebugDisplayProbeVolume"
105106

106107
float valueValidity = saturate((ProbeVolumeSampleValidity(uvw) - _ValidRange.x) * _ValidRange.y);
107108

108-
#if SHADEROPTIONS_PROBE_VOLUMES_BILATERAL_FILTERING == PROBEVOLUMESBILATERALFILTERINGMODES_OCTAHEDRAL_DEPTH
109-
float2 valueOctahedralDepthMeanAndVariance = saturate((SAMPLE_TEXTURE2D_LOD(_AtlasTextureOctahedralDepth, ltc_linear_clamp_sampler, input.texcoord * _AtlasTextureOctahedralDepthScaleBias.xy + _AtlasTextureOctahedralDepthScaleBias.zw, 0).xy - _ValidRange.x) * _ValidRange.y);
109+
#if SHADEROPTIONS_PROBE_VOLUMES_BILATERAL_FILTERING_MODE == PROBEVOLUMESBILATERALFILTERINGMODES_OCTAHEDRAL_DEPTH
110+
float4 scaleBias = _AtlasTextureOctahedralDepthScaleBias;
111+
float2 valueOctahedralDepthMeanAndMeanSquared = saturate((SAMPLE_TEXTURE2D_LOD(_ProbeVolumeAtlasOctahedralDepth, ltc_linear_clamp_sampler, input.texcoord * scaleBias.xy + scaleBias.zw, 0).xy - _ValidRange.x) * _ValidRange.y);
110112
#endif
111113

112114
switch (_ProbeVolumeAtlasSliceMode)
@@ -164,11 +166,13 @@ Shader "Hidden/ScriptableRenderPipeline/DebugDisplayProbeVolume"
164166

165167
case PROBEVOLUMEATLASSLICEMODE_OCTAHEDRAL_DEPTH:
166168
{
167-
#if SHADEROPTIONS_PROBE_VOLUMES_BILATERAL_FILTERING == PROBEVOLUMESBILATERALFILTERINGMODES_OCTAHEDRAL_DEPTH
168-
// Tonemap variance with sqrt() to bring it into a more similar scale to mean to make it more readable.
169+
#if SHADEROPTIONS_PROBE_VOLUMES_BILATERAL_FILTERING_MODE == PROBEVOLUMESBILATERALFILTERINGMODES_OCTAHEDRAL_DEPTH
170+
float mean = valueOctahedralDepthMeanAndMeanSquared.x;
171+
float meanSquared = valueOctahedralDepthMeanAndMeanSquared.y;
172+
float variance = meanSquared - mean * mean;
169173
return float4(
170-
valueOctahedralDepthMeanAndVariance.x,
171-
(valueOctahedralDepthMeanAndVariance.y > 0.0f) ? sqrt(valueOctahedralDepthMeanAndVariance.y) : 0.0f,
174+
mean,
175+
variance,
172176
0.0f,
173177
1.0f
174178
);

0 commit comments

Comments
 (0)