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

@@ -10,6 +10,7 @@ from ..common.image_data import (
)
from ..common.depth_data import camera_depth_values, depth_uniform_scale
from ..common.mesh_result import (
IMAGE_MATERIAL_NODE_GROUP_NAME,
create_image_material,
finalize_object_result,
load_asset_node_group,
@@ -30,6 +31,7 @@ from .geometry import (
)
from .shape import (
BALLOON_ATTRIBUTE_NAME,
BALLOON_CUTOUT_SHAPES,
CUTOUT_NODE_GROUP_NAME,
CUTOUT_SHAPE_INDICES,
DEPTH_CUTOUT_SHAPES,
@@ -124,6 +126,24 @@ def load_cutout_node_group():
return load_asset_node_group(CUTOUT_NODE_GROUP_NAME)
def _connect_balloon_normal_scale(material):
nodes = material.node_tree.nodes
image_layer = next(
node
for node in nodes
if node.bl_idname == "ShaderNodeGroup"
and node.node_tree is not None
and node.node_tree.name == IMAGE_MATERIAL_NODE_GROUP_NAME
)
attribute = nodes.new("ShaderNodeAttribute")
attribute.attribute_type = "GEOMETRY"
attribute.attribute_name = BALLOON_ATTRIBUTE_NAME
attribute.location = (-550.0, -250.0)
material.node_tree.links.new(
attribute.outputs["Fac"], image_layer.inputs["Normal Scale"]
)
def create_shape_object(
context,
source_object,
@@ -178,6 +198,8 @@ def create_shape_object(
scene=context.scene,
)
depth_reference = None
if shape in BALLOON_CUTOUT_SHAPES:
_connect_balloon_normal_scale(material)
uniform_scale = None
depth_direction = None
if shape in DEPTH_CUTOUT_SHAPES:

View File

@@ -19,3 +19,4 @@ CUTOUT_SHAPE_INDICES = {
}
CUTOUT_SHAPES = frozenset(CUTOUT_NODE_GROUP_NAMES)
DEPTH_CUTOUT_SHAPES = frozenset({"DEPTH_BALLOON", "DEPTH_SURFACE"})
BALLOON_CUTOUT_SHAPES = frozenset({"BALLOON", "DEPTH_BALLOON"})