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:
@@ -59,7 +59,7 @@ def check_asset_library(asset_path):
|
||||
modifier.node_group = node_group
|
||||
values = {"Subdivide": 0, "Thickness": 0.2, "Reference Depth": 2.0,
|
||||
"Depth Image": depth_image, "Uniform Scale": 1.0, "Normal Smooth": 0,
|
||||
"Split Threshold": 0.0}
|
||||
"Depth Split": 0.0}
|
||||
for item in node_group.interface.items_tree:
|
||||
if item.item_type == "SOCKET" and item.in_out == "INPUT" and item.name in values:
|
||||
modifier[item.identifier] = values[item.name]
|
||||
|
||||
@@ -36,8 +36,8 @@ def taper_split_profile(group, original, geometry):
|
||||
rim = evaluate_field(group, edge_boundary_field(nodes, links), "FLOAT", "POINT")
|
||||
protected = sample_field(group, original, rim, "FLOAT", index=nearest.outputs["Index"])
|
||||
influence = boundary_influence(group, protected)
|
||||
controls = group_input(nodes, {"Split Threshold"})
|
||||
band = _math(group, "MULTIPLY", influence, _math(group, "GREATER_THAN", controls.outputs["Split Threshold"], 0))
|
||||
controls = group_input(nodes, {"Depth Split"})
|
||||
band = _math(group, "MULTIPLY", influence, _math(group, "GREATER_THAN", controls.outputs["Depth Split"], 0))
|
||||
retained = _math(group, "SQRT", _math(group, "MAXIMUM", _math(group, "SUBTRACT", 1, band), 0))
|
||||
profile = _math(group, "MULTIPLY", read_float_attribute(group, "o_balloon"), retained)
|
||||
return store_float_attribute(group, geometry, "o_balloon", profile)
|
||||
|
||||
@@ -107,19 +107,19 @@ def _set_segmented_layer_z(
|
||||
return merge.outputs["Geometry"]
|
||||
|
||||
|
||||
def _build_cutout(group, geometry, thickness):
|
||||
def _build_shell(group, geometry, thickness):
|
||||
nodes = group.nodes
|
||||
links = group.links
|
||||
half = math_node(nodes, "MULTIPLY")
|
||||
half.inputs[1].default_value = 0.5
|
||||
links.new(thickness, half.inputs[0])
|
||||
front = math_node(nodes, "MULTIPLY")
|
||||
front.inputs[1].default_value = 0.0
|
||||
links.new(thickness, front.inputs[0])
|
||||
back = math_node(nodes, "MULTIPLY")
|
||||
back.inputs[1].default_value = -1.0
|
||||
links.new(half.outputs[0], back.inputs[0])
|
||||
links.new(thickness, back.inputs[0])
|
||||
shaped = _set_segmented_layer_z(
|
||||
group,
|
||||
geometry,
|
||||
half.outputs[0],
|
||||
front.outputs[0],
|
||||
back.outputs[0],
|
||||
thickness,
|
||||
)
|
||||
@@ -158,26 +158,26 @@ def build_image_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'] = 13
|
||||
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, 'Thickness', 1.0).description = 'Control how much the surface bulges in Balloon mode. Zero removes the bulge.'
|
||||
float_input(group, 'Shell Thickness', 0.0, subtype='DISTANCE').description = 'Add thickness behind the original surface while keeping the front surface in place.'
|
||||
iterations = interface_socket(group, 'Smooth', 'INPUT', 'NodeSocketInt')
|
||||
iterations.description = 'Set the number of mesh smoothing passes. Higher values smooth the surface more but may soften details. Zero disables smoothing.'
|
||||
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, '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, 'Smooth Weight', 1.0, maximum=1, subtype='FACTOR', parent=options).description = 'Control the strength of each mesh smoothing pass. Higher values move vertices more.'
|
||||
interface_socket(group, 'Depth Axis', 'INPUT', 'NodeSocketMenu', options).menu_expanded = True
|
||||
interface_socket(group, 'Geometry', 'OUTPUT', 'NodeSocketGeometry')
|
||||
controls = group_input(group.nodes, set())
|
||||
balloon = _build_balloon(group, controls.outputs['Geometry'], controls.outputs['Thickness'])
|
||||
uniform = _build_cutout(group, controls.outputs['Geometry'], controls.outputs['Uniform Thickness'])
|
||||
choose = menu_switch(group, 'Mode', ('Balloon', 'Uniform'), 'GEOMETRY')
|
||||
shell = _build_shell(group, controls.outputs['Geometry'], controls.outputs['Shell Thickness'])
|
||||
choose = menu_switch(group, 'Mode', ('Balloon', 'Shell'), 'GEOMETRY')
|
||||
group.links.new(balloon, choose.inputs['Balloon'])
|
||||
group.links.new(uniform, choose.inputs['Uniform'])
|
||||
group.links.new(shell, choose.inputs['Shell'])
|
||||
geometry = choose.outputs[0]
|
||||
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'})
|
||||
@@ -198,15 +198,15 @@ def build_image_cutout_group():
|
||||
inflated.inputs['False'].default_value = 1
|
||||
group.links.new(enabled.outputs[0], inflated.inputs['Switch'])
|
||||
group.links.new(profile, inflated.inputs['True'])
|
||||
mode = menu_switch(group, 'Mode', ('Balloon', 'Uniform'), 'FLOAT')
|
||||
mode.inputs['Uniform'].default_value = 1
|
||||
mode = menu_switch(group, 'Mode', ('Balloon', 'Shell'), 'FLOAT')
|
||||
mode.inputs['Shell'].default_value = 1
|
||||
group.links.new(inflated.outputs[0], mode.inputs['Balloon'])
|
||||
scale = mode.outputs[0]
|
||||
geometry = store_float_attribute(group, geometry, NORMAL_SCALE_ATTRIBUTE_NAME, scale)
|
||||
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')
|
||||
axis = menu_switch(group, 'Depth 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])
|
||||
@@ -216,8 +216,8 @@ def build_image_cutout_group():
|
||||
continue
|
||||
if item.name == 'Mode':
|
||||
item.default_value = 'Balloon'
|
||||
elif item.name == 'Inward Axis':
|
||||
elif item.name == 'Depth Axis':
|
||||
item.default_value = '-Z'
|
||||
elif item.name == 'Uniform Thickness':
|
||||
elif item.name == 'Shell Thickness':
|
||||
item.name = 'Thickness'
|
||||
return group
|
||||
|
||||
@@ -110,21 +110,22 @@ def build_image_depth_balloon_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'] = 12
|
||||
group['anyimage_asset_revision'] = 14
|
||||
interface_socket(group, 'Geometry', 'INPUT', 'NodeSocketGeometry')
|
||||
float_input(group, 'Thickness', 1.0).description = 'Balloon profile multiplier; zero returns the sheet'
|
||||
float_input(group, 'Thickness', 1.0).description = 'Control how much the surface bulges. Zero removes the bulge.'
|
||||
float_input(group, 'Depth Scale', 1.0)
|
||||
bool_input(group, 'Double Sided', True)
|
||||
iterations = interface_socket(group, 'Smooth', 'INPUT', 'NodeSocketInt')
|
||||
iterations.description = 'Set the number of mesh smoothing passes. Higher values smooth the surface more but may soften details. Zero disables smoothing.'
|
||||
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, 'Smooth Weight', 1.0, maximum=1, subtype='FACTOR', parent=options)
|
||||
float_input(group, 'Smooth Weight', 1.0, maximum=1, subtype='FACTOR', parent=options).description = 'Control the strength of each mesh smoothing pass. Higher values move vertices more.'
|
||||
float_input(group, 'Reference Depth', 1.0, subtype='DISTANCE', parent=options)
|
||||
interface_socket(group, 'Depth Axis', 'INPUT', 'NodeSocketMenu', options).menu_expanded = True
|
||||
vector_input(group, 'Depth Direction', (0, 0, 1), subtype='DIRECTION', 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')
|
||||
@@ -145,7 +146,7 @@ def build_image_depth_balloon_group():
|
||||
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')
|
||||
axis = menu_switch(group, 'Depth 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])
|
||||
@@ -155,8 +156,6 @@ def build_image_depth_balloon_group():
|
||||
continue
|
||||
if item.name == 'Mode':
|
||||
item.default_value = 'Balloon'
|
||||
elif item.name == 'Inward Axis':
|
||||
elif item.name == 'Depth Axis':
|
||||
item.default_value = '-Z'
|
||||
elif item.name == 'Uniform Thickness':
|
||||
item.name = 'Thickness'
|
||||
return group
|
||||
|
||||
@@ -15,14 +15,14 @@ from ..common.cutout_boundary import remove_boundary_triangles, taper_split_prof
|
||||
NODE_GROUP_NAME = "O Image Depth Cutout"
|
||||
|
||||
|
||||
def build_normal_weight(group, uniform):
|
||||
def build_normal_weight(group, is_shell):
|
||||
"""Scale normal smoothing by the active mode's relative thickness."""
|
||||
control = group_input(group.nodes, {"Thickness", "Uniform Thickness", "Reference Depth"})
|
||||
control = group_input(group.nodes, {"Thickness", "Shell Thickness", "Reference Depth"})
|
||||
amount = group.nodes.new("GeometryNodeSwitch")
|
||||
amount.input_type = "FLOAT"
|
||||
group.links.new(uniform, amount.inputs["Switch"])
|
||||
group.links.new(is_shell, amount.inputs["Switch"])
|
||||
group.links.new(control.outputs["Thickness"], amount.inputs["False"])
|
||||
ratio = _math(group, "DIVIDE", control.outputs["Uniform Thickness"],
|
||||
ratio = _math(group, "DIVIDE", control.outputs["Shell Thickness"],
|
||||
_math(group, "MAXIMUM", control.outputs["Reference Depth"], 1e-8))
|
||||
group.links.new(ratio, amount.inputs["True"])
|
||||
ramp = group.nodes.new("ShaderNodeMapRange")
|
||||
@@ -73,7 +73,7 @@ def build_volume_fields(group):
|
||||
return {"rim": rim, "center": center, "thickness": thickness}
|
||||
|
||||
|
||||
def build_shell_fields(group, geometry, fields, uniform, normal_weight=1):
|
||||
def build_shell_fields(group, geometry, fields, is_shell, normal_weight=1):
|
||||
"""Evaluate rear directions on the center surface and select shell thickness."""
|
||||
nodes, links = group.nodes, group.links
|
||||
position = nodes.new("GeometryNodeInputPosition")
|
||||
@@ -93,12 +93,12 @@ def build_shell_fields(group, geometry, fields, uniform, normal_weight=1):
|
||||
links.new(normal.outputs[0], blur.inputs["Value"])
|
||||
normalized = blend_normal(group, normal.outputs[0], blur.outputs[0], normal_weight)
|
||||
rear_normal = sample_field(group, surface.outputs[0], normalized, "FLOAT_VECTOR")
|
||||
control = group_input(nodes, {"Uniform Thickness"})
|
||||
control = group_input(nodes, {"Shell Thickness"})
|
||||
thickness = nodes.new("GeometryNodeSwitch")
|
||||
thickness.input_type = "FLOAT"
|
||||
links.new(uniform, thickness.inputs["Switch"])
|
||||
links.new(is_shell, thickness.inputs["Switch"])
|
||||
links.new(fields["thickness"], thickness.inputs["False"])
|
||||
links.new(control.outputs["Uniform Thickness"], thickness.inputs["True"])
|
||||
links.new(control.outputs["Shell Thickness"], thickness.inputs["True"])
|
||||
return {"thickness": thickness.outputs[0], "normal": rear_normal}
|
||||
|
||||
|
||||
@@ -145,8 +145,8 @@ def build_front_fields(group, rim, front_normal, normal_weight=1):
|
||||
return {"structure": structure, "inflation_normal": normalized}
|
||||
|
||||
|
||||
def build_inflation_position(group, position, distance, uniform, fields):
|
||||
"""Grow both modes continuously while leaving the rear cap in place."""
|
||||
def build_inflation_position(group, position, distance, fields):
|
||||
"""Inflate the Balloon front while leaving the rear cap in place."""
|
||||
links = group.links
|
||||
|
||||
structure = fields["structure"]
|
||||
@@ -170,15 +170,7 @@ def build_inflation_position(group, position, distance, uniform, fields):
|
||||
profile = group.nodes.new("GeometryNodeInputNamedAttribute")
|
||||
profile.data_type = "FLOAT"
|
||||
profile.inputs["Name"].default_value = "o_balloon"
|
||||
balloon = _math(group, "MULTIPLY", profile.outputs["Attribute"], response)
|
||||
uniform_control = group.nodes.new("NodeGroupInput")
|
||||
uniform_amount = _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]
|
||||
displacement = _math(group, "MULTIPLY", profile.outputs["Attribute"], response)
|
||||
height = fields["thickness"]
|
||||
layer = _math(group, "DIVIDE", distance, height)
|
||||
layer = _math(group, "ADD", 1, layer)
|
||||
@@ -213,7 +205,7 @@ def build_front_normal(group, normal_weight):
|
||||
return evaluate_field(group, normalized, "FLOAT_VECTOR", "POINT")
|
||||
|
||||
|
||||
def build_shell_position(group, position, front, uniform, fields):
|
||||
def build_shell_position(group, position, front, is_shell, fields):
|
||||
links = group.links
|
||||
|
||||
def connect(value, target):
|
||||
@@ -234,13 +226,13 @@ def build_shell_position(group, position, front, uniform, fields):
|
||||
links.new(value, result.inputs[0])
|
||||
return result.outputs["Z"]
|
||||
|
||||
# Uniform and the thin end of Balloon share the actual front normal.
|
||||
# Shell and the thin end of Balloon share the actual front normal.
|
||||
front_z = z(front)
|
||||
raw_z = z(position)
|
||||
distance = _math(group, "SUBTRACT", raw_z, front_z)
|
||||
normal = fields["front_normal"]
|
||||
thin_offset = vector("SCALE", normal, distance)
|
||||
uniform_position = vector("ADD", front, thin_offset)
|
||||
shell_position = vector("ADD", front, thin_offset)
|
||||
|
||||
control = group_input(group.nodes, {"Thickness"})
|
||||
clamp = group.nodes.new("ShaderNodeClamp")
|
||||
@@ -267,16 +259,17 @@ def build_shell_position(group, position, front, uniform, fields):
|
||||
balloon_position = vector("ADD", front, 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, fields)
|
||||
links.new(is_shell, choose.inputs["Switch"])
|
||||
inflated = build_inflation_position(group, balloon_position, distance, fields)
|
||||
links.new(inflated, choose.inputs["False"])
|
||||
links.new(shell_position, choose.inputs["True"])
|
||||
return choose.outputs[0]
|
||||
|
||||
|
||||
def _build_depth_surface(group, geometry, controls):
|
||||
"""Project the mesh and sample front-surface fields while shaping the shell."""
|
||||
links = group.links
|
||||
split = controls.outputs["Split Threshold"]
|
||||
split = controls.outputs["Depth Split"]
|
||||
image = controls.outputs["Depth Image"]
|
||||
scale = controls.outputs["Uniform Scale"]
|
||||
original = geometry
|
||||
@@ -292,15 +285,15 @@ def _build_depth_surface(group, geometry, controls):
|
||||
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 = menu_switch(group, "Mode", ("Balloon", "Shell"), "BOOLEAN")
|
||||
mode.inputs["Balloon"].default_value = False
|
||||
mode.inputs["Uniform"].default_value = True
|
||||
uniform = mode.outputs[0]
|
||||
mode.inputs["Shell"].default_value = True
|
||||
is_shell = mode.outputs[0]
|
||||
volume = build_volume_fields(group)
|
||||
normal_weight = build_normal_weight(group, uniform)
|
||||
normal_weight = build_normal_weight(group, is_shell)
|
||||
normal = build_front_normal(group, normal_weight)
|
||||
front = build_front_fields(group, volume["rim"], normal, normal_weight)
|
||||
shell_fields = build_shell_fields(group, projection, volume, uniform, normal_weight)
|
||||
shell_fields = build_shell_fields(group, projection, volume, is_shell, normal_weight)
|
||||
thickness = sample_field(group, projection, shell_fields["thickness"], "FLOAT")
|
||||
shell = thicken_depth_surface(
|
||||
group, projection, thickness, back_mask=NORMAL_SCALE_ATTRIBUTE_NAME, weld_zero_thickness=True,
|
||||
@@ -317,13 +310,13 @@ def _build_depth_surface(group, geometry, controls):
|
||||
index=shell["source_index"])
|
||||
for name, value in shell_fields.items()
|
||||
})
|
||||
oriented = build_shell_position(group, shell["position"], shell["front"], uniform, fields)
|
||||
oriented = build_shell_position(group, shell["position"], shell["front"], is_shell, fields)
|
||||
links.new(oriented, shell["position_input"])
|
||||
amount = group.nodes.new("GeometryNodeSwitch")
|
||||
amount.input_type = "FLOAT"
|
||||
links.new(uniform, amount.inputs["Switch"])
|
||||
links.new(is_shell, amount.inputs["Switch"])
|
||||
links.new(controls.outputs["Thickness"], amount.inputs["False"])
|
||||
links.new(controls.outputs["Uniform Thickness"], amount.inputs["True"])
|
||||
links.new(controls.outputs["Shell Thickness"], amount.inputs["True"])
|
||||
return _remove_zero_thickness(group, projection, shell["geometry"], amount.outputs[0])
|
||||
|
||||
|
||||
@@ -335,29 +328,30 @@ 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'] = 23
|
||||
group['anyimage_asset_revision'] = 26
|
||||
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, 'Thickness', 1.0).description = 'Control how much the surface bulges in Balloon mode. Zero removes the bulge.'
|
||||
float_input(group, 'Shell Thickness', 0.5, subtype='DISTANCE').description = 'Add thickness behind the original surface while keeping the front surface in place.'
|
||||
float_input(group, 'Depth Scale', 1.0)
|
||||
float_input(group, 'Split Threshold', 0.1, maximum=1, subtype='FACTOR')
|
||||
float_input(group, 'Depth Split', 0.1, maximum=1, subtype='FACTOR').description = 'Split the mesh where depth changes abruptly. Higher values detect smaller depth jumps. Zero disables splitting.'
|
||||
iterations = interface_socket(group, 'Smooth', 'INPUT', 'NodeSocketInt')
|
||||
iterations.description = 'Set the number of mesh smoothing passes. Higher values smooth the surface more but may soften details. Zero disables smoothing.'
|
||||
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, 'Smooth Weight', 1.0, maximum=1, subtype='FACTOR', parent=options)
|
||||
float_input(group, 'Smooth Weight', 1.0, maximum=1, subtype='FACTOR', parent=options).description = 'Control the strength of each mesh smoothing pass. Higher values move vertices more.'
|
||||
float_input(group, 'Reference Depth', 1.0, subtype='DISTANCE', parent=options)
|
||||
interface_socket(group, 'Depth Axis', 'INPUT', 'NodeSocketMenu', options).menu_expanded = True
|
||||
boundary_smooth = interface_socket(group, 'Boundary Smooth', 'INPUT', 'NodeSocketInt', options)
|
||||
boundary_smooth.default_value, boundary_smooth.min_value, boundary_smooth.max_value = 2, 1, 20
|
||||
boundary_smooth.description = 'Boundary geometry iterations and depth blur steps per outline smoothing round'
|
||||
boundary_smooth.description = 'Control boundary smoothing within each Outline Depth Fix pass. Higher values apply more smoothing per pass.'
|
||||
outline_smooth = interface_socket(group, 'Outline Depth Fix', 'INPUT', 'NodeSocketInt', options)
|
||||
outline_smooth.default_value, outline_smooth.min_value, outline_smooth.max_value = 16, 0, 200
|
||||
outline_smooth.description = 'Adaptive ray-distance smoothing rounds around the original outline; preserves split boundary distance'
|
||||
float_input(group, 'Front Inflation', 0.0, maximum=1, subtype='FACTOR', parent=options)
|
||||
outline_smooth.description = 'Reduce abrupt depth changes near the original Cutout outline. Higher values apply more correction passes. Zero disables correction.'
|
||||
float_input(group, 'Front Inflation', 0.5, maximum=1, subtype='FACTOR', parent=options).description = 'Control how much the front surface bulges in Balloon mode. Zero keeps the original front surface.'
|
||||
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')
|
||||
@@ -373,7 +367,7 @@ def build_image_depth_cutout_group():
|
||||
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')
|
||||
axis = menu_switch(group, 'Depth 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])
|
||||
@@ -383,8 +377,8 @@ def build_image_depth_cutout_group():
|
||||
continue
|
||||
if item.name == 'Mode':
|
||||
item.default_value = 'Balloon'
|
||||
elif item.name == 'Inward Axis':
|
||||
elif item.name == 'Depth Axis':
|
||||
item.default_value = '-Z'
|
||||
elif item.name == 'Uniform Thickness':
|
||||
elif item.name == 'Shell Thickness':
|
||||
item.name = 'Thickness'
|
||||
return group
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Build O Image Depth Layer."""
|
||||
import bpy
|
||||
from anyimage.common.material import DEPTH_MATERIAL_NODE_GROUP_NAME
|
||||
from ..common.materials import build_material_nodes, connect_material_outputs
|
||||
from ..common.shader import build_material_nodes, connect_material_outputs
|
||||
|
||||
MATERIAL_DISPLACEMENT_ATTRIBUTE = "o_material_displacement"
|
||||
BACKGROUND_DEPTH_ATTRIBUTE = "o_background_depth"
|
||||
@@ -27,6 +27,7 @@ def build_image_depth_layer_group():
|
||||
socket.max_value = 1.0
|
||||
socket.subtype = 'FACTOR'
|
||||
elif name == 'Bump Scale':
|
||||
socket.description = 'Control bump detail derived from image brightness. Negative values reverse the bumps. Zero disables the effect.'
|
||||
socket.default_value = 0.0
|
||||
socket.min_value = -10000.0
|
||||
socket.max_value = 10000.0
|
||||
|
||||
@@ -10,7 +10,7 @@ from ..common.depth_surface import (
|
||||
_math, split_depth_surface, build_surface_camera, CUT_ATTRIBUTE,
|
||||
)
|
||||
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.material_slots import inherit_material_slots
|
||||
from ..common.smoothing import expand_smooth
|
||||
from ..common.boundary_smoothing import smooth_boundary_depth, smooth_cut_boundary
|
||||
|
||||
@@ -42,19 +42,24 @@ def build_image_depth_panorama_group():
|
||||
group["anyimage_asset_revision"] = 15
|
||||
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
|
||||
float_input(group, "Depth Scale", 1, maximum=1, subtype="FACTOR")
|
||||
float_input(group, "Split Threshold", 0, maximum=1, subtype="FACTOR")
|
||||
subdivide.description = "Increase mesh density to represent finer shapes. Higher levels create more vertices and require more processing time."
|
||||
subdivide.default_value, subdivide.min_value, subdivide.max_value = 8, 0, 8
|
||||
float_input(group, "Depth Scale", 1, maximum=1, subtype="FACTOR").description = "Blend between a sphere at zero and the estimated depth surface at one."
|
||||
float_input(group, "Depth Split", 0.1, maximum=1, subtype="FACTOR").description = "Split the mesh where depth changes abruptly. Higher values detect smaller depth jumps. Zero disables splitting."
|
||||
smooth = interface_socket(group, "Smooth", "INPUT", "NodeSocketInt")
|
||||
smooth.description = "Set the number of mesh smoothing passes. Higher values smooth the surface more but may soften details. Zero disables smoothing."
|
||||
smooth.default_value, smooth.min_value, smooth.max_value = 0, 0, 20
|
||||
interface_socket(group, "Valid Only", "INPUT", "NodeSocketBool").default_value = True
|
||||
valid_only = interface_socket(group, "Depth Mask", "INPUT", "NodeSocketBool")
|
||||
valid_only.default_value = True
|
||||
valid_only.description = "Remove mesh areas marked invalid by the depth mask."
|
||||
group.interface.move(valid_only, smooth.position)
|
||||
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)
|
||||
boundary_smooth.default_value, boundary_smooth.min_value, boundary_smooth.max_value = 2, 0, 20
|
||||
boundary_smooth.description = "Smooth depth and geometry near cut edges on the panorama surface. Zero disables boundary smoothing."
|
||||
float_input(group, "Smooth Weight", 1, maximum=1, subtype="FACTOR", parent=options).description = "Control the strength of each mesh smoothing pass. Higher values move vertices more."
|
||||
float_input(group, "Mask Threshold", 0.9, maximum=1, subtype="FACTOR", parent=options).description = "Set the minimum depth mask value treated as valid. Higher values exclude more partially valid boundary areas."
|
||||
float_input(group, "Invalid Distance", 100, minimum=1e-5, subtype="DISTANCE", parent=options).description = "Set the fallback distance from the panorama center for invalid depth areas kept when Depth Mask is disabled."
|
||||
data = group.interface.new_panel("Data", default_closed=True)
|
||||
interface_socket(group, "Depth Image", "INPUT", "NodeSocketImage", data).hide_in_modifier = True
|
||||
interface_socket(group, "Geometry", "OUTPUT", "NodeSocketGeometry")
|
||||
@@ -131,9 +136,9 @@ def build_image_depth_panorama_group():
|
||||
pixel = evaluate_field(group, pixel, "FLOAT_VECTOR", "POINT")
|
||||
nearest = nodes.new("FunctionNodeSeparateColor")
|
||||
links.new(texture(coordinates, "Closest"), nearest.inputs["Color"])
|
||||
controls = group_input(nodes, {"Validity Threshold"})
|
||||
controls = group_input(nodes, {"Mask Threshold"})
|
||||
invalid = _math(group, "MAXIMUM",
|
||||
_math(group, "LESS_THAN", nearest.outputs["Alpha"], controls.outputs["Validity Threshold"]),
|
||||
_math(group, "LESS_THAN", nearest.outputs["Alpha"], controls.outputs["Mask Threshold"]),
|
||||
_math(group, "LESS_THAN", nearest.outputs["Red"], 1e-5))
|
||||
face_invalid = evaluate_field(group, invalid, "FLOAT", "POINT")
|
||||
any_invalid = _math(group, "GREATER_THAN", face_invalid, 0)
|
||||
@@ -147,11 +152,11 @@ def build_image_depth_panorama_group():
|
||||
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(group_input(nodes, {"Depth Mask"}).outputs["Depth Mask"], selection.inputs["Switch"])
|
||||
links.new(delete.outputs[0], selection.inputs["False"])
|
||||
links.new(culled, selection.inputs["True"])
|
||||
controls = group_input(nodes, {"Split Threshold"})
|
||||
strength = controls.outputs["Split Threshold"]
|
||||
controls = group_input(nodes, {"Depth Split"})
|
||||
strength = controls.outputs["Depth Split"]
|
||||
face_camera = depth(combine(face_u, face_v))[0]
|
||||
radial = nodes.new("ShaderNodeSeparateXYZ")
|
||||
links.new(face_camera, radial.inputs[0])
|
||||
|
||||
@@ -29,6 +29,7 @@ def build_image_depth_plane_group(image_plane_group):
|
||||
geometry = _interface_socket(group, "Geometry", "INPUT", "NodeSocketGeometry")
|
||||
geometry.structure_type = "SINGLE"
|
||||
subdivide = _interface_socket(group, "Subdivide", "INPUT", "NodeSocketInt")
|
||||
subdivide.description = "Increase mesh density to represent finer shapes. Higher levels create more vertices and require more processing time."
|
||||
subdivide.default_value = 6
|
||||
subdivide.min_value = 0
|
||||
subdivide.max_value = 10
|
||||
@@ -36,23 +37,27 @@ def build_image_depth_plane_group(image_plane_group):
|
||||
thickness.default_value = 0.0
|
||||
thickness.min_value = 0.0
|
||||
thickness.subtype = "DISTANCE"
|
||||
thickness.description = "Inward shell distance"
|
||||
thickness.description = "Add shell thickness inward from the depth surface. Zero keeps a single surface."
|
||||
depth_scale = _interface_socket(group, "Depth Scale", "INPUT", "NodeSocketFloat")
|
||||
depth_scale.default_value = 1.0
|
||||
depth_scale.min_value = 0.0
|
||||
float_input(group, "Split Threshold", 0.1, maximum=1, subtype="FACTOR")
|
||||
float_input(group, "Depth Split", 0.1, maximum=1, subtype="FACTOR").description = "Split the mesh where depth changes abruptly. Higher values detect smaller depth jumps. Zero disables splitting."
|
||||
iterations = _interface_socket(group, "Smooth", "INPUT", "NodeSocketInt")
|
||||
iterations.description = "Set the number of mesh smoothing passes. Higher values smooth the surface more but may soften details. Zero disables smoothing."
|
||||
iterations.default_value = 0
|
||||
iterations.min_value, iterations.max_value = 0, 20
|
||||
valid_only = _interface_socket(group, "Valid Only", "INPUT", "NodeSocketBool")
|
||||
valid_only = _interface_socket(group, "Depth Mask", "INPUT", "NodeSocketBool")
|
||||
valid_only.description = "Remove mesh areas marked invalid by the depth mask."
|
||||
valid_only.default_value = True
|
||||
group.interface.move(valid_only, iterations.position)
|
||||
options = group.interface.new_panel(name="Options", default_closed=True)
|
||||
float_input(group, "Smooth Weight", 1.0, maximum=1, subtype="FACTOR", parent=options)
|
||||
float_input(group, "Smooth Weight", 1.0, maximum=1, subtype="FACTOR", parent=options).description = "Control the strength of each mesh smoothing pass. Higher values move vertices more."
|
||||
float_input(group, "Reference Depth", 1.0, subtype="DISTANCE", parent=options)
|
||||
boundary_smooth = _interface_socket(group, "Boundary Smooth", "INPUT", "NodeSocketInt", parent=options)
|
||||
boundary_smooth.default_value, boundary_smooth.min_value, boundary_smooth.max_value = 2, 0, 20
|
||||
boundary_smooth.description = "Smooth boundary depth and cut-edge geometry while preserving the original image border"
|
||||
validity_threshold = _interface_socket(group, "Validity Threshold", "INPUT", "NodeSocketFloat", parent=options)
|
||||
boundary_smooth.description = "Smooth depth and geometry near cut edges while preserving the original image border. Zero disables boundary smoothing."
|
||||
validity_threshold = _interface_socket(group, "Mask Threshold", "INPUT", "NodeSocketFloat", parent=options)
|
||||
validity_threshold.description = "Set the minimum depth mask value treated as valid. Higher values exclude more partially valid boundary areas."
|
||||
validity_threshold.default_value = 0.9
|
||||
validity_threshold.min_value, validity_threshold.max_value = 0.0, 1.0
|
||||
validity_threshold.subtype = "FACTOR"
|
||||
@@ -93,13 +98,13 @@ def build_image_depth_plane_group(image_plane_group):
|
||||
texture.interpolation, texture.extension = "Linear", "EXTEND"
|
||||
links.new(uv.outputs["Attribute"], texture.inputs["Vector"])
|
||||
links.new(texture_input.outputs["Depth Image"], texture.inputs["Image"])
|
||||
threshold_input = _group_input(nodes, {"Validity Threshold"})
|
||||
threshold_input = _group_input(nodes, {"Mask Threshold"})
|
||||
channels = nodes.new("FunctionNodeSeparateColor")
|
||||
channels.mode = "RGB"
|
||||
links.new(texture.outputs["Color"], channels.inputs["Color"])
|
||||
invalid = nodes.new("FunctionNodeCompare")
|
||||
invalid.data_type, invalid.operation = "FLOAT", "LESS_THAN"
|
||||
links.new(threshold_input.outputs["Validity Threshold"], invalid.inputs["B"])
|
||||
links.new(threshold_input.outputs["Mask Threshold"], invalid.inputs["B"])
|
||||
links.new(channels.outputs["Alpha"], invalid.inputs["A"])
|
||||
# Image Plane's normalized UV rectangle retains its original outline after cuts.
|
||||
uv_axes = nodes.new("ShaderNodeSeparateXYZ")
|
||||
@@ -110,28 +115,28 @@ def build_image_depth_plane_group(image_plane_group):
|
||||
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_controls = _group_input(nodes, {"Depth Mask"})
|
||||
cull = nodes.new("GeometryNodeSwitch")
|
||||
cull.input_type = "GEOMETRY"
|
||||
links.new(cull_controls.outputs["Valid Only"], cull.inputs["Switch"])
|
||||
links.new(cull_controls.outputs["Depth Mask"], cull.inputs["Switch"])
|
||||
links.new(culled, cull.inputs["True"])
|
||||
links.new(protected, cull.inputs["False"])
|
||||
split_input = _group_input(nodes, {"Split Threshold"})
|
||||
split_input = _group_input(nodes, {"Depth Split"})
|
||||
reference_input = _group_input(nodes, {"Reference Depth"})
|
||||
geometry, corner_camera, cut_vertex = split_depth_surface(
|
||||
group, cull.outputs["Output"], sample_face_camera(group, texture_input.outputs["Depth Image"]),
|
||||
split_input.outputs["Split Threshold"], reference_input.outputs["Reference Depth"],
|
||||
split_input.outputs["Depth Split"], reference_input.outputs["Reference Depth"],
|
||||
)
|
||||
camera = build_surface_camera(
|
||||
group, texture.outputs["Color"], corner_camera, cut_vertex,
|
||||
split_input.outputs["Split Threshold"],
|
||||
split_input.outputs["Depth Split"],
|
||||
)
|
||||
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"], split_input.outputs["Split Threshold"],
|
||||
depth_input.outputs["Depth Scale"], split_input.outputs["Depth Split"],
|
||||
)
|
||||
surface = smooth_cut_boundary(group, surface, original_boundary)
|
||||
shell_input = _group_input(nodes, {"Thickness"})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Build O Image Layer."""
|
||||
import bpy
|
||||
from anyimage.common.material import IMAGE_MATERIAL_NODE_GROUP_NAME
|
||||
from ..common.materials import build_material_nodes, connect_material_outputs
|
||||
from ..common.shader import build_material_nodes, connect_material_outputs
|
||||
|
||||
|
||||
def build_image_layer_group():
|
||||
@@ -26,17 +26,22 @@ def build_image_layer_group():
|
||||
socket.max_value = 1.0
|
||||
socket.subtype = 'FACTOR'
|
||||
elif name == 'Bump Scale':
|
||||
socket.description = 'Control bump detail derived from image brightness. Negative values reverse the bumps. Zero disables the effect.'
|
||||
socket.default_value = 0.0
|
||||
socket.min_value = -10000.0
|
||||
socket.max_value = 10000.0
|
||||
elif name == 'Normal':
|
||||
socket.default_value = (0.5, 0.5, 1.0, 1.0)
|
||||
elif name == 'Normal Scale':
|
||||
socket.description = 'Control the strength of surface detail from the normal map.'
|
||||
socket.default_value = 1.0
|
||||
socket.min_value = 0.0
|
||||
socket.max_value = 10.0
|
||||
elif name == 'Object Space':
|
||||
socket.description = 'Interpret the normal map in object space when enabled, or tangent space when disabled.'
|
||||
socket.default_value = False
|
||||
if name == 'Alpha Fix':
|
||||
socket.description = 'Reduce semi-transparent fringes around image edges. Higher values remove more faint edge pixels. Zero keeps the original transparency.'
|
||||
output_sockets = [('Color', 'NodeSocketColor'), ('Roughness', 'NodeSocketFloat'), ('Alpha', 'NodeSocketFloat'), ('Normal', 'NodeSocketVector')]
|
||||
for name, socket_type in output_sockets:
|
||||
interface.new_socket(name=name, in_out='OUTPUT', socket_type=socket_type)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import bpy
|
||||
|
||||
from ..common.nodes import prepare_node_group
|
||||
from ..common.material import inherit_material_slots
|
||||
from ..common.material_slots import inherit_material_slots
|
||||
|
||||
|
||||
IMAGE_PLANE_GROUP_NAME = "O Image Plane"
|
||||
@@ -61,6 +61,7 @@ def build_image_plane_group():
|
||||
geometry = new_socket(interface, "Geometry", "INPUT", "NodeSocketGeometry")
|
||||
geometry.structure_type = "SINGLE"
|
||||
subdivide = new_socket(interface, "Subdivide", "INPUT", "NodeSocketInt")
|
||||
subdivide.description = "Increase mesh density to represent finer shapes. Higher levels create more vertices and require more processing time."
|
||||
subdivide.default_value = 0
|
||||
subdivide.min_value = 0
|
||||
subdivide.max_value = 10
|
||||
|
||||
@@ -29,6 +29,7 @@ def build_image_relief_plane_group(image_plane_group):
|
||||
geometry = _interface_socket(group, "Geometry", "INPUT", "NodeSocketGeometry")
|
||||
geometry.structure_type = "SINGLE"
|
||||
subdivide = _interface_socket(group, "Subdivide", "INPUT", "NodeSocketInt")
|
||||
subdivide.description = "Increase mesh density to represent finer shapes. Higher levels create more vertices and require more processing time."
|
||||
subdivide.default_value = 6
|
||||
subdivide.min_value = 0
|
||||
subdivide.max_value = 10
|
||||
@@ -36,11 +37,12 @@ def build_image_relief_plane_group(image_plane_group):
|
||||
thickness.default_value = 0.5
|
||||
thickness.min_value = 0.0
|
||||
thickness.subtype = "DISTANCE"
|
||||
thickness.description = "Fixed relief base thickness"
|
||||
thickness.description = "Set the thickness of the flat base beneath the relief."
|
||||
depth_scale = _interface_socket(group, "Depth Scale", "INPUT", "NodeSocketFloat")
|
||||
depth_scale.default_value = 0.5
|
||||
depth_scale.min_value = 0.0
|
||||
smooth = _interface_socket(group, "Smooth", "INPUT", "NodeSocketInt")
|
||||
smooth.description = "Set the number of mesh smoothing passes. Higher values smooth the surface more but may soften details. Zero disables smoothing."
|
||||
smooth.default_value, smooth.min_value, smooth.max_value = 0, 0, 20
|
||||
options = group.interface.new_panel(name="Options", default_closed=True)
|
||||
base_plane_depth = _interface_socket(
|
||||
@@ -53,7 +55,7 @@ def build_image_relief_plane_group(image_plane_group):
|
||||
base_plane_depth.default_value = 1.0
|
||||
base_plane_depth.min_value = 0.0
|
||||
base_plane_depth.subtype = "DISTANCE"
|
||||
float_input(group, "Smooth Weight", 1.0, maximum=1, subtype="FACTOR", parent=options)
|
||||
float_input(group, "Smooth Weight", 1.0, maximum=1, subtype="FACTOR", parent=options).description = "Control the strength of each mesh smoothing pass. Higher values move vertices more."
|
||||
vector_input(group, "Depth Direction", (0, 0, 1), subtype="DIRECTION", parent=options)
|
||||
data = group.interface.new_panel(name="Data", default_closed=True)
|
||||
uniform_scale = _interface_socket(
|
||||
|
||||
Reference in New Issue
Block a user