Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -732,9 +732,18 @@ public static ProbeSubdivisionResult BakeBricks(ProbeSubdivisionContext ctx)
{
var go = renderer.component.gameObject;
int rendererLayerMask = 1 << go.layer;
renderer.volume.CalculateCenterAndSize(out _, out var rendererBoundsSize);
float rendererBoundsVolume = rendererBoundsSize.x * rendererBoundsSize.y * rendererBoundsSize.z;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid issues with planes I'd say we should min all dimensions to avoid 0, probably to 2/3 cm?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, in this renderer size, there is already padding of 1cm in every axis


foreach (var probeVolume in overlappingProbeVolumes)
{
// Skip renderers that have a smaller volume than the min volume size from the profile or probe volume component
float minRendererBoundingBoxSize = ctx.profile.minRendererVolumeSize;
if (probeVolume.component.overrideMinRendererVolumeSize)
minRendererBoundingBoxSize = probeVolume.component.minRendererVolumeSize;
if (rendererBoundsVolume < minRendererBoundingBoxSize)
continue;

if (ProbeVolumePositioning.OBBIntersect(renderer.volume, probeVolume.volume)
&& ProbeVolumePositioning.OBBIntersect(renderer.volume, cell.volume))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ struct GPUProbeVolumeOBB
public int minControllerSubdivLevel;
public int maxControllerSubdivLevel;
public int maxSubdivLevelInsideVolume;
public float geometryDistanceOffset;
}

public class GPUSubdivisionContext : IDisposable
Expand Down Expand Up @@ -621,7 +620,6 @@ static void VoxelizeProbeVolumeData(CommandBuffer cmd, Bounds cellAABB,
minControllerSubdivLevel = minSubdiv,
maxControllerSubdivLevel = maxSubdiv,
maxSubdivLevelInsideVolume = subdivLevel,
geometryDistanceOffset = kp.component.geometryDistanceOffset,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ struct GPUProbeVolumeOBB
int minControllerSubdivLevel;
int maxControllerSubdivLevel;
int maxSubdivLevelInsideVolume;
float geometryDistanceOffset;
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,10 @@ void DelayCreateAsset()
if (m_ProbeVolumeProfileEditor.target != set.profile)
Editor.CreateCachedEditor(set.profile, m_ProbeVolumeProfileEditor.GetType(), ref m_ProbeVolumeProfileEditor);

EditorGUILayout.LabelField("Probe Volume Profile", EditorStyles.largeLabel);
EditorGUILayout.LabelField("Probe Volume Profile", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
m_ProbeVolumeProfileEditor.OnInspectorGUI();

EditorGUILayout.Space();
EditorGUI.indentLevel--;

var serializedSets = m_ProbeSceneData.FindPropertyRelative("serializedBakingSets");
var serializedSet = serializedSets.GetArrayElementAtIndex(m_BakingSets.index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ bool PointInsideOBB(GPUProbeVolumeOBB obbA, GPUProbeVolumeOBB obbB)
void VoxelizeProbeVolumeData(uint3 id : SV_DispatchThreadID)
{
float2 subdivisionLimits = float2(0, 0);
float maxGeometryDistance = -1e20;
float maxSubdivLevelInsideVolume = 0;

if (any(id >= uint3(_MaxBrickSize.xyz)))
Expand All @@ -222,12 +221,11 @@ void VoxelizeProbeVolumeData(uint3 id : SV_DispatchThreadID)

subdivisionLimits.x = max(subdivisionLimits.x, obb.minControllerSubdivLevel);
subdivisionLimits.y = max(subdivisionLimits.y, obb.maxControllerSubdivLevel);
maxGeometryDistance = max(maxGeometryDistance, obb.geometryDistanceOffset);
maxSubdivLevelInsideVolume = max(maxSubdivLevelInsideVolume, obb.maxSubdivLevelInsideVolume);
}
}

_Output[id] = float4(subdivisionLimits, maxGeometryDistance, maxSubdivLevelInsideVolume);
_Output[id] = float4(subdivisionLimits, 0, maxSubdivLevelInsideVolume);
}

[numthreads(8, 8, 1)]
Expand All @@ -248,7 +246,6 @@ void Subdivide(uint3 id : SV_DispatchThreadID)
if (_SubdivisionLevel < maxControllerSubdivLevel || _SubdivisionLevel > maxSubdivLevelInsideVolume)
return;


uint3 sdfId = floor(position01 * _SDFSize.xyz);

float dist = _Input[sdfId].r;
Expand All @@ -259,9 +256,6 @@ void Subdivide(uint3 id : SV_DispatchThreadID)

int minControllerSubdivLevel = _MaxSubdivisionLevel - subdivisionLevelData.x - 1;

// Add a small offset to control how the subdivision looks from the probe volume
voxelDetectionDistance += subdivisionLevelData.z * rcp(_MaxBrickSize.x);

if (dist <= voxelDetectionDistance || _SubdivisionLevel > minControllerSubdivLevel)
{
// transform id to world position
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,14 @@ static void Drawer_VolumeContent(SerializedProbeVolume serialized, Editor owner)

EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(serialized.objectLayerMask, Styles.s_ObjectLayerMask);
EditorGUILayout.PropertyField(serialized.geometryDistanceOffset, Styles.s_GeometryDistanceOffset);

EditorGUILayout.PropertyField(serialized.overrideMinRendererVolumeSize, Styles.s_OverrideMinRendererVolumeSize);
if (serialized.overrideMinRendererVolumeSize.boolValue)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(serialized.minRendererVolumeSize, Styles.s_MinRendererVolumeSize);
EditorGUI.indentLevel--;
}
EditorGUI.indentLevel--;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ internal static class Styles
internal static readonly GUIContent s_HighestSubdivLevel = new GUIContent("Highest Subdivision Level", "Overrides the highest subdivision level used by the system. This determines how finely a probe volume is subdivided, lower values means larger minimum distance between probes.");
internal static readonly GUIContent s_LowestSubdivLevel = new GUIContent("Lowest Subdivision Level", "Overrides the lowest subdivision level used by the system. This determines how coarsely a probe volume is allowed to be subdivided, higher values means smaller maximum distance between probes.");
internal static readonly GUIContent s_ObjectLayerMask = new GUIContent("Layer Mask", "Control which layers will be used to select the meshes for the probe placement algorithm.");
internal static readonly GUIContent s_GeometryDistanceOffset = new GUIContent("Probe Placement Distance Offset", "Affects the minimum distance at which the subdivision system will attempts to place probes near the geometry. This value can be useful in situations where the generated probes don't fully cover an object.");
internal static readonly GUIContent s_MinRendererVolumeSize = new GUIContent("Minimum Renderer Volume Size", "Specifies the minimum bounding box volume of renderers to consider placing probes around.");
internal static readonly GUIContent s_OverrideMinRendererVolumeSize = new GUIContent("Override Renderer Filters", "Overrides the Minimum Renderer Volume Size specified in the Probe Volume Settings Window.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this

Override Renderer Filters

Should have been Minimum Renderer Volume Size?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Override Minimum Renderer Volume Size
Was too long in the inspector, needed to find another name

internal static readonly string s_ProbeVolumeChangedMessage = "The probe volume has changed since last baking or the data was never baked.\nPlease bake lighting in the lighting panel to update the lighting data.";

internal static readonly Color k_GizmoColorBase = new Color32(137, 222, 144, 255);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ internal class SerializedProbeVolume
internal SerializedProperty highestSubdivisionLevelOverride;
internal SerializedProperty lowestSubdivisionLevelOverride;
internal SerializedProperty objectLayerMask;
internal SerializedProperty geometryDistanceOffset;
internal SerializedProperty minRendererVolumeSize;
internal SerializedProperty overrideMinRendererVolumeSize;

internal SerializedObject serializedObject;

Expand All @@ -21,7 +22,8 @@ internal SerializedProbeVolume(SerializedObject obj)
globalVolume = serializedObject.FindProperty("globalVolume");
size = serializedObject.FindProperty("size");
objectLayerMask = serializedObject.FindProperty("objectLayerMask");
geometryDistanceOffset = serializedObject.FindProperty("geometryDistanceOffset");
minRendererVolumeSize = serializedObject.FindProperty("minRendererVolumeSize");
overrideMinRendererVolumeSize = serializedObject.FindProperty("overrideMinRendererVolumeSize");
highestSubdivisionLevelOverride = serializedObject.FindProperty("highestSubdivLevelOverride");
lowestSubdivisionLevelOverride = serializedObject.FindProperty("lowestSubdivLevelOverride");
overridesSubdivision = serializedObject.FindProperty("overridesSubdivLevels");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ internal enum Version
/// </summary>
public float cellSizeInMeters => (float)cellSizeInBricks * minBrickSize;

/// <summary>
/// Specifies the minimum bounding box volume of renderers to consider placing probes around.
/// </summary>
[Min(0)]
public float minRendererVolumeSize = 0.1f;

void OnEnable()
{
if (version != CoreUtils.GetLastEnumValue<Version>())
Expand Down Expand Up @@ -79,6 +85,7 @@ internal class ProbeReferenceVolumeProfileEditor : Editor
SerializedProperty m_CellSize;
SerializedProperty m_MinDistanceBetweenProbes;
SerializedProperty m_SimplificationLevels;
SerializedProperty m_MinRendererVolumeSize;
ProbeReferenceVolumeProfile profile => target as ProbeReferenceVolumeProfile;

static class Styles
Expand All @@ -88,13 +95,15 @@ static class Styles
public static readonly string simplificationLevelsHighWarning = "High simplification levels have a big memory overhead, they are not recommended except for testing purposes.";
public static readonly GUIContent minDistanceBetweenProbes = new GUIContent("Min Distance Between Probes", "The minimal distance between two probes in meters.");
public static readonly GUIContent indexDimensions = new GUIContent("Index Dimensions", "The dimensions of the index buffer.");
public static readonly GUIContent minRendererVolumeSize = new GUIContent("Minimum Renderer Volume Size", "Specifies the minimum bounding box volume of renderers to consider placing probes around.");
}

void OnEnable()
{
m_CellSize = serializedObject.FindProperty(nameof(ProbeReferenceVolumeProfile.cellSizeInBricks));
m_MinDistanceBetweenProbes = serializedObject.FindProperty(nameof(ProbeReferenceVolumeProfile.minDistanceBetweenProbes));
m_SimplificationLevels = serializedObject.FindProperty(nameof(ProbeReferenceVolumeProfile.simplificationLevels));
m_MinRendererVolumeSize = serializedObject.FindProperty(nameof(ProbeReferenceVolumeProfile.minRendererVolumeSize));
}

public override void OnInspectorGUI()
Expand All @@ -109,6 +118,8 @@ public override void OnInspectorGUI()
}
EditorGUILayout.PropertyField(m_MinDistanceBetweenProbes, Styles.minDistanceBetweenProbes);
EditorGUILayout.HelpBox($"The distance between probes will fluctuate between : {profile.minDistanceBetweenProbes}m and {profile.cellSizeInMeters / 3.0f}m", MessageType.Info);

EditorGUILayout.PropertyField(m_MinRendererVolumeSize, Styles.minRendererVolumeSize);

if (EditorGUI.EndChangeCheck())
serializedObject.ApplyModifiedProperties();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ public class ProbeVolume : MonoBehaviour
{
public bool globalVolume = false;
public Vector3 size = new Vector3(10, 10, 10);
[HideInInspector, Range(0f, 2f)]
public float geometryDistanceOffset = 0.0f;
[HideInInspector, Min(0)]
public bool overrideMinRendererVolumeSize = false;
[HideInInspector, Min(0)]
public float minRendererVolumeSize = 0.1f;

public LayerMask objectLayerMask = -1;

Expand Down Expand Up @@ -115,7 +117,9 @@ public override int GetHashCode()
hash = hash * 23 + overridesSubdivLevels.GetHashCode();
hash = hash * 23 + highestSubdivLevelOverride.GetHashCode();
hash = hash * 23 + lowestSubdivLevelOverride.GetHashCode();
hash = hash * 23 + geometryDistanceOffset.GetHashCode();
hash = hash * 23 + overrideMinRendererVolumeSize.GetHashCode();
if (overrideMinRendererVolumeSize)
hash = hash * 23 + minRendererVolumeSize.GetHashCode();
hash = hash * 23 + objectLayerMask.GetHashCode();
}

Expand Down
2 changes: 2 additions & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Changed sample scene in HDRP material samples: add shadow transparency (raster, ray-traced, path-traced).
- Support for encoded HDR cubemaps, configurable via the HDR Cubemap Encoding project setting.
- The rendering order of decals that have a similar draw order value was modified. The new order should be the reverse of the previous order.
- Improved the probe placement of APV when dealing with scenes that contains objects smaller than a brick.
- Replaced the geometry distance offset in the Probe Volume component by a minimum renderer volume threshold to ignore small objects when placing probes.

### Fixed
- Fixed some XR devices: Pulling camera world space position from mainViewConstants instead of transform.
Expand Down