feat: Add restore cutout depth extension with edge depth correction
- Introduced a new extension for restoring cutout depth with edge correction. - Implemented edge depth extension algorithm in `edge_depth.py` to enhance depth accuracy near cutout edges. - Updated `generate_moge_artifacts` to include an option for extending depth edges during depth generation. - Modified cutout job processing to enable edge depth extension based on depth request. - Added comprehensive tests for edge depth functionality, ensuring correct behavior under various scenarios. - Updated existing node loading functions to remove asset revision dependencies, simplifying the loading process. - Created new design and proposal documentation outlining the goals and decisions for the extension.
This commit is contained in:
@@ -40,8 +40,7 @@ def test_cutout_node_groups_are_loaded_from_the_asset():
|
||||
) as load:
|
||||
for shape in cutout_shape.CUTOUT_NODE_GROUP_NAMES:
|
||||
assert cutout_object.load_cutout_node_group(shape) is loaded
|
||||
load.assert_called_with(cutout_shape.CUTOUT_NODE_GROUP_NAMES[shape],
|
||||
asset_revision=26 if shape == "DEPTH_SOLID" else 14 if shape == "DEPTH_BALLOON" else 13)
|
||||
load.assert_called_with(cutout_shape.CUTOUT_NODE_GROUP_NAMES[shape])
|
||||
assert load.call_count == 4
|
||||
|
||||
|
||||
|
||||
@@ -81,17 +81,16 @@ def artifacts(tmp_path, source):
|
||||
|
||||
def test_result_replaces_source_with_zero_rotation_and_shadeless_material(source, artifacts, monkeypatch):
|
||||
result, operator = artifacts
|
||||
saved = bpy.data.node_groups.new("O Image Depth Panorama", "GeometryNodeTree")
|
||||
saved["anyimage_asset_revision"] = 11
|
||||
from anyimage.common.node import load_node_group
|
||||
saved = load_node_group("O Image Depth Panorama")
|
||||
matrix = Matrix.Translation((2, -3, 4)) @ Matrix.Rotation(0.6, 4, "Y") @ Matrix.Diagonal((2, 3, 4, 1))
|
||||
source.matrix_world = matrix
|
||||
source.empty_image_offset = (0.3, -0.8)
|
||||
undo = Mock(return_value={"FINISHED"})
|
||||
monkeypatch.setattr(conversion, "bpy", SimpleNamespace(data=bpy.data, ops=SimpleNamespace(ed=SimpleNamespace(undo_push=undo))))
|
||||
obj = conversion.create_panorama_from_result(bpy.context, result, operator)
|
||||
assert obj.modifiers[0].node_group != saved
|
||||
assert obj.modifiers[0].node_group["anyimage_asset_revision"] == 15
|
||||
assert saved in bpy.data.node_groups.values() and saved["anyimage_asset_revision"] == 11
|
||||
assert obj.modifiers[0].node_group == saved
|
||||
assert saved.name == "O Image Depth Panorama"
|
||||
assert obj.name == operator.source_object_name and obj.type == "MESH"
|
||||
np.testing.assert_allclose(obj.location, matrix.translation, atol=1e-6)
|
||||
np.testing.assert_allclose(obj.scale, matrix.to_scale(), atol=1e-6)
|
||||
|
||||
@@ -11,7 +11,7 @@ def test_conversion_preserves_offset_world_placement_and_initializes_inputs(surf
|
||||
|
||||
obj, _, _, inputs, image = surface
|
||||
group = obj.modifiers[0].node_group
|
||||
monkeypatch.setattr(conversion, "load_node_group", lambda name, *, asset_revision: group)
|
||||
monkeypatch.setattr(conversion, "load_node_group", lambda name: group)
|
||||
source = bpy.data.objects.new("Offset Image", None)
|
||||
source.empty_display_type = "IMAGE"
|
||||
source.data = image
|
||||
@@ -48,7 +48,7 @@ def test_failed_modifier_initialization_removes_partial_object(surface, monkeypa
|
||||
from anyimage.operators.convert_to_plane import object as conversion
|
||||
|
||||
obj, _, _, _, image = surface
|
||||
monkeypatch.setattr(conversion, "load_node_group", lambda name, *, asset_revision: obj.modifiers[0].node_group)
|
||||
monkeypatch.setattr(conversion, "load_node_group", lambda name: obj.modifiers[0].node_group)
|
||||
source = bpy.data.objects.new("Source", None)
|
||||
source.empty_display_type = "IMAGE"
|
||||
source.data = image
|
||||
|
||||
@@ -74,7 +74,6 @@ def test_clipboard_plane_uses_the_mesh_material_slot():
|
||||
def test_converted_planes_center_the_origin_without_moving_world_corners():
|
||||
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||
saved = build_image_depth_plane_group(build_image_plane_group())
|
||||
saved["anyimage_asset_revision"] = 11
|
||||
|
||||
def create_source(name):
|
||||
image = bpy.data.images.new(name, width=200, height=100)
|
||||
@@ -150,9 +149,8 @@ def test_converted_planes_center_the_origin_without_moving_world_corners():
|
||||
assert_centered(depth_plane, depth_bounds, depth_matrix)
|
||||
assert depth_plane["anyimage_mesh_shape"] == "DEPTH_PLANE"
|
||||
depth_modifier = depth_plane.modifiers[0]
|
||||
assert depth_modifier.node_group != saved
|
||||
assert depth_modifier.node_group["anyimage_asset_revision"] == 16
|
||||
assert saved in bpy.data.node_groups.values() and saved["anyimage_asset_revision"] == 11
|
||||
assert depth_modifier.node_group == saved
|
||||
assert saved.name == "O Image Depth Plane"
|
||||
uniform_scale = depth_modifier[
|
||||
object_data.modifier_input_identifier(
|
||||
depth_modifier.node_group,
|
||||
|
||||
Reference in New Issue
Block a user