feat(cutout): implement boundary padding for cutout textures

- Introduced a new `Boundary Padding` preference in the Cutout Tool with a default of 2 px and a configurable range of 1-4 px.
- Updated the Cutout client to establish inward mapping from the final Mask, sampling in a fixed direction and processing independent material RGBA and Depth.
- Enhanced the handling of RGBA and Depth during cutout operations, ensuring proper mapping and preservation of source data.
- Added tests to validate the new boundary padding functionality and its integration with existing cutout processes.

feat(geometry): remove overall mesh smoothing from geometry nodes

- Removed the `Smooth` input from several geometry node groups to eliminate unnecessary overall mesh smoothing.
- Retained `Smooth Weight` for depth nodes while removing it from Cutout and Relief Plane nodes.
- Ensured that boundary, normal, and fill smoothing behaviors remain intact and consistent.
- Updated tests and documentation to reflect the changes in node interfaces and behaviors.

feat(normals): scale tangent normals with depth

- Reused the existing `o_normal_reduction` attribute to adjust Tangent Normal strength based on the geometry's `Depth Scale`.
- Ensured that Tangent Normal strength is consistent with the geometry depth, preserving full strength for materials that do not provide the attribute.
- Updated tests to verify the correct behavior of normal strength adjustments in both Tangent and Object Space.
This commit is contained in:
2026-09-15 00:40:24 +08:00
parent ab282e4fdf
commit 591e62085a
93 changed files with 1915 additions and 2851 deletions

View File

@@ -202,6 +202,9 @@ def test_relief_plane_builds_a_fixed_base_terrain_block():
for name in ("Thickness", "Depth Scale"):
identifier = object_data.modifier_input_identifier(group, name)
assert modifier[identifier] == 0.5
assert modifier[
object_data.modifier_input_identifier(group, "Depth Offset")
] == 1.0
def set_input(name, value):
object_data.set_modifier_input(
@@ -214,6 +217,7 @@ def test_relief_plane_builds_a_fixed_base_terrain_block():
set_input("Depth Scale", 0.0)
set_input("Thickness", 0.1)
set_input("Depth Offset", 0.0)
baseline = _evaluated_positions(result)
assert np.isclose(baseline[:, 2].min(), 0.0, atol=1e-6)
assert np.isclose(baseline[:, 2].max(), 0.1, atol=1e-6)
@@ -251,13 +255,12 @@ def test_relief_plane_builds_a_fixed_base_terrain_block():
set_input("Reference Depth", 0.95)
inward = _evaluated_positions(result)
assert np.isclose(inward[:, 2].min(), 0.0, atol=1e-6)
assert np.isclose(inward[:, 2].max(), 0.05, atol=1e-5)
assert np.isclose(inward[:, 2].max(), 0.1, atol=1e-5)
set_input("Reference Depth", 0.0)
limited = _evaluated_positions(result)
assert np.isclose(limited[:, 2].min(), 0.0, atol=1e-6)
assert limited[:, 2].max() > 0.0
assert limited[:, 2].max() < 0.001
assert np.isclose(limited[:, 2].max(), 0.1, atol=1e-5)
set_input("Reference Depth", 1.3)
outward_beyond_thickness = _evaluated_positions(result)
@@ -269,3 +272,47 @@ def test_relief_plane_builds_a_fixed_base_terrain_block():
assert np.allclose(sheet[:, 2], 0.2, atol=1e-5)
set_input("Reference Depth", 0.8)
assert np.allclose(_evaluated_positions(result)[:, 2], 0.0, atol=1e-5)
def test_relief_plane_initializes_a_fitted_depth_direction():
bpy.ops.wm.read_factory_settings(use_empty=True)
build_image_relief_plane_group(build_image_plane_group())
image = bpy.data.images.new("Sloped Relief", width=5, height=3)
source = bpy.data.objects.new("Sloped Relief", None)
source.empty_display_type = "IMAGE"
source.data = image
source.empty_display_size = 2.0
bpy.context.collection.objects.link(source)
bounds = image_data.image_empty_bounds(source)
x = bounds[0] + (np.arange(5) + 0.5) / 5 * (bounds[1] - bounds[0])
y = bounds[3] - (np.arange(3) + 0.5) / 3 * (bounds[3] - bounds[2])
xx, yy = np.meshgrid(x, y)
depth = 2.0 + 0.2 * xx + 0.1 * yy
depth_image = _depth_image(
np.repeat(depth[..., None], 3, axis=2),
np.ones(depth.shape, dtype=bool),
)
metadata = _depth_metadata(
((2.0, 0.0, 2.0), (0.0, 2.0, 1.0), (0.0, 0.0, 1.0)),
(5, 3),
2.0,
)
result = plane_object.create_depth_plane_object(
bpy.context,
source,
2,
bpy.data.materials.new("Sloped Relief Material"),
depth_image,
metadata,
"RELIEF",
)
modifier = result.modifiers[0]
direction = modifier[
object_data.modifier_input_identifier(modifier.node_group, "Depth Direction")
]
uniform_scale = modifier[
object_data.modifier_input_identifier(modifier.node_group, "Uniform Scale")
]
expected = np.asarray((0.2 * uniform_scale, 0.1 * uniform_scale, 1.0))
expected /= np.linalg.norm(expected)
np.testing.assert_allclose(direction, expected, atol=1e-6)