Refactor depth node groups and simplify options

- Removed `Smooth Weight` input from `O Image Depth Plane`, `O Image Depth Cutout`, and `O Image Depth Panorama` to streamline the interface and maintain consistent boundary smoothing behavior.
- Adjusted the `Reference Depth` input to appear last in the options panel for better organization, reflecting its role as a calibration value.
- Consolidated the `expand_smooth()` function to only accept necessary parameters, eliminating unused branches related to `Smooth Weight` and `pin_sharp`.
- Updated related tests and node assets to ensure functionality remains intact and consistent with the new structure.
- Introduced new specifications to document the changes and ensure compliance with the updated requirements.
This commit is contained in:
2026-09-16 13:12:12 +08:00
parent 6ca084ee4a
commit 7f69630371
26 changed files with 741 additions and 178 deletions

View File

@@ -90,7 +90,6 @@ def test_cutout_fine_outline_smooths_only_within_boundary_band():
image.pixels.foreach_set(pixels.ravel())
image.update()
set_value("Boundary Smooth", 0)
set_value("Smooth Weight", 1)
before, original_faces = evaluated(obj)
set_value("Boundary Smooth", 12)
after, result_faces = evaluated(obj)
@@ -114,7 +113,7 @@ def test_plane_validity_hole_blurs_depth_and_protects_rectangle():
pixels[1:3, 7:9, 2] = 12
image.pixels.foreach_set(pixels.ravel())
image.update()
for name, value in (("Subdivide", 5), ("Depth Scale", 1), ("Smooth Weight", 0)):
for name, value in (("Subdivide", 5), ("Depth Scale", 1)):
set_value(name, value)
before, faces, uv, *_ = plane_mesh(obj)
set_value("Boundary Smooth", 12)
@@ -126,8 +125,11 @@ def test_plane_validity_hole_blurs_depth_and_protects_rectangle():
corners = np.concatenate(faces)
outer = np.unique(corners[protected])
np.testing.assert_array_equal(after[outer], before[outer])
np.testing.assert_allclose(after[:, [0, 2]] / (1.2 + after[:, 1:2]),
before[:, [0, 2]] / (1.2 + before[:, 1:2]), atol=1e-6)
# Position smoothing moves the cut band off its projection ray by design.
band = edge_band(faces, boundary_neighbors(faces))
kept = [i for i in range(len(before)) if i not in band]
np.testing.assert_allclose(after[kept][:, [0, 2]] / (1.2 + after[kept][:, 1:2]),
before[kept][:, [0, 2]] / (1.2 + before[kept][:, 1:2]), atol=1e-6)
set_value("Depth Mask", False)
intact = plane_mesh(obj)[0]
set_value("Boundary Smooth", 0)
@@ -144,7 +146,6 @@ def test_panorama_blurs_opening_radially_and_keeps_invalid_distance(region):
spike = ((distance < 4) & (yy > 40) & (yy < 44)) if region == "seam" else ((yy > 50) & (xx < 8))
depth = np.where(spike, 10., 3.)
obj, set_value = panorama(depth, (~hole).astype(float), subdivide=5)
set_value("Smooth Weight", 0)
before, faces, uv = panorama_mesh(obj)
set_value("Boundary Smooth", 12)
after, result_faces, result_uv = panorama_mesh(obj)
@@ -154,18 +155,28 @@ def test_panorama_blurs_opening_radially_and_keeps_invalid_distance(region):
smoothed = np.linalg.norm(after, axis=1)
rim = list(boundary_neighbors(faces))
assert smoothed[rim].max() < radii[rim].max() - .1
np.testing.assert_allclose(after / smoothed[:, None], before / radii[:, None], atol=1e-6)
band = edge_band(faces, boundary_neighbors(faces))
interior = [i for i in range(len(before)) if i not in band]
assert interior
# Position smoothing moves the opening rim off its radial direction by design.
np.testing.assert_allclose(after[interior] / smoothed[interior, None],
before[interior] / radii[interior, None], atol=1e-6)
np.testing.assert_array_equal(after[interior], before[interior])
set_value("Depth Mask", False)
near = panorama_mesh(obj)[0]
set_value("Invalid Distance", 250)
far = panorama_mesh(obj)[0]
far, far_faces, _ = panorama_mesh(obj)
valid = np.linalg.norm(near, axis=1) < 50
assert valid.any() and (~valid).any()
np.testing.assert_array_equal(far[valid], near[valid])
np.testing.assert_allclose(np.linalg.norm(far[~valid], axis=1), 250, atol=5e-5)
# The smoothed rim blends into its neighbours, so only the interior keeps the exact distance.
far_band = edge_band(far_faces, boundary_neighbors(far_faces))
kept = [i for i in range(len(far)) if i not in far_band and not valid[i]]
assert kept
np.testing.assert_allclose(np.linalg.norm(far[kept], axis=1), 250, atol=5e-5)
set_value("Depth Scale", 0)
np.testing.assert_allclose(np.linalg.norm(panorama_mesh(obj)[0], axis=1), 1, atol=1e-6)
sphere, sphere_faces, _ = panorama_mesh(obj)
sphere_band = edge_band(sphere_faces, boundary_neighbors(sphere_faces))
interior = [i for i in range(len(sphere)) if i not in sphere_band]
assert interior
np.testing.assert_allclose(np.linalg.norm(sphere[interior], axis=1), 1, atol=1e-6)