Add cutout shell and volume node assets for depth volume processing

- Implemented `cutout_shell.py` to build front normals and shell positions for balloon geometry.
- Created `cutout_volume.py` to establish smooth center fields and manage balloon surface attributes.
- Introduced `pisa_sr_export.py` for exporting PiSA-SR components with dependencies and asset finalization.
This commit is contained in:
2026-09-08 17:18:03 +08:00
parent 7dec3b7ca4
commit 196b964efc
71 changed files with 3440 additions and 1988 deletions

View File

@@ -1,11 +1,11 @@
"""Arrange staggered calculation branches on both sides of the geometry path."""
from node_layout import arrange_nodes
from cutout_layout import route_geometry
# Main geometry advances left to right. Local fields grow to either side of it;
# a long calculation may start before the geometry input or span several stages.
POSITIONS = {
"Position": (0, 260),
"Position": (-240, 110),
"Store Named Attribute": (0, 0),
"Store Named Attribute.001": (260, 0),
"Store Named Attribute.002": (520, 0),
@@ -13,9 +13,9 @@ POSITIONS = {
"Split Edges": (1060, 0),
"Switch": (1360, 0),
# Face sampling stays near its stores; selection forms a dense field cluster.
"Named Attribute": (-400, -320),
"Evaluate on Domain": (-180, -320),
"Image Texture": (20, -320),
"Named Attribute": (-440, 380),
"Evaluate on Domain": (-220, 380),
"Image Texture": (20, 380),
"Named Attribute.003": (260, 260),
"Named Attribute.001": (-1090, 1060),
"Separate XYZ": (-870, 1060),
@@ -32,80 +32,55 @@ POSITIONS = {
"Math": (-530, 1040),
"Math.001": (-350, 1040),
"Math.002": (-170, 1040),
"Math.003": (-350, 830),
"Math.004": (10, 1040),
"Math.005": (190, 1040),
"Math.006": (190, 790),
"Math.007": (370, 980),
"Math.008": (190, 620),
"Math.009": (550, 910),
"Math.003": (190, 1040),
"Math.004": (190, 790),
"Math.005": (370, 980),
"Math.006": (190, 620),
"Math.007": (550, 910),
"Edge Neighbors": (370, 590),
"Math.010": (550, 590),
"Math.011": (730, 810),
"Math.008": (550, 590),
"Math.009": (730, 810),
"Evaluate on Domain.001": (730, 670),
"Evaluate on Domain.002": (910, 670),
"Math.012": (1090, 670),
"Math.013": (1360, 280),
# Cleanup is a separate compact cluster before projection.
"Face Area": (1460, 780),
"Mesh Island": (1460, 580),
"Accumulate Field": (1680, 780),
"Math.014": (1900, 580),
"Delete Geometry": (2120, 0),
"Math.010": (1090, 670),
"Math.011": (1360, 280),
# Camera-ray reconstruction runs below; scene projection runs above.
"Named Attribute.004": (1290, -440),
"Image Texture.001": (1510, -440),
"Separate XYZ.001": (1740, -440),
"Named Attribute.005": (1510, -710),
"Separate XYZ.002": (1740, -710),
"Math.017": (1960, -440),
"Math.014": (1960, -440),
"Vector Math.001": (2180, -440),
"Named Attribute.006": (1740, -940),
"Math.015": (1510, -940),
"Math.016": (1960, -940),
"Math.012": (1510, -940),
"Math.013": (1960, -940),
"Switch.001": (2600, -240),
"Store Named Attribute.004": (2920, 0),
"Named Attribute.007": (2340, 1080),
"Vector Math.002": (2560, 1080),
"Separate XYZ.003": (2740, 1080),
"Math.018": (3100, 730),
"Math.019": (3280, 730),
"Math.020": (2740, 910),
"Math.015": (3100, 730),
"Math.016": (3280, 730),
"Math.017": (2740, 910),
"Combine XYZ": (2920, 1040),
"Position.001": (2920, 790),
"Mix": (3100, 950),
"Separate XYZ.004": (3280, 950),
"Combine XYZ.001": (3460, 850),
"Set Position": (3870, 0),
# Short preparation fields sit above the axis; the long wall-count branch
# sits below, reading geometry back from the source-vertex store.
# Front and rear caps share a single extrusion along the geometry axis.
"Position.002": (4560, 340),
"Store Named Attribute.005": (4560, 0),
"Vector Math.003": (4780, 340),
"Set Position.001": (4780, 0),
"Index": (5010, 340),
"Store Named Attribute.006": (5010, 0),
"Edge Vertices": (3470, -610),
"Vector Math.004": (3700, -610),
"Edge Neighbors.001": (3470, -850),
"Math.021": (3700, -850),
"Attribute Statistic": (3920, -610),
"Math.022": (4150, -610),
"Math.023": (4370, -610),
"Math.024": (4590, -610),
"Math.025": (4820, -610),
"Math.026": (5040, -610),
"Store Named Attribute.007": (5310, 0),
"Repeat Input": (5620, 0),
"Extrude Mesh": (5850, 0),
"Combine XYZ.003": (5620, -340),
"Separate Geometry": (6070, 0),
"Join Geometry": (6300, -180),
"Repeat Output": (6520, 0),
"Flip Faces.001": (6740, 0),
"Join Geometry.001": (6970, 0),
"Named Attribute.010": (5620, -530),
"Math.027": (5850, -530),
"Extrude Mesh": (5500, 0),
"Combine XYZ.003": (5260, 350),
"Separate Geometry": (5780, 0),
"Flip Faces.001": (6300, 0),
"Join Geometry": (6970, 0),
"Combine XYZ.004": (6070, -530),
"Set Position.002": (6300, -320),
"Flip Faces": (6740, -320),
@@ -122,14 +97,12 @@ POSITIONS = {
"Merge by Distance": (7640, 0),
"Position.003": (6910, -950),
"Separate XYZ.005": (7160, -950),
"Named Attribute.011": (6900, -710),
"Math.028": (7140, -580),
"Math.029": (7380, -750),
"Math.018": (7380, -750),
"Combine XYZ.005": (7600, -680),
"Named Attribute.012": (7600, -370),
"Vector Math.005": (7830, -340),
"Named Attribute.010": (7600, -370),
"Vector Math.004": (7830, -340),
"Set Position.004": (8080, 0),
"Math.030": (8310, 260),
"Math.019": (8310, 260),
"Switch.002": (8310, 0),
"Remove Named Attribute": (9000, 0),
"Set Shade Smooth": (9220, 0),
@@ -139,71 +112,34 @@ POSITIONS = {
INPUT_REGIONS = (
(("Store Named Attribute",), (-240, 0)),
(("Switch",), (1100, -300)),
(("Image Texture",), (-180, -190)),
(("Image Texture",), (30, 520)),
(("Math.002",), (-350, 1140)),
(("Math.003",), (-530, 830)),
(("Math.005",), (10, 1140)),
(("Math.013",), (1100, 320)),
(("Math.014",), (1680, 400)),
(("Math.003",), (10, 1140)),
(("Math.011",), (1100, 320)),
(("Image Texture.001",), (1290, -270)),
(("Math.015",), (1290, -940)),
(("Math.012",), (1290, -940)),
(("Vector Math.002",), (2340, 1200)),
(("Math.018", "Math.019"), (2920, 680)),
(("Math.015", "Math.016"), (2920, 680)),
(("Mix",), (2920, 900)),
(("Math.023",), (4150, -820)),
(("Math.028",), (6900, -540)),
(("Math.030",), (8080, 300)),
(("Math.019",), (8080, 300)),
)
def _route(group, source_name, output, target_name, input_name, points):
"""Place geometry references around the local branches they serve."""
source = group.nodes[source_name].outputs[output]
target = group.nodes[target_name].inputs[input_name]
for link in list(group.links):
if link.from_socket == source and link.to_socket == target:
group.links.remove(link)
for point in points:
node = group.nodes.new("NodeReroute")
node.location = point
node.select = False
group.links.new(source, node.inputs[0])
source = node.outputs[0]
group.links.new(source, target)
def layout_geometry_references(group, stage):
"""Separate the split bypass and long projection references from fields."""
links = group.links
entry = stage["Store Named Attribute"].inputs["Geometry"]
source = entry.links[0].from_socket
fork = route_geometry(group, source, [(-3250, -40), (-1450, -40), (-290, -40)])
links.new(fork, entry)
bypass = route_geometry(group, fork, [(-210, -280), (500, -280), (1100, -280)])
links.new(bypass, stage["Switch"].inputs["False"])
def layout_depth_surface(group):
"""Keep the geometry path readable while staggering long and short branches."""
arrange_nodes(group, POSITIONS, INPUT_REGIONS)
_route(
group,
"Repeat Input",
"Sides",
"Join Geometry",
"Geometry",
((5810, -170), (6280, -170)),
)
_route(
group,
"Store Named Attribute.007",
"Geometry",
"Join Geometry.001",
"Geometry",
((5530, 150), (6950, 150)),
)
_route(
group,
"Store Named Attribute.007",
"Geometry",
"Set Position.002",
"Geometry",
((5530, -270), (6280, -270)),
)
_route(
group,
"Set Position",
"Geometry",
"Switch.002",
"True",
((4110, 240), (8290, 240)),
)
projection = next(n.outputs["Geometry"] for n in group.nodes if n.bl_idname == "GeometryNodeStoreNamedAttribute" and n.inputs["Name"].default_value == "o_balloon_surface_front_normal")
shared = next(n.outputs["Geometry"] for n in group.nodes if n.bl_idname == "GeometryNodeStoreNamedAttribute" and n.inputs["Name"].default_value == "o_balloon_surface_inflation_normal")
uniform = next(link.to_socket for link in shared.links if link.to_node.bl_idname == "GeometryNodeStoreNamedAttribute" and link.to_node.inputs["Name"].default_value == "o_balloon_surface_thickness")
fork = route_geometry(group, projection, [(4360, -40), (4650, -1700), (8500, -1700), (11400, -1700)])
uniform_route = route_geometry(group, shared, [(8250, -40), (8460, -1450), (11400, -1450), (11420, -370)])
links.new(uniform_route, uniform)
surface_route = route_geometry(group, fork, [(13500, -1700), (16800, -1700)])
links.new(surface_route, stage["Switch.002"].inputs["True"])