Add tests and implement boundary smoothing and cutout functionality
- Introduced tests for boundary smoothing in `test_boundary_smoothing.py`, verifying that smoothing reduces stair-step artifacts while preserving boundary integrity. - Added tests for cutout boundary behavior in `test_cutout_boundary.py`, ensuring proper handling of boundary triangles and normal blending. - Created `test_temporary_attributes.py` to check the cleanup of temporary attributes across depth modifier branches, ensuring no warnings are raised. - Implemented point culling functionality in `test_validity.py`, confirming that invalid points are removed without affecting adjacent geometry. - Developed boundary smoothing logic in `boundary_smoothing.py`, allowing for depth smoothing while maintaining edge integrity. - Added cutout boundary management in `cutout_boundary.py`, including functions for removing boundary triangles and tapering thickness profiles. - Implemented validity checks in `validity.py` to ensure proper deletion of invalid vertices and associated wire edges.
This commit is contained in:
@@ -2,16 +2,51 @@
|
||||
import bpy
|
||||
from mathutils import Matrix
|
||||
from anyimage.operators.cutout_tool.shape import CUTOUT_Z_TO_X, NORMAL_SCALE_ATTRIBUTE_NAME
|
||||
from ..common.nodes import interface_socket, group_input, math_node, float_input, menu_switch, read_float_attribute, store_float_attribute, prepare_node_group, capture_fields, evaluate_field
|
||||
from ..common.nodes import interface_socket, group_input, math_node, float_input, menu_switch, read_float_attribute, store_float_attribute, prepare_node_group, sample_field, evaluate_field
|
||||
from ..common.smoothing import expand_smooth
|
||||
from ..common.boundary_smoothing import smooth_boundary_camera, smooth_cut_boundary
|
||||
from ..common.cutout import _island_cleanup, _position_field, _remove_zero_thickness, _shade_output
|
||||
from ..common.depth_surface import _math, project_depth_surface, build_surface_camera, split_depth_surface, sample_face_camera, thicken_depth_surface
|
||||
from ..common.smoothing import edge_boundary_field
|
||||
from ..common.cutout_boundary import remove_boundary_triangles, taper_split_profile
|
||||
|
||||
|
||||
NODE_GROUP_NAME = "O Image Depth Cutout"
|
||||
|
||||
|
||||
def build_normal_weight(group, uniform):
|
||||
"""Scale normal smoothing by the active mode's relative thickness."""
|
||||
control = group_input(group.nodes, {"Thickness", "Uniform Thickness", "Reference Depth"})
|
||||
amount = group.nodes.new("GeometryNodeSwitch")
|
||||
amount.input_type = "FLOAT"
|
||||
group.links.new(uniform, amount.inputs["Switch"])
|
||||
group.links.new(control.outputs["Thickness"], amount.inputs["False"])
|
||||
ratio = _math(group, "DIVIDE", control.outputs["Uniform Thickness"],
|
||||
_math(group, "MAXIMUM", control.outputs["Reference Depth"], 1e-8))
|
||||
group.links.new(ratio, amount.inputs["True"])
|
||||
ramp = group.nodes.new("ShaderNodeMapRange")
|
||||
ramp.interpolation_type = "SMOOTHSTEP"
|
||||
ramp.clamp = True
|
||||
group.links.new(amount.outputs[0], ramp.inputs["Value"])
|
||||
return ramp.outputs["Result"]
|
||||
|
||||
|
||||
def blend_normal(group, original, smoothed, weight):
|
||||
"""Normalize the thickness-weighted blend on the consumer geometry."""
|
||||
mix = group.nodes.new("ShaderNodeMix")
|
||||
mix.data_type = "VECTOR"
|
||||
if isinstance(weight, (int, float)):
|
||||
mix.inputs[0].default_value = weight
|
||||
else:
|
||||
group.links.new(weight, mix.inputs[0])
|
||||
group.links.new(original, mix.inputs[4])
|
||||
group.links.new(smoothed, mix.inputs[5])
|
||||
normalize = group.nodes.new("ShaderNodeVectorMath")
|
||||
normalize.operation = "NORMALIZE"
|
||||
group.links.new(mix.outputs["Result"], normalize.inputs[0])
|
||||
return normalize.outputs[0]
|
||||
|
||||
|
||||
def build_volume_fields(group):
|
||||
"""Evaluate the center and thickness on the original front surface."""
|
||||
links = group.links
|
||||
@@ -37,7 +72,7 @@ def build_volume_fields(group):
|
||||
return {"rim": rim, "center": center, "thickness": thickness}
|
||||
|
||||
|
||||
def build_volume_rounding(group, geometry, fields, uniform):
|
||||
def build_volume_rounding(group, geometry, fields, uniform, normal_weight=1):
|
||||
links = group.links
|
||||
|
||||
control = group.nodes.new("NodeGroupInput")
|
||||
@@ -87,39 +122,36 @@ def build_volume_rounding(group, geometry, fields, uniform):
|
||||
links.new(normal.outputs[0], blur.inputs["Value"])
|
||||
local = group.nodes.new("NodeGroupInput")
|
||||
links.new(local.outputs["Normal Smooth"], blur.inputs["Iterations"])
|
||||
normalize = group.nodes.new("ShaderNodeVectorMath")
|
||||
normalize.operation = "NORMALIZE"
|
||||
links.new(blur.outputs[0], normalize.inputs[0])
|
||||
normalized = blend_normal(group, normal.outputs[0], blur.outputs[0], normal_weight)
|
||||
index = group.nodes.new("GeometryNodeInputIndex")
|
||||
sample = group.nodes.new("GeometryNodeSampleIndex")
|
||||
sample.data_type, sample.domain = "FLOAT_VECTOR", "POINT"
|
||||
links.new(surface.outputs[0], sample.inputs["Geometry"])
|
||||
links.new(normalize.outputs[0], sample.inputs["Value"])
|
||||
links.new(normalized, sample.inputs["Value"])
|
||||
links.new(index.outputs[0], sample.inputs["Index"])
|
||||
thickness = group.nodes.new("GeometryNodeSwitch")
|
||||
thickness.input_type = "FLOAT"
|
||||
links.new(uniform, thickness.inputs["Switch"])
|
||||
links.new(total, thickness.inputs["False"])
|
||||
links.new(control.outputs["Uniform Thickness"], thickness.inputs["True"])
|
||||
carrier, captured = capture_fields(
|
||||
group, geometry, "POINT",
|
||||
edge_weight=("FLOAT", weight), front_delta=("FLOAT", delta),
|
||||
thickness=("FLOAT", thickness.outputs[0]), normal=("VECTOR", sample.outputs[0]),
|
||||
)
|
||||
rounding = {
|
||||
"edge_weight": weight, "front_delta": delta,
|
||||
"thickness": thickness.outputs[0], "normal": sample.outputs[0],
|
||||
}
|
||||
displacement = group.nodes.new("ShaderNodeCombineXYZ")
|
||||
links.new(captured["front_delta"], displacement.inputs["Z"])
|
||||
links.new(delta, displacement.inputs["Z"])
|
||||
front = group.nodes.new("GeometryNodeSetPosition")
|
||||
links.new(carrier, front.inputs["Geometry"])
|
||||
links.new(geometry, front.inputs["Geometry"])
|
||||
links.new(displacement.outputs[0], front.inputs["Offset"])
|
||||
choose = group.nodes.new("GeometryNodeSwitch")
|
||||
choose.input_type = "GEOMETRY"
|
||||
links.new(uniform, choose.inputs["Switch"])
|
||||
links.new(front.outputs[0], choose.inputs["False"])
|
||||
links.new(carrier, choose.inputs["True"])
|
||||
return choose.outputs[0], captured
|
||||
links.new(geometry, choose.inputs["True"])
|
||||
return choose.outputs[0], rounding
|
||||
|
||||
|
||||
def build_front_fields(group, rim, front_normal):
|
||||
def build_front_fields(group, rim, front_normal, normal_weight=1):
|
||||
"""Fit structural amplitude over neighbouring points before creating the shell."""
|
||||
links = group.links
|
||||
|
||||
@@ -162,10 +194,8 @@ def build_front_fields(group, rim, front_normal):
|
||||
smooth.data_type = "FLOAT_VECTOR"
|
||||
links.new(normal, smooth.inputs["Value"])
|
||||
links.new(spread, smooth.inputs["Iterations"])
|
||||
normalize = group.nodes.new("ShaderNodeVectorMath")
|
||||
normalize.operation = "NORMALIZE"
|
||||
links.new(smooth.outputs[0], normalize.inputs[0])
|
||||
return {"structure": structure, "inflation_normal": normalize.outputs[0]}
|
||||
normalized = blend_normal(group, normal, smooth.outputs[0], normal_weight)
|
||||
return {"structure": structure, "inflation_normal": normalized}
|
||||
|
||||
|
||||
def build_inflation_position(group, position, distance, uniform, fields):
|
||||
@@ -220,7 +250,7 @@ def build_inflation_position(group, position, distance, uniform, fields):
|
||||
return result.outputs[0]
|
||||
|
||||
|
||||
def build_front_normal(group):
|
||||
def build_front_normal(group, normal_weight):
|
||||
links = group.links
|
||||
normal = group.nodes.new("GeometryNodeInputNormal")
|
||||
control = group.nodes.new("NodeGroupInput")
|
||||
@@ -228,10 +258,8 @@ def build_front_normal(group):
|
||||
blur.data_type = "FLOAT_VECTOR"
|
||||
links.new(normal.outputs[0], blur.inputs["Value"])
|
||||
links.new(control.outputs["Normal Smooth"], blur.inputs["Iterations"])
|
||||
normalize = group.nodes.new("ShaderNodeVectorMath")
|
||||
normalize.operation = "NORMALIZE"
|
||||
links.new(blur.outputs[0], normalize.inputs[0])
|
||||
return evaluate_field(group, normalize.outputs[0], "FLOAT_VECTOR", "POINT")
|
||||
normalized = blend_normal(group, normal.outputs[0], blur.outputs[0], normal_weight)
|
||||
return evaluate_field(group, normalized, "FLOAT_VECTOR", "POINT")
|
||||
|
||||
|
||||
def build_shell_position(group, position, front, uniform, fields):
|
||||
@@ -316,36 +344,49 @@ def build_shell_position(group, position, front, uniform, fields):
|
||||
|
||||
|
||||
def _build_depth_surface(group, geometry, controls):
|
||||
"""Project the cleaned mesh, capture surface fields, and connect the shell."""
|
||||
"""Project the mesh and sample front-surface fields while shaping the shell."""
|
||||
links = group.links
|
||||
split = controls.outputs["Split Threshold"]
|
||||
image = controls.outputs["Depth Image"]
|
||||
scale = controls.outputs["Uniform Scale"]
|
||||
original = geometry
|
||||
geometry, corner_camera, cut_vertex = split_depth_surface(
|
||||
group, geometry, sample_face_camera(group, image), split, scale, triangles=True,
|
||||
)
|
||||
geometry = remove_boundary_triangles(group, geometry)
|
||||
camera = build_surface_camera(group, _position_field(group, image), corner_camera, cut_vertex, split)
|
||||
camera = smooth_boundary_camera(group, camera)
|
||||
projection = project_depth_surface(
|
||||
group, geometry, camera, scale, controls.outputs["Reference Depth"], controls.outputs["Depth Scale"],
|
||||
group, geometry, camera, scale, controls.outputs["Reference Depth"], controls.outputs["Depth Scale"], split,
|
||||
)
|
||||
projection = smooth_cut_boundary(group, projection)
|
||||
projection = taper_split_profile(group, original, projection)
|
||||
# The mode field is shared by the geometry and thickness choices.
|
||||
mode = menu_switch(group, "Mode", ("Balloon", "Uniform"), "BOOLEAN")
|
||||
mode.inputs["Balloon"].default_value = False
|
||||
mode.inputs["Uniform"].default_value = True
|
||||
uniform = mode.outputs[0]
|
||||
volume = build_volume_fields(group)
|
||||
normal = build_front_normal(group)
|
||||
front = build_front_fields(group, volume["rim"], normal)
|
||||
shared, fields = capture_fields(
|
||||
group, projection, "POINT",
|
||||
center=("FLOAT", volume["center"]), front_normal=("VECTOR", normal),
|
||||
structure=("FLOAT", front["structure"]), inflation_normal=("VECTOR", front["inflation_normal"]),
|
||||
)
|
||||
rounded, rounding = build_volume_rounding(group, shared, {**volume, **fields}, uniform)
|
||||
fields.update(rounding)
|
||||
normal_weight = build_normal_weight(group, uniform)
|
||||
normal = build_front_normal(group, normal_weight)
|
||||
front = build_front_fields(group, volume["rim"], normal, normal_weight)
|
||||
rounded, rounding = build_volume_rounding(group, projection, volume, uniform, normal_weight)
|
||||
thickness = sample_field(group, projection, rounding["thickness"], "FLOAT")
|
||||
shell = thicken_depth_surface(
|
||||
group, rounded, fields["thickness"], back_mask=NORMAL_SCALE_ATTRIBUTE_NAME, weld_zero_thickness=True,
|
||||
group, rounded, thickness, back_mask=NORMAL_SCALE_ATTRIBUTE_NAME, weld_zero_thickness=True,
|
||||
)
|
||||
fields = {
|
||||
name: sample_field(group, projection, value, data_type, index=shell["source_index"])
|
||||
for name, value, data_type in (
|
||||
("center", volume["center"], "FLOAT"), ("front_normal", normal, "FLOAT_VECTOR"),
|
||||
("structure", front["structure"], "FLOAT"), ("inflation_normal", front["inflation_normal"], "FLOAT_VECTOR"),
|
||||
)
|
||||
}
|
||||
fields.update({
|
||||
name: sample_field(group, projection, value, "FLOAT_VECTOR" if name == "normal" else "FLOAT",
|
||||
index=shell["source_index"])
|
||||
for name, value in rounding.items()
|
||||
})
|
||||
oriented = build_shell_position(group, shell["position"], shell["front"], uniform, fields)
|
||||
links.new(oriented, shell["position_input"])
|
||||
amount = group.nodes.new("GeometryNodeSwitch")
|
||||
@@ -364,17 +405,20 @@ def build_image_depth_cutout_group():
|
||||
group = bpy.data.node_groups.new(name, 'GeometryNodeTree')
|
||||
group.is_modifier, group.use_fake_user = (True, True)
|
||||
group.color_tag = 'GEOMETRY'
|
||||
group['anyimage_asset_revision'] = 11
|
||||
group['anyimage_asset_revision'] = 18
|
||||
interface_socket(group, 'Geometry', 'INPUT', 'NodeSocketGeometry')
|
||||
interface_socket(group, 'Mode', 'INPUT', 'NodeSocketMenu')
|
||||
float_input(group, 'Thickness', 1.0).description = 'Balloon profile multiplier; zero returns the sheet'
|
||||
float_input(group, 'Uniform Thickness', 0.0, subtype='DISTANCE').description = 'Distance used only by Uniform thickness mode'
|
||||
float_input(group, 'Depth Scale', 1.0)
|
||||
float_input(group, 'Split Threshold', 0.0, maximum=1, subtype='FACTOR')
|
||||
float_input(group, 'Split Threshold', 0.1, maximum=1, subtype='FACTOR')
|
||||
iterations = interface_socket(group, 'Smooth', 'INPUT', 'NodeSocketInt')
|
||||
iterations.default_value = 0
|
||||
iterations.min_value, iterations.max_value = (0, 20)
|
||||
options = group.interface.new_panel(name='Options', default_closed=True)
|
||||
boundary_smooth = interface_socket(group, 'Boundary Smooth', 'INPUT', 'NodeSocketInt', options)
|
||||
boundary_smooth.default_value, boundary_smooth.min_value, boundary_smooth.max_value = 5, 0, 20
|
||||
boundary_smooth.description = 'Smooth boundary depth and geometry along the original outline and split edges'
|
||||
float_input(group, 'Cleanup Threshold', 0.0, parent=options)
|
||||
float_input(group, 'Reference Depth', 1.0, subtype='DISTANCE', parent=options)
|
||||
float_input(group, 'Edge Round', 0.2, maximum=1, subtype='FACTOR', parent=options)
|
||||
|
||||
@@ -4,12 +4,15 @@ import math
|
||||
|
||||
import bpy
|
||||
|
||||
from ..common.validity import delete_invalid_points
|
||||
|
||||
from ..common.depth_surface import (
|
||||
_math, split_depth_surface, build_surface_camera,
|
||||
_math, split_depth_surface, build_surface_camera, CUT_ATTRIBUTE,
|
||||
)
|
||||
from ..common.nodes import float_input, group_input, interface_socket, prepare_node_group, evaluate_field
|
||||
from ..common.nodes import float_input, group_input, interface_socket, prepare_node_group, evaluate_field, remove_attributes
|
||||
from ..common.material import inherit_material_slots
|
||||
from ..common.smoothing import expand_smooth
|
||||
from ..common.boundary_smoothing import smooth_boundary_depth, smooth_cut_boundary
|
||||
|
||||
|
||||
def _quad_sphere(group, segments):
|
||||
@@ -36,6 +39,7 @@ def _quad_sphere(group, segments):
|
||||
def build_image_depth_panorama_group():
|
||||
group = bpy.data.node_groups.new("O Image Depth Panorama", "GeometryNodeTree")
|
||||
group.is_modifier = group.use_fake_user = True
|
||||
group["anyimage_asset_revision"] = 14
|
||||
interface_socket(group, "Geometry", "INPUT", "NodeSocketGeometry")
|
||||
subdivide = interface_socket(group, "Subdivide", "INPUT", "NodeSocketInt")
|
||||
subdivide.default_value, subdivide.min_value, subdivide.max_value = 7, 0, 8
|
||||
@@ -45,6 +49,9 @@ def build_image_depth_panorama_group():
|
||||
smooth.default_value, smooth.min_value, smooth.max_value = 0, 0, 20
|
||||
interface_socket(group, "Valid Only", "INPUT", "NodeSocketBool").default_value = True
|
||||
options = group.interface.new_panel("Options", default_closed=True)
|
||||
boundary_smooth = interface_socket(group, "Boundary Smooth", "INPUT", "NodeSocketInt", options)
|
||||
boundary_smooth.default_value, boundary_smooth.min_value, boundary_smooth.max_value = 5, 0, 20
|
||||
boundary_smooth.description = "Smooth boundary distance and cut-edge geometry on the sphere"
|
||||
float_input(group, "Smooth Weight", 1, maximum=1, subtype="FACTOR", parent=options)
|
||||
float_input(group, "Validity Threshold", 0.9, maximum=1, subtype="FACTOR", parent=options)
|
||||
float_input(group, "Invalid Distance", 100, minimum=1e-5, subtype="DISTANCE", parent=options)
|
||||
@@ -133,18 +140,20 @@ def build_image_depth_panorama_group():
|
||||
any_invalid = _math(group, "GREATER_THAN", face_invalid, 0)
|
||||
mixed = _math(group, "MULTIPLY", any_invalid,
|
||||
_math(group, "LESS_THAN", face_invalid, 1))
|
||||
selection = nodes.new("GeometryNodeSwitch")
|
||||
selection.input_type = "BOOLEAN"
|
||||
links.new(group_input(nodes, {"Valid Only"}).outputs["Valid Only"], selection.inputs["Switch"])
|
||||
links.new(mixed, selection.inputs["False"])
|
||||
links.new(any_invalid, selection.inputs["True"])
|
||||
protected = uv_map.outputs["Geometry"]
|
||||
culled = delete_invalid_points(group, protected, any_invalid)
|
||||
delete = nodes.new("GeometryNodeDeleteGeometry")
|
||||
delete.domain, delete.mode = "FACE", "ALL"
|
||||
links.new(uv_map.outputs["Geometry"], delete.inputs["Geometry"])
|
||||
links.new(selection.outputs[0], delete.inputs["Selection"])
|
||||
links.new(protected, delete.inputs["Geometry"])
|
||||
links.new(mixed, delete.inputs["Selection"])
|
||||
selection = nodes.new("GeometryNodeSwitch")
|
||||
selection.input_type = "GEOMETRY"
|
||||
links.new(group_input(nodes, {"Valid Only"}).outputs["Valid Only"], selection.inputs["Switch"])
|
||||
links.new(delete.outputs[0], selection.inputs["False"])
|
||||
links.new(culled, selection.inputs["True"])
|
||||
controls = group_input(nodes, {"Split Threshold", "Reference Distance"})
|
||||
strength = controls.outputs["Split Threshold"]
|
||||
geometry, corner_camera, cut_vertex = split_depth_surface(group, delete.outputs[0], depth(combine(face_u, face_v))[0], strength,
|
||||
geometry, corner_camera, cut_vertex = split_depth_surface(group, selection.outputs[0], depth(combine(face_u, face_v))[0], strength,
|
||||
_math(group, "DIVIDE", 1, controls.outputs["Reference Distance"]),
|
||||
face_center=face.outputs["Value"])
|
||||
distance = build_surface_camera(group, pixel, corner_camera, cut_vertex, strength)
|
||||
@@ -153,7 +162,7 @@ def build_image_depth_panorama_group():
|
||||
distance = nodes.new("GeometryNodeSwitch")
|
||||
distance.input_type = "FLOAT"
|
||||
links.new(face_invalid, distance.inputs["Switch"])
|
||||
links.new(axes.outputs["X"], distance.inputs["False"])
|
||||
links.new(smooth_boundary_depth(group, axes.outputs["X"], face_invalid), distance.inputs["False"])
|
||||
links.new(group_input(nodes, {"Invalid Distance"}).outputs["Invalid Distance"], distance.inputs["True"])
|
||||
controls = group_input(nodes, {"Depth Scale"})
|
||||
radius = _math(group, "ADD", 1, _math(group, "MULTIPLY", controls.outputs["Depth Scale"], _math(group, "SUBTRACT", distance.outputs[0], 1)))
|
||||
@@ -164,7 +173,12 @@ def build_image_depth_panorama_group():
|
||||
deform = nodes.new("GeometryNodeSetPosition")
|
||||
links.new(geometry, deform.inputs["Geometry"])
|
||||
links.new(radial.outputs[0], deform.inputs["Position"])
|
||||
geometry = expand_smooth(group, deform.outputs[0], iterations_name="Smooth", weight_name="Smooth Weight")
|
||||
geometry = remove_attributes(
|
||||
group, deform.outputs[0], CUT_ATTRIBUTE,
|
||||
enabled=_math(group, "GREATER_THAN", strength, 0.0),
|
||||
)
|
||||
geometry = smooth_cut_boundary(group, geometry)
|
||||
geometry = expand_smooth(group, geometry, iterations_name="Smooth", weight_name="Smooth Weight")
|
||||
flip = nodes.new("GeometryNodeFlipFaces")
|
||||
links.new(geometry, flip.inputs["Mesh"])
|
||||
smooth = nodes.new("GeometryNodeSetShadeSmooth")
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
|
||||
import bpy
|
||||
|
||||
from ..common.validity import delete_invalid_points
|
||||
|
||||
from ..common.nodes import group_input as _group_input, interface_socket as _interface_socket
|
||||
from ..common.nodes import prepare_node_group, float_input
|
||||
from ..common.nodes import prepare_node_group, float_input, evaluate_field
|
||||
from ..common.smoothing import expand_smooth
|
||||
from ..common.boundary_smoothing import smooth_boundary_camera, smooth_cut_boundary
|
||||
from ..common.depth_surface import (
|
||||
project_depth_surface, thicken_depth_surface,
|
||||
_math, project_depth_surface, thicken_depth_surface,
|
||||
split_depth_surface, sample_face_camera, build_surface_camera,
|
||||
)
|
||||
|
||||
@@ -22,6 +25,7 @@ def build_image_depth_plane_group(image_plane_group):
|
||||
"GeometryNodeTree",
|
||||
)
|
||||
group.is_modifier = True
|
||||
group["anyimage_asset_revision"] = 14
|
||||
geometry = _interface_socket(group, "Geometry", "INPUT", "NodeSocketGeometry")
|
||||
geometry.structure_type = "SINGLE"
|
||||
subdivide = _interface_socket(group, "Subdivide", "INPUT", "NodeSocketInt")
|
||||
@@ -43,6 +47,9 @@ def build_image_depth_plane_group(image_plane_group):
|
||||
valid_only = _interface_socket(group, "Valid Only", "INPUT", "NodeSocketBool")
|
||||
valid_only.default_value = True
|
||||
options = group.interface.new_panel(name="Options", default_closed=True)
|
||||
boundary_smooth = _interface_socket(group, "Boundary Smooth", "INPUT", "NodeSocketInt", parent=options)
|
||||
boundary_smooth.default_value, boundary_smooth.min_value, boundary_smooth.max_value = 5, 0, 20
|
||||
boundary_smooth.description = "Smooth boundary depth and cut-edge geometry while preserving the original image border"
|
||||
base_plane_depth = _interface_socket(
|
||||
group,
|
||||
"Reference Depth",
|
||||
@@ -111,16 +118,21 @@ def build_image_depth_plane_group(image_plane_group):
|
||||
invalid.data_type, invalid.operation = "FLOAT", "LESS_THAN"
|
||||
links.new(threshold_input.outputs["Validity Threshold"], invalid.inputs["B"])
|
||||
links.new(channels.outputs["Alpha"], invalid.inputs["A"])
|
||||
delete = nodes.new("GeometryNodeDeleteGeometry")
|
||||
delete.domain, delete.mode = "FACE", "ALL"
|
||||
links.new(plane.outputs["Geometry"], delete.inputs["Geometry"])
|
||||
links.new(invalid.outputs["Result"], delete.inputs["Selection"])
|
||||
# Image Plane's normalized UV rectangle retains its original outline after cuts.
|
||||
uv_axes = nodes.new("ShaderNodeSeparateXYZ")
|
||||
links.new(uv.outputs["Attribute"], uv_axes.inputs[0])
|
||||
u, v = uv_axes.outputs["X"], uv_axes.outputs["Y"]
|
||||
margin = _math(group, "MINIMUM", _math(group, "MINIMUM", u, v),
|
||||
_math(group, "MINIMUM", _math(group, "SUBTRACT", 1, u), _math(group, "SUBTRACT", 1, v)))
|
||||
original_boundary = evaluate_field(group, _math(group, "LESS_THAN", margin, 1e-6), "BOOLEAN", "POINT")
|
||||
protected = plane.outputs["Geometry"]
|
||||
culled = delete_invalid_points(group, protected, invalid.outputs["Result"])
|
||||
cull_controls = _group_input(nodes, {"Valid Only"})
|
||||
cull = nodes.new("GeometryNodeSwitch")
|
||||
cull.input_type = "GEOMETRY"
|
||||
links.new(cull_controls.outputs["Valid Only"], cull.inputs["Switch"])
|
||||
links.new(delete.outputs["Geometry"], cull.inputs["True"])
|
||||
links.new(plane.outputs["Geometry"], cull.inputs["False"])
|
||||
links.new(culled, cull.inputs["True"])
|
||||
links.new(protected, cull.inputs["False"])
|
||||
split_input = _group_input(nodes, {"Split Threshold"})
|
||||
geometry, corner_camera, cut_vertex = split_depth_surface(
|
||||
group, cull.outputs["Output"], sample_face_camera(group, texture_input.outputs["Depth Image"]),
|
||||
@@ -131,11 +143,13 @@ def build_image_depth_plane_group(image_plane_group):
|
||||
split_input.outputs["Split Threshold"],
|
||||
)
|
||||
depth_input = _group_input(nodes, {"Reference Depth", "Depth Scale"})
|
||||
camera = smooth_boundary_camera(group, camera, original_boundary)
|
||||
surface = project_depth_surface(
|
||||
group, geometry, camera,
|
||||
scale_input.outputs["Uniform Scale"], depth_input.outputs["Reference Depth"],
|
||||
depth_input.outputs["Depth Scale"],
|
||||
depth_input.outputs["Depth Scale"], split_input.outputs["Split Threshold"],
|
||||
)
|
||||
surface = smooth_cut_boundary(group, surface, original_boundary)
|
||||
shell_input = _group_input(nodes, {"Thickness", "Normal Smooth"})
|
||||
shell = thicken_depth_surface(
|
||||
group, surface, shell_input.outputs["Thickness"],
|
||||
|
||||
Reference in New Issue
Block a user