refactor: incorporate Depth Scale into Depth Split criteria for consistent geometry handling
This commit is contained in:
@@ -194,9 +194,12 @@ def ray_distance(group, camera):
|
||||
return length.outputs["Value"]
|
||||
|
||||
|
||||
def split_depth_surface(group, geometry, face_camera, strength, reference_depth, *,
|
||||
def split_depth_surface(group, geometry, face_camera, strength, reference_depth, depth_scale, *,
|
||||
face_distance=None, face_center=None, triangles=False):
|
||||
"""Split relative ray-distance jumps over the base face-center spacing."""
|
||||
"""Split relative ray-distance jumps over the base face-center spacing.
|
||||
|
||||
The jump is scaled by Depth Scale, so a flat projection keeps its faces.
|
||||
"""
|
||||
nodes, links = group.nodes, group.links
|
||||
if face_center is None:
|
||||
face_center = nodes.new("GeometryNodeInputPosition").outputs[0]
|
||||
@@ -224,6 +227,8 @@ def split_depth_surface(group, geometry, face_camera, strength, reference_depth,
|
||||
for index, center in enumerate(centers):
|
||||
links.new(center, distance.inputs[index])
|
||||
delta = _math(group, "ABSOLUTE", _math(group, "SUBTRACT", *depths))
|
||||
# Depth Scale is the display amplitude of that jump on the projected surface.
|
||||
delta = _math(group, "MULTIPLY", delta, depth_scale)
|
||||
local_distance = _math(group, "MAXIMUM", _math(group, "MULTIPLY", _math(group, "ADD", *depths), 0.5), 1e-8)
|
||||
reference = _math(group, "MAXIMUM", reference_depth, 1e-8)
|
||||
# Uniform Scale cancels between the distance jump and local spacing correction.
|
||||
@@ -262,7 +267,12 @@ def split_depth_surface(group, geometry, face_camera, strength, reference_depth,
|
||||
split = nodes.new("GeometryNodeSplitEdges")
|
||||
links.new(corners, split.inputs["Mesh"])
|
||||
links.new(selected, split.inputs["Selection"])
|
||||
enabled = compare_node(group, "GREATER_THAN", strength, 0.0)
|
||||
enabled = boolean_node(
|
||||
group,
|
||||
"AND",
|
||||
compare_node(group, "GREATER_THAN", strength, 0.0),
|
||||
compare_node(group, "GREATER_THAN", depth_scale, 0.0),
|
||||
)
|
||||
choose = nodes.new("GeometryNodeSwitch")
|
||||
choose.input_type = "GEOMETRY"
|
||||
links.new(enabled, choose.inputs["Switch"])
|
||||
|
||||
Reference in New Issue
Block a user