Refactor and enhance geometry node groups for depth plane and material layers

- Updated the depth plane node group to load from an asset and simplified the interface.
- Created a new build script for depth plane geometry nodes.
- Introduced material layer groups for image and depth materials with appropriate sockets.
- Added functionality to connect balloon normal scale to the image material.
- Enhanced tests to validate the new node groups and their connections.
- Ensured that production code does not create node groups directly.
This commit is contained in:
2026-08-31 12:25:23 +08:00
parent 87d7721128
commit 377eee43f5
18 changed files with 602 additions and 405 deletions

View File

@@ -11,8 +11,12 @@ sys.path.insert(
)
from anyimage.operators.common.mesh_result import (
DEPTH_MATERIAL_NODE_GROUP_NAME,
IMAGE_MATERIAL_NODE_GROUP_NAME,
load_asset_node_group,
node_asset_path,
)
from anyimage.operators.convert_to_plane.nodes import DEPTH_PLANE_NODE_GROUP_NAME
from anyimage.operators.cutout_tool.shape import (
CUTOUT_NODE_GROUP_NAME,
CUTOUT_NODE_GROUP_NAMES,
@@ -30,11 +34,25 @@ def input_names(group):
def main():
bpy.ops.wm.read_factory_settings(use_empty=True)
mesh_plane = load_asset_node_group("O Mesh Plane")
depth_plane = load_asset_node_group(DEPTH_PLANE_NODE_GROUP_NAME)
image_layer = load_asset_node_group(IMAGE_MATERIAL_NODE_GROUP_NAME)
depth_layer = load_asset_node_group(DEPTH_MATERIAL_NODE_GROUP_NAME)
shadeless = load_asset_node_group("O Shadeless")
cutout = load_asset_node_group(CUTOUT_NODE_GROUP_NAME)
cutout_groups = {
name: bpy.data.node_groups[name] for name in CUTOUT_NODE_GROUP_NAMES.values()
}
expected_names = {
"O Mesh Plane",
DEPTH_PLANE_NODE_GROUP_NAME,
IMAGE_MATERIAL_NODE_GROUP_NAME,
DEPTH_MATERIAL_NODE_GROUP_NAME,
"O Shadeless",
CUTOUT_NODE_GROUP_NAME,
*CUTOUT_NODE_GROUP_NAMES.values(),
}
with bpy.data.libraries.load(str(node_asset_path()), link=False) as (source, _):
assert set(source.node_groups) == expected_names
assert mesh_plane.name == "O Mesh Plane"
assert mesh_plane.bl_idname == "GeometryNodeTree"
@@ -45,6 +63,34 @@ def main():
"Thickness",
"Material",
]
assert depth_plane.bl_idname == "GeometryNodeTree"
assert depth_plane.is_modifier
assert input_names(depth_plane) == [
"Geometry",
"Subdivide",
"Thickness",
"Depth Amount",
"Reference Depth",
"Uniform Scale",
"Depth Image",
"Material",
]
assert image_layer.bl_idname == "ShaderNodeTree"
assert input_names(image_layer) == [
"Color",
"Alpha",
"Normal",
"Normal Scale",
"Object Space",
"Bump Scale",
]
assert depth_layer.bl_idname == "ShaderNodeTree"
assert input_names(depth_layer) == [
"Color",
"Alpha",
"Depth",
"Bump Scale",
]
assert shadeless.name == "O Shadeless"
assert shadeless.bl_idname == "ShaderNodeTree"
assert input_names(shadeless) == ["Color"]
@@ -59,7 +105,14 @@ def main():
assert not group.is_modifier
assert input_names(group)[0] == "Geometry"
public_groups = {mesh_plane, shadeless, cutout}
public_groups = {
mesh_plane,
depth_plane,
image_layer,
depth_layer,
shadeless,
cutout,
}
loaded = {*public_groups, *cutout_groups.values()}
assert all(group.use_fake_user for group in public_groups)
assert all(group.users > 0 for group in cutout_groups.values())