"""Build O Image Depth Cutout.""" 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 from ..common.smoothing import expand_smooth from ..common.cutout import _island_cleanup, _position_field, _remove_zero_thickness, _shade_output from ..common.depth_surface import project_depth_surface, store_surface_camera, remove_surface_attributes, split_depth_surface, thicken_depth_surface from ..common.smoothing import edge_boundary_field NODE_GROUP_NAME = "O Image Depth Cutout" def build_volume_fields(group, geometry): boundary = edge_boundary_field(group.nodes, group.links) store = group.nodes.new("GeometryNodeStoreNamedAttribute") store.domain, store.data_type = "POINT", "FLOAT" store.inputs["Name"].default_value = "o_balloon_surface_rim" group.links.new(geometry, store.inputs["Geometry"]) group.links.new(boundary, store.inputs["Value"]) profile = group.nodes.new("GeometryNodeInputNamedAttribute") profile.data_type = "FLOAT" profile.inputs["Name"].default_value = "o_balloon" links = group.links def math(operation, a, b): result = group.nodes.new("ShaderNodeMath") result.operation = operation for index, value in enumerate((a, b)): if isinstance(value, (int, float)): result.inputs[index].default_value = value else: links.new(value, result.inputs[index]) return result.outputs[0] position = group.nodes.new("GeometryNodeInputPosition") axes = group.nodes.new("ShaderNodeSeparateXYZ") links.new(position.outputs[0], axes.inputs[0]) seed = math("SUBTRACT", axes.outputs["Z"], profile.outputs["Attribute"]) center = group.nodes.new("GeometryNodeStoreNamedAttribute") center.domain, center.data_type = "POINT", "FLOAT" center.inputs["Name"].default_value = "o_balloon_surface_center" links.new(store.outputs["Geometry"], center.inputs["Geometry"]) links.new(seed, center.inputs["Value"]) current = group.nodes.new("GeometryNodeInputNamedAttribute") current.data_type = "FLOAT" current.inputs["Name"].default_value = "o_balloon_surface_center" rim = group.nodes.new("GeometryNodeInputNamedAttribute") rim.data_type = "FLOAT" rim.inputs["Name"].default_value = "o_balloon_surface_rim" interior = math("SUBTRACT", 1, rim.outputs["Attribute"]) blur = group.nodes.new("GeometryNodeBlurAttribute") blur.data_type = "FLOAT" blur.inputs["Iterations"].default_value = 256 links.new(current.outputs["Attribute"], blur.inputs["Value"]) links.new(interior, blur.inputs["Weight"]) update = group.nodes.new("GeometryNodeStoreNamedAttribute") update.domain, update.data_type = "POINT", "FLOAT" update.inputs["Name"].default_value = "o_balloon_surface_center" links.new(center.outputs["Geometry"], update.inputs["Geometry"]) links.new(blur.outputs[0], update.inputs["Value"]) baseline = group.nodes.new("GeometryNodeInputNamedAttribute") baseline.data_type = "FLOAT" baseline.inputs["Name"].default_value = "o_balloon_surface_center" profile_end = group.nodes.new("GeometryNodeInputNamedAttribute") profile_end.data_type = "FLOAT" profile_end.inputs["Name"].default_value = "o_balloon" position_end = group.nodes.new("GeometryNodeInputPosition") axes_end = group.nodes.new("ShaderNodeSeparateXYZ") links.new(position_end.outputs[0], axes_end.inputs[0]) residual = math("SUBTRACT", axes_end.outputs["Z"], baseline.outputs["Attribute"]) full = math("ADD", residual, profile_end.outputs["Attribute"]) minimum = math("MULTIPLY", profile_end.outputs["Attribute"], 0.05) positive = math("MAXIMUM", full, minimum) control = group.nodes.new("NodeGroupInput") scaled = math("MULTIPLY", positive, control.outputs["Thickness"]) thickness = group.nodes.new("GeometryNodeStoreNamedAttribute") thickness.domain, thickness.data_type = "POINT", "FLOAT" thickness.inputs["Name"].default_value = "o_balloon_surface_thickness" group.links.new(update.outputs["Geometry"], thickness.inputs["Geometry"]) group.links.new(scaled, thickness.inputs["Value"]) return thickness.outputs["Geometry"] def build_volume_rounding(group, volume): links = group.links def math(operation, a, b): result = group.nodes.new("ShaderNodeMath") result.operation = operation for index, value in enumerate((a, b)): if isinstance(value, (int, float)): result.inputs[index].default_value = value else: links.new(value, result.inputs[index]) return result.outputs[0] def read(name, kind="FLOAT"): result = group.nodes.new("GeometryNodeInputNamedAttribute") result.data_type = kind result.inputs["Name"].default_value = "o_balloon_surface_" + name return result.outputs["Attribute"] def store(geometry, name, value, kind="FLOAT"): result = group.nodes.new("GeometryNodeStoreNamedAttribute") result.data_type, result.domain = kind, "POINT" result.inputs["Name"].default_value = "o_balloon_surface_" + name links.new(geometry, result.inputs["Geometry"]) links.new(value, result.inputs["Value"]) return result.outputs["Geometry"] control = group.nodes.new("NodeGroupInput") profile = group.nodes.new("GeometryNodeInputNamedAttribute") profile.data_type = "FLOAT" profile.inputs["Name"].default_value = "o_balloon" balloon = profile.outputs["Attribute"] maximum = group.nodes.new("GeometryNodeAttributeStatistic") maximum.data_type, maximum.domain = "FLOAT", "POINT" links.new(volume, maximum.inputs["Geometry"]) links.new(balloon, maximum.inputs["Attribute"]) limit = math("MAXIMUM", maximum.outputs["Max"], 1e-8) falloff = group.nodes.new("ShaderNodeMapRange") falloff.interpolation_type = "SMOOTHERSTEP" falloff.inputs["To Min"].default_value = 1 falloff.inputs["To Max"].default_value = 0 links.new(balloon, falloff.inputs["Value"]) links.new(limit, falloff.inputs["From Max"]) weight = math("MULTIPLY", falloff.outputs[0], control.outputs["Edge Round"]) center = read("center") position = group.nodes.new("GeometryNodeInputPosition") axes = group.nodes.new("ShaderNodeSeparateXYZ") links.new(position.outputs[0], axes.inputs[0]) target = math("ADD", center, balloon) delta = math("SUBTRACT", target, axes.outputs["Z"]) delta = math("MULTIPLY", delta, weight) enabled = math("MINIMUM", control.outputs["Thickness"], 1) enabled = math("MAXIMUM", enabled, 0) delta = math("MULTIPLY", delta, enabled) carrier = store(volume, "edge_weight", weight) carrier = store(carrier, "front_delta", delta) rear = math("MULTIPLY", balloon, weight) rear = math("MULTIPLY", rear, control.outputs["Thickness"]) thickness = read("thickness") total = math("ADD", thickness, delta) total = math("ADD", total, rear) carrier = store(carrier, "thickness", total) # Evaluate normals on a separate center surface with identical point indices. center_position = group.nodes.new("ShaderNodeCombineXYZ") for axis in ("X", "Y"): links.new(axes.outputs[axis], center_position.inputs[axis]) links.new(center, center_position.inputs["Z"]) surface = group.nodes.new("GeometryNodeSetPosition") links.new(volume, surface.inputs["Geometry"]) links.new(center_position.outputs[0], surface.inputs["Position"]) normal = group.nodes.new("GeometryNodeInputNormal") blur = group.nodes.new("GeometryNodeBlurAttribute") blur.data_type = "FLOAT_VECTOR" 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]) 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(index.outputs[0], sample.inputs["Index"]) carrier = store(carrier, "normal", sample.outputs[0], "FLOAT_VECTOR") captured = read("front_delta") displacement = group.nodes.new("ShaderNodeCombineXYZ") links.new(captured, displacement.inputs["Z"]) front = group.nodes.new("GeometryNodeSetPosition") links.new(carrier, front.inputs["Geometry"]) links.new(displacement.outputs[0], front.inputs["Offset"]) return front.outputs[0] def _inflation_math(group, operation, a, b): result = group.nodes.new("ShaderNodeMath") result.operation = operation for index, value in enumerate((a, b)): if hasattr(value, "node"): group.links.new(value, result.inputs[index]) else: result.inputs[index].default_value = value return result.outputs[0] def _inflation_read(group, name, kind="FLOAT"): result = group.nodes.new("GeometryNodeInputNamedAttribute") result.data_type = kind result.inputs["Name"].default_value = "o_balloon_surface_" + name return result.outputs["Attribute"] def _inflation_store(group, geometry, name, value, kind="FLOAT"): result = group.nodes.new("GeometryNodeStoreNamedAttribute") result.data_type, result.domain = kind, "POINT" result.inputs["Name"].default_value = "o_balloon_surface_" + name group.links.new(geometry, result.inputs["Geometry"]) group.links.new(value, result.inputs["Value"]) return result.outputs["Geometry"] def build_front_fields(group, geometry): """Fit structural amplitude over neighbouring points before creating the shell.""" links = group.links def blur(value, weight=None): result = group.nodes.new("GeometryNodeBlurAttribute") result.data_type = "FLOAT" result.inputs["Iterations"].default_value = 256 links.new(value, result.inputs["Value"]) if weight is not None: links.new(weight, result.inputs["Weight"]) return result.outputs[0] profile_node = group.nodes.new("GeometryNodeInputNamedAttribute") profile_node.data_type = "FLOAT" profile_node.inputs["Name"].default_value = "o_balloon" profile = profile_node.outputs["Attribute"] rim = _inflation_read(group, "rim") interior = _inflation_math(group, "SUBTRACT", 1, rim) position = group.nodes.new("GeometryNodeInputPosition") axes = group.nodes.new("ShaderNodeSeparateXYZ") links.new(position.outputs[0], axes.inputs[0]) depth = axes.outputs["Z"] depth_slow = blur(depth, interior) profile_slow = blur(profile, interior) depth_bump = _inflation_math(group, "SUBTRACT", depth, depth_slow) profile_bump = _inflation_math(group, "SUBTRACT", profile, profile_slow) numerator = _inflation_math(group, "MULTIPLY", depth_bump, profile_bump) denominator = _inflation_math(group, "MULTIPLY", profile_bump, profile_bump) numerator = blur(numerator) denominator = blur(denominator) denominator = _inflation_math(group, "MAXIMUM", denominator, 1e-10) structure = _inflation_math(group, "DIVIDE", numerator, denominator) structure = _inflation_math(group, "MAXIMUM", structure, 0) carrier = _inflation_store(group, geometry, "structure", structure) normal = _inflation_read(group, "front_normal", "FLOAT_VECTOR") controls = group.nodes.new("NodeGroupInput") # Keep the accepted broad front-direction filter at the default of 50; # zero disables both this filter and the initial front/back normal filters. spread = _inflation_math(group, "MULTIPLY", controls.outputs["Normal Smooth"], 256 / 50) smooth = group.nodes.new("GeometryNodeBlurAttribute") 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]) carrier = _inflation_store(group, carrier, "inflation_normal", normalize.outputs[0], "FLOAT_VECTOR") return carrier def build_inflation_position(group, position, distance, uniform): """Grow both modes continuously while leaving the rear cap in place.""" links = group.links structure = _inflation_read(group, "structure") control = group.nodes.new("NodeGroupInput") a = _inflation_math(group, "MULTIPLY", control.outputs["Thickness"], control.outputs["Front Inflation"]) # A shifted cubic blend preserves continuous growth and height order. shifted = _inflation_math(group, "ADD", a, 0.75) quadratic = _inflation_math(group, "MULTIPLY", a, shifted) quadratic = _inflation_math(group, "ADD", quadratic, 0.1875) q = _inflation_math(group, "MULTIPLY", a, quadratic) k = _inflation_math(group, "ADD", structure, 0.25) square = _inflation_math(group, "MULTIPLY", k, k) cube = _inflation_math(group, "MULTIPLY", square, k) total = _inflation_math(group, "ADD", cube, q) root = _inflation_math(group, "POWER", total, 1 / 3) root_square = _inflation_math(group, "MULTIPLY", root, root) product = _inflation_math(group, "MULTIPLY", root, k) denominator = _inflation_math(group, "ADD", root_square, product) denominator = _inflation_math(group, "ADD", denominator, square) response = _inflation_math(group, "DIVIDE", q, denominator) profile = group.nodes.new("GeometryNodeInputNamedAttribute") profile.data_type = "FLOAT" profile.inputs["Name"].default_value = "o_balloon" balloon = _inflation_math(group, "MULTIPLY", profile.outputs["Attribute"], response) uniform_control = group.nodes.new("NodeGroupInput") uniform_amount = _inflation_math(group, "MULTIPLY", uniform_control.outputs["Uniform Thickness"], uniform_control.outputs["Front Inflation"]) selected = group.nodes.new("GeometryNodeSwitch") selected.input_type = "FLOAT" links.new(uniform, selected.inputs["Switch"]) links.new(balloon, selected.inputs["False"]) links.new(uniform_amount, selected.inputs["True"]) displacement = selected.outputs[0] height = _inflation_read(group, "thickness") layer = _inflation_math(group, "DIVIDE", distance, height) layer = _inflation_math(group, "ADD", 1, layer) layer = _inflation_math(group, "MAXIMUM", layer, 0) layer = _inflation_math(group, "MINIMUM", layer, 1) displacement = _inflation_math(group, "MULTIPLY", displacement, layer) normal = _inflation_read(group, "inflation_normal", "FLOAT_VECTOR") offset = group.nodes.new("ShaderNodeVectorMath") offset.operation = "SCALE" links.new(normal, offset.inputs[0]) links.new(displacement, offset.inputs[3]) result = group.nodes.new("ShaderNodeVectorMath") result.operation = "ADD" links.new(position, result.inputs[0]) links.new(offset.outputs[0], result.inputs[1]) return result.outputs[0] def build_front_normals(group, geometry): links = group.links normal = group.nodes.new("GeometryNodeInputNormal") control = group.nodes.new("NodeGroupInput") blur = group.nodes.new("GeometryNodeBlurAttribute") 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]) store = group.nodes.new("GeometryNodeStoreNamedAttribute") store.data_type, store.domain = "FLOAT_VECTOR", "POINT" store.inputs["Name"].default_value = "o_balloon_surface_front_normal" links.new(geometry, store.inputs["Geometry"]) links.new(normalize.outputs[0], store.inputs["Value"]) return store.outputs[0] def build_shell_position(group, position, uniform): links = group.links def connect(value, target): if hasattr(value, "node"): links.new(value, target) else: target.default_value = value def math(operation, a, b): result = group.nodes.new("ShaderNodeMath") result.operation = operation connect(a, result.inputs[0]) connect(b, result.inputs[1]) return result.outputs[0] def vector(operation, a, b): result = group.nodes.new("ShaderNodeVectorMath") result.operation = operation connect(a, result.inputs[0]) connect(b, result.inputs[3 if operation == "SCALE" else 1]) return result.outputs[0] def read(name, kind="FLOAT"): result = group.nodes.new("GeometryNodeInputNamedAttribute") result.data_type = kind result.inputs["Name"].default_value = name return result.outputs["Attribute"] def z(value): result = group.nodes.new("ShaderNodeSeparateXYZ") links.new(value, result.inputs[0]) return result.outputs["Z"] # Uniform and the thin end of Balloon share the actual front normal. front = read("o_depth_surface_position", "FLOAT_VECTOR") front_z = z(front) raw_z = z(position) distance = math("SUBTRACT", raw_z, front_z) normal = read("o_balloon_surface_front_normal", "FLOAT_VECTOR") thin_offset = vector("SCALE", normal, distance) uniform_position = vector("ADD", front, thin_offset) # R = t * (front_z - center) + (1 - t) * front_delta, with t clamped. # This avoids division by Thickness and removes the old zero-thickness drift. control = group.nodes.new("NodeGroupInput") clamp = group.nodes.new("ShaderNodeClamp") links.new(control.outputs["Thickness"], clamp.inputs["Value"]) t = clamp.outputs[0] center = read("o_balloon_surface_center") delta = read("o_balloon_surface_front_delta") radius = math("SUBTRACT", front_z, center) radius = math("MULTIPLY", radius, t) remaining = math("SUBTRACT", 1, t) remainder = math("MULTIPLY", remaining, delta) radius = math("ADD", radius, remainder) # Front and rear use the same edge field, evaluated on their own caps. edge = read("o_balloon_surface_edge_weight") mask = read("o_normal_scale") remaining = math("SUBTRACT", 1, edge) remaining = math("MULTIPLY", remaining, mask) weight = math("SUBTRACT", 1, remaining) difference = math("SUBTRACT", weight, edge) base = math("MULTIPLY", difference, radius) layer = math("MULTIPLY", weight, distance) rear_radius = math("ADD", base, layer) front_radius = math("MULTIPLY", edge, radius) normal = read("o_balloon_surface_normal", "FLOAT_VECTOR") direction = vector("SUBTRACT", normal, (0, 0, 1)) front_shift = vector("SCALE", direction, front_radius) front_position = vector("ADD", front, front_shift) rear_shift = vector("SCALE", direction, rear_radius) axis_offset = group.nodes.new("ShaderNodeCombineXYZ") links.new(distance, axis_offset.inputs["Z"]) full_offset = vector("ADD", axis_offset.outputs[0], rear_shift) # Smoothly reach the existing full-volume shape at Thickness >= 1. transition = group.nodes.new("ShaderNodeMapRange") transition.interpolation_type = "SMOOTHERSTEP" links.new(t, transition.inputs["Value"]) mix = group.nodes.new("ShaderNodeMix") mix.data_type = "VECTOR" links.new(transition.outputs[0], mix.inputs[0]) links.new(thin_offset, mix.inputs[4]) links.new(full_offset, mix.inputs[5]) balloon_position = vector("ADD", front_position, mix.outputs["Result"]) choose = group.nodes.new("GeometryNodeSwitch") choose.input_type = "VECTOR" links.new(uniform, choose.inputs["Switch"]) links.new(balloon_position, choose.inputs["False"]) links.new(uniform_position, choose.inputs["True"]) return build_inflation_position(group, choose.outputs[0], distance, uniform) def _build_depth_surface( group, geometry, thickness, depth_scale, split, uniform_scale, reference_depth, depth_image, ): nodes = group.nodes links = group.links geometry = split_depth_surface( group, geometry, depth_image, split, uniform_scale, triangles=True ) original_camera = _position_field(group, depth_image) geometry, camera_position = store_surface_camera( group, geometry, original_camera, split ) geometry = project_depth_surface( group, geometry, camera_position, uniform_scale, reference_depth, depth_scale ) shaped = thicken_depth_surface(group, geometry, thickness) geometry = _remove_zero_thickness( group, geometry, shaped, thickness ) return remove_surface_attributes(group, geometry) def _depth_volume(group): """Insert the volume field ahead of identity-based shell construction.""" links = group.links nodes = group.nodes projection = nodes["Set Position"].outputs["Geometry"] shell_input = nodes["Store Named Attribute.005"].inputs["Geometry"] projection = build_front_normals(group, projection) volume = build_volume_fields(group, projection) shared = build_front_fields(group, volume.node.inputs["Geometry"].links[0].from_socket) links.new(shared, volume.node.inputs["Geometry"]) uniform_control = group_input(group.nodes, {"Uniform Thickness"}) uniform = store_float_attribute(group, shared, "o_balloon_surface_thickness", uniform_control.outputs["Uniform Thickness"]) choose = menu_switch(group, "Mode", ("Balloon", "Uniform"), "GEOMETRY") links.new(volume, choose.inputs["Balloon"]) links.new(uniform, choose.inputs["Uniform"]) links.new(choose.outputs[0], shell_input) thickness = read_float_attribute(group, "o_balloon_surface_thickness") links.new(thickness, nodes["Math.018"].inputs[1]) control = group_input(group.nodes, {"Thickness", "Uniform Thickness"}) amount = menu_switch(group, "Mode", ("Balloon", "Uniform"), "FLOAT") links.new(control.outputs["Thickness"], amount.inputs["Balloon"]) links.new(control.outputs["Uniform Thickness"], amount.inputs["Uniform"]) links.new(amount.outputs[0], nodes["Math.019"].inputs[0]) identity_thickness = read_float_attribute(group, "o_balloon_surface_thickness") positive = math_node(group.nodes, "GREATER_THAN") positive.inputs[1].default_value = 1e-12 links.new(identity_thickness, positive.inputs[0]) layer = math_node(group.nodes, "MULTIPLY") links.new(positive.outputs[0], layer.inputs[0]) links.new(nodes["Separate XYZ.006"].outputs["Z"], layer.inputs[1]) links.new(layer.outputs[0], nodes["Combine XYZ.002"].inputs["Z"]) for name in ("Flip Faces", "Flip Faces.001"): source = nodes[name].outputs["Mesh"] outgoing = [link for link in links if link.from_socket == source] targets = [link.to_socket for link in outgoing] for link in outgoing: links.remove(link) masked = store_float_attribute(group, source, NORMAL_SCALE_ATTRIBUTE_NAME, 0.0, domain="FACE") for target in targets: links.new(masked, target) rounded = build_volume_rounding(group, volume) links.new(rounded, choose.inputs["Balloon"]) restored = nodes["Vector Math.004"].outputs[0] targets = [link.to_socket for link in restored.links] uniform_mode = choose.outputs[0].node.inputs["Switch"].links[0].from_socket oriented = build_shell_position(group, restored, uniform_mode) for target in targets: links.new(oriented, target) def build_image_depth_cutout_group(): name = NODE_GROUP_NAME existing = bpy.data.node_groups.get(name) if existing is not None: return existing 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 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') 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) 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) float_input(group, 'Front Inflation', 1.0, maximum=32, parent=options) normal_iterations = interface_socket(group, 'Normal Smooth', 'INPUT', 'NodeSocketInt', options) normal_iterations.default_value = 50 normal_iterations.min_value, normal_iterations.max_value = (0, 50) float_input(group, 'Smooth Weight', 1.0, maximum=1, subtype='FACTOR', parent=options) data = group.interface.new_panel(name='Data', default_closed=True) interface_socket(group, 'Inward Axis', 'INPUT', 'NodeSocketMenu', data).hide_in_modifier = True float_input(group, 'Uniform Scale', 1.0, parent=data).hide_in_modifier = True interface_socket(group, 'Depth Image', 'INPUT', 'NodeSocketImage', data).hide_in_modifier = True interface_socket(group, 'Geometry', 'OUTPUT', 'NodeSocketGeometry') controls = group_input(group.nodes, set()) geometry = _build_depth_surface(group, controls.outputs['Geometry'], controls.outputs['Thickness'], controls.outputs['Depth Scale'], controls.outputs['Split Threshold'], controls.outputs['Uniform Scale'], controls.outputs['Reference Depth'], controls.outputs['Depth Image']) _depth_volume(group) planar_inputs = [link.to_socket for link in group.links if link.from_node.bl_idname == 'NodeGroupInput' and link.from_socket.name == 'Geometry'] base = group_input(group.nodes, {'Geometry', 'Cleanup Threshold'}) area = math_node(group.nodes, 'MULTIPLY') area.inputs[1].default_value = 0.01 group.links.new(base.outputs['Cleanup Threshold'], area.inputs[0]) cleaned = _island_cleanup(group, base.outputs['Geometry'], area.outputs[0]) cleaned = store_float_attribute(group, cleaned, NORMAL_SCALE_ATTRIBUTE_NAME, 1.0, domain='FACE') for target in planar_inputs: group.links.new(cleaned, target) geometry = expand_smooth(group, geometry, iterations_name='Smooth', weight_name='Smooth Weight') remove = group.nodes.new('GeometryNodeRemoveAttribute') remove.pattern_mode = 'WILDCARD' remove.inputs['Name'].default_value = 'o_balloon_surface_*' group.links.new(geometry, remove.inputs['Geometry']) geometry = remove.outputs[0] orient = group.nodes.new('GeometryNodeTransform') orient.inputs['Rotation'].default_value = Matrix(CUTOUT_Z_TO_X).to_euler() group.links.new(geometry, orient.inputs['Geometry']) axis = menu_switch(group, 'Inward Axis', ('-Z', '+X'), 'GEOMETRY') group.links.new(geometry, axis.inputs['-Z']) group.links.new(orient.outputs[0], axis.inputs['+X']) _shade_output(group, axis.outputs[0]) projection = next((node.outputs['Geometry'] for node in group.nodes if node.bl_idname == 'GeometryNodeStoreNamedAttribute' and node.inputs['Name'].default_value == 'o_balloon_surface_front_normal')) group.links.new(projection, group.nodes['Switch.002'].inputs['True']) prepare_node_group(group) for item in group.interface.items_tree: if item.item_type != 'SOCKET' or item.in_out != 'INPUT': continue if item.name == 'Mode': item.default_value = 'Balloon' elif item.name == 'Inward Axis': item.default_value = '-Z' elif item.name == 'Uniform Thickness': item.name = 'Thickness' return group