Add new functionality for image rectification and depth metadata handling
- Implemented a preview tool for rectifying images with interactive aspect controls in `preview.py`. - Added tests for depth metadata loading to ensure consistent schema usage in `test_depth_metadata.py`. - Developed comprehensive tests for cutout calibration processes in `test_cutout_calibration.py`, including stability checks and depth calibration. - Created tests for frame compositing operations in `test_frame_compositing.py`, ensuring correct handling of depth and transparency. - Introduced material slot inheritance functionality in `material_slots.py` to manage geometry material assignments. - Built shared shader nodes for material processing in `shader.py`, including roughness and bump mapping setups.
This commit is contained in:
@@ -1,27 +1,85 @@
|
||||
"""Check the saved library's public inventory and persistence."""
|
||||
import bpy
|
||||
import pytest
|
||||
from anyimage.common.node import load_node_group, node_asset_path
|
||||
from tools.nodes.check import GEOMETRY_NAMES, SHADER_NAMES
|
||||
from anyimage.common.node import node_asset_path
|
||||
from tools.nodes.check import GEOMETRY_NAMES
|
||||
|
||||
|
||||
def test_saved_asset_inventory():
|
||||
def test_saved_assets_evaluate():
|
||||
from tools.nodes.check import check_asset_library
|
||||
|
||||
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||
with bpy.data.libraries.load(str(node_asset_path())) as (source, _):
|
||||
assert set(source.node_groups) == GEOMETRY_NAMES | SHADER_NAMES
|
||||
for name in sorted(GEOMETRY_NAMES | SHADER_NAMES):
|
||||
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||
node_group = load_node_group(name)
|
||||
assert node_group.bl_idname == ("GeometryNodeTree" if name in GEOMETRY_NAMES else "ShaderNodeTree")
|
||||
assert node_group.use_fake_user and node_group.users > 0
|
||||
if name in GEOMETRY_NAMES:
|
||||
assert node_group.is_modifier
|
||||
if bpy.app.version >= (5, 0, 0):
|
||||
assert node_group.library is not None
|
||||
if name in {"O Image Depth Layer", "O Shadeless"}:
|
||||
expected = ["Color", "Alpha", "Depth", "Bump Scale"] if name == "O Image Depth Layer" else ["Color", "Alpha"]
|
||||
assert [item.name for item in node_group.interface.items_tree
|
||||
if item.item_type == "SOCKET" and item.in_out == "INPUT"] == expected
|
||||
check_asset_library(node_asset_path())
|
||||
|
||||
|
||||
def test_saved_parameter_descriptions_match_definitions():
|
||||
from tools.nodes.build import build_node_groups
|
||||
|
||||
parameters = {
|
||||
"O Image Plane": {"Subdivide"},
|
||||
"O Image Depth Plane": {
|
||||
"Subdivide", "Thickness", "Depth Split", "Smooth", "Smooth Weight",
|
||||
"Depth Mask", "Mask Threshold", "Boundary Smooth",
|
||||
},
|
||||
"O Image Relief Plane": {"Subdivide", "Thickness", "Smooth", "Smooth Weight"},
|
||||
"O Image Cutout": {"Thickness", "Smooth", "Smooth Weight"},
|
||||
"O Image Depth Cutout": {
|
||||
"Thickness", "Depth Split", "Smooth", "Smooth Weight",
|
||||
"Boundary Smooth", "Outline Depth Fix", "Front Inflation",
|
||||
},
|
||||
"O Image Depth Balloon": {"Thickness", "Smooth", "Smooth Weight"},
|
||||
"O Image Depth Panorama": {
|
||||
"Subdivide", "Depth Scale", "Depth Split", "Smooth", "Smooth Weight",
|
||||
"Depth Mask", "Mask Threshold", "Boundary Smooth", "Invalid Distance",
|
||||
},
|
||||
"O Image Layer": {"Alpha Fix", "Normal Scale", "Bump Scale", "Object Space"},
|
||||
"O Image Depth Layer": {"Bump Scale"},
|
||||
}
|
||||
|
||||
def descriptions(groups):
|
||||
result = {}
|
||||
for group in groups:
|
||||
if group.name not in parameters:
|
||||
continue
|
||||
sockets = [
|
||||
item for item in group.interface.items_tree
|
||||
if item.item_type == "SOCKET" and item.in_out == "INPUT"
|
||||
and item.name in parameters[group.name]
|
||||
]
|
||||
assert {item.name for item in sockets} == parameters[group.name]
|
||||
assert all(item.description for item in sockets), group.name
|
||||
if group.name == "O Image Depth Panorama":
|
||||
defaults = {item.name: item.default_value for item in sockets
|
||||
if item.name in {"Subdivide", "Depth Split", "Boundary Smooth"}}
|
||||
assert defaults == pytest.approx({
|
||||
"Subdivide": 8, "Depth Split": 0.1, "Boundary Smooth": 2,
|
||||
})
|
||||
if "Depth Mask" in parameters[group.name]:
|
||||
names = [item.name for item in group.interface.items_tree
|
||||
if item.item_type == "SOCKET" and item.in_out == "INPUT"]
|
||||
assert names.index("Depth Mask") == names.index("Depth Split") + 1
|
||||
if group.name in {"O Image Cutout", "O Image Depth Cutout"}:
|
||||
mode = next(node for node in group.nodes
|
||||
if node.bl_idname == "GeometryNodeMenuSwitch"
|
||||
and node.inputs["Menu"].links[0].from_socket.name == "Mode")
|
||||
assert [item.name for item in mode.enum_items] == ["Balloon", "Shell"]
|
||||
thickness = [item.description for item in sockets if item.name == "Thickness"]
|
||||
assert len(thickness) == 2 and len(set(thickness)) == 2
|
||||
if group.name == "O Image Depth Cutout":
|
||||
inflation = next(item for item in sockets if item.name == "Front Inflation")
|
||||
assert inflation.default_value == 0.5
|
||||
result[group.name] = [
|
||||
(item.identifier, item.name, item.description) for item in sockets
|
||||
]
|
||||
assert result.keys() == parameters.keys()
|
||||
return result
|
||||
|
||||
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||
expected = descriptions(build_node_groups())
|
||||
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||
with bpy.data.libraries.load(str(node_asset_path())) as (library, target):
|
||||
target.node_groups = list(library.node_groups)
|
||||
assert descriptions(target.node_groups) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize("source", ["definition", "asset"])
|
||||
|
||||
Reference in New Issue
Block a user