Files
AnyImage/tools/node_assets/geometry_layouts.py
nan 7dec3b7ca4 Add depth surface processing and layout tools
- Implemented `cutout_depth_surface.py` for face separation and connected thickness calculations for depth surface assets.
- Created `cutout_depth_surface_layout.py` to arrange nodes for staggered calculation branches in depth surface processing.
- Authored `geometry_layouts.py` to define layouts for various geometry assets, including image cutouts and depth planes.
- Introduced `node_layout.py` for shared presentation rules, facilitating node arrangement and validation in geometry-node layouts.
2026-09-07 19:21:03 +08:00

340 lines
12 KiB
Python

"""Authored processing stages for the shared image geometry assets."""
from node_layout import arrange_nodes
LAYOUTS = {
"O Mesh Plane": (
{
"Bounding Box": (-2320, 440),
"Vector Math": (-2100, 650),
"Separate XYZ": (-1870, 650),
"Math": (-1870, 990),
"Math.001": (-1650, 850),
"Math.002": (-1430, 850),
"Math.003": (-1200, 850),
"Math.004": (-980, 850),
"Math.005": (-760, 850),
"Math.006": (-1650, 510),
"Math.007": (-1430, 510),
"Math.008": (-1200, 510),
"Math.009": (-980, 510),
"Math.010": (-760, 510),
"Grid": (520, 340),
"Position": (-950, -480),
"Separate XYZ.001": (-720, -480),
"Math.011": (-500, -340),
"Math.012": (-280, -340),
"Math.013": (-500, -610),
"Math.014": (-280, -610),
"Combine XYZ": (0, -340),
"Store Named Attribute": (770, 340),
"Vector Math.001": (740, 710),
"Vector Math.002": (960, 710),
"Transform Geometry": (1030, 340),
"Bounding Box.001": (-1170, -990),
"Vector Math.003": (-950, -990),
"Separate XYZ.002": (-720, -990),
"Bounding Box.002": (-330, 140),
"Vector Math.004": (-100, 140),
"Separate XYZ.003": (120, 270),
"Math.015": (-520, 1390),
"Math.016": (-290, 1390),
"Math.017": (-520, 1160),
"Math.018": (-290, 1160),
"Math.019": (-70, 1390),
"Math.020": (150, 1390),
"Math.021": (380, 1390),
"Math.022": (600, 1390),
"Math.023": (830, 1390),
"Math.024": (1050, 1390),
"Combine XYZ.001": (280, 0),
"Cube": (520, -170),
"Store Named Attribute.001": (770, -170),
"Transform Geometry.001": (1030, -170),
"Compare": (1320, 410),
"Switch": (1360, 0),
"Capture Attribute": (1320, -580),
"Join Geometry": (1720, 0),
"Set Material Index": (1940, 0),
"Delete Geometry": (2170, 0),
"Group Output": (2390, 0),
},
(
(("Bounding Box",), (-2550, 440)),
(("Math",), (-2100, 1020)),
(("Math.021",), (150, 1600)),
(("Combine XYZ.001",), (120, 60)),
(("Compare",), (1140, 540)),
(("Capture Attribute",), (1140, -580)),
(("Bounding Box.001",), (-1390, -990)),
(("Bounding Box.002",), (-550, 140)),
),
),
"O Image Cutout": (
{
"Math": (-170, 580),
"Mesh Island": (-620, 140),
"Face Area": (-620, 340),
"Accumulate Field": (-400, 340),
"Math.001": (50, 310),
"Delete Geometry": (430, 270),
"Group": (1030, 520),
"Group.001": (1030, 300),
"Group.002": (1030, 80),
"Group.003": (1030, -220),
"Menu Switch": (1390, 240),
"Repeat Input": (2170, 0),
"Repeat Output": (5090, 0),
"Vertex Neighbors": (2170, -780),
"Compare": (2390, -780),
"Edge Neighbors": (1940, -1020),
"Compare.001": (2170, -1020),
"Evaluate on Domain": (2390, -1020),
"Boolean Math": (2610, -780),
"Evaluate on Domain.001": (2840, -580),
"Separate Geometry": (3110, -310),
"Position": (3300, 540),
"Blur Attribute": (3520, 540),
"Position.001": (3110, -780),
"Blur Attribute.001": (3340, -780),
"Sample Nearest": (3340, -310),
"Sample Index": (3590, -310),
"Vertex Neighbors.001": (2390, 950),
"Compare.002": (2610, 950),
"Edge Neighbors.001": (2170, 1220),
"Compare.003": (2390, 1220),
"Evaluate on Domain.002": (2610, 1220),
"Boolean Math.001": (2840, 950),
"Switch": (3890, 340),
"Mix": (4130, 340),
"Normal": (3060, 1500),
"Blur Attribute.002": (3280, 1500),
"Vector Math": (3510, 1500),
"Switch.001": (3730, 1500),
"Math.002": (3950, 1360),
"Switch.002": (4370, 410),
"Position.002": (4370, 680),
"Mix.001": (4660, 410),
"Set Position": (4830, 0),
"Transform Geometry": (5450, -340),
"Menu Switch.001": (5740, 0),
"Set Shade Smooth": (5970, 0),
"Group Output": (6190, 0),
},
(
(("Math",), (-400, 580)),
(("Delete Geometry",), (430, 530)),
(("Group",), (810, 520)),
(("Group.001",), (810, 300)),
(("Group.002",), (810, 80)),
(("Group.003",), (810, -220)),
(("Menu Switch",), (1390, 380)),
(("Repeat Input",), (1940, 0)),
(("Math.002",), (3730, 1220)),
(("Menu Switch.001",), (5520, 340)),
),
),
"O Image Depth Plane": (
{
"Group": (0, 0),
"Transform Geometry": (520, 0),
"Set Position": (2470, 0),
"Set Shade Smooth": (2730, 0),
"Group Output": (2990, 0),
"Math": (60, 340),
"Combine XYZ": (240, 340),
"Named Attribute": (240, -450),
"Image Texture": (460, -450),
"Separate XYZ": (640, -450),
"Math.001": (820, -450),
"Math.002": (1000, -450),
"Math.003": (1180, -450),
"Math.004": (1180, -660),
"Math.005": (1380, -450),
"Math.006": (1740, -1060),
"Switch": (1760, -450),
"Position": (820, -820),
"Separate XYZ.001": (1000, -820),
"Math.007": (1180, -820),
"Math.008": (1380, -820),
"Math.009": (1560, -820),
"Switch.001": (1760, -820),
"Math.010": (1970, -520),
"Combine XYZ.001": (2150, -520),
},
(
(("Group",), (-240, 0)),
(("Math",), (-120, 340)),
(("Image Texture",), (240, -310)),
(("Math.001",), (640, -310)),
(("Math.002", "Math.003"), (820, -590)),
(("Math.004",), (1000, -660)),
(("Math.006",), (1560, -1060)),
(("Math.007",), (1000, -980)),
),
),
"O Image Balloon": (
{
"Named Attribute": (-950, 440),
"Attribute Statistic": (-730, 1020),
"Math": (-500, 1020),
"Math.001": (-280, 1020),
"Map Range": (-50, 1020),
"Math.002": (-500, 440),
"Math.003": (-500, 240),
"Math.004": (-280, 240),
"Extrude Mesh": (0, 0),
"Switch": (220, 440),
"Position": (20, 240),
"Separate XYZ": (220, 240),
"Combine XYZ": (420, 340),
"Set Position": (690, 0),
"Separate Geometry": (910, 0),
"Flip Faces": (1140, 0),
"Combine XYZ.001": (910, 530),
"Set Position.001": (1140, 300),
"Combine XYZ.002": (690, -550),
"Set Position.002": (910, -300),
"Flip Faces.001": (1140, -300),
"Join Geometry": (1430, 0),
"Merge by Distance": (1650, 0),
"Math.005": (2100, 310),
"Switch.001": (2100, 0),
"Set Shade Smooth": (2320, 0),
"Group Output": (2550, 0),
},
(
(("Extrude Mesh",), (-220, 0)),
(("Attribute Statistic",), (-950, 1020)),
(("Math.002", "Math.003"), (-730, 240)),
(("Set Position.001",), (910, 300)),
(("Set Position.002",), (690, -300)),
(("Math.005",), (1870, 340)),
(("Switch.001",), (1870, -240)),
),
),
"O Image Surface": (
{
"Math": (-90, 680),
"Math.001": (140, 680),
"Edge Vertices": (-1630, -340),
"Vector Math": (-1410, -340),
"Edge Neighbors": (-1630, -560),
"Math.002": (-1410, -560),
"Attribute Statistic": (-1190, -340),
"Math.003": (-960, -340),
"Math.004": (-740, -340),
"Float to Integer": (-520, -340),
"Integer Math": (-290, -340),
"Integer Math.001": (-70, -340),
"Math.005": (190, -580),
"Math.006": (410, -580),
"Combine XYZ": (1630, 480),
"Set Position": (1860, 260),
"Repeat Input": (410, 0),
"Extrude Mesh": (640, 0),
"Separate Geometry": (860, 0),
"Join Geometry": (1080, -180),
"Repeat Output": (1310, 0),
"Combine XYZ.001": (1410, 270),
"Set Position.001": (1630, 0),
"Flip Faces": (1860, 0),
"Combine XYZ.002": (1410, -470),
"Set Position.002": (1630, -260),
"Flip Faces.001": (1860, -260),
"Join Geometry.001": (2150, 0),
"Merge by Distance": (2370, 0),
"Math.007": (2820, 290),
"Switch": (2820, 0),
"Set Shade Smooth": (3040, 0),
"Group Output": (3270, 0),
},
(
(("Math",), (-310, 680)),
(("Attribute Statistic",), (-1410, -170)),
(("Math.004",), (-960, -610)),
(("Math.005",), (-30, -580)),
(("Repeat Input",), (190, 0)),
(("Set Position",), (1630, 260)),
(("Set Position.002",), (1410, -260)),
(("Math.007",), (2600, 310)),
(("Switch",), (2600, -240)),
),
),
"O Image Depth Balloon": (
{
"Named Attribute": (-1120, 650),
"Attribute Statistic": (-890, 650),
"Math": (-670, 650),
"Math.001": (-450, 650),
"Map Range": (-220, 650),
"Named Attribute.001": (-1790, -440),
"Image Texture": (-1570, -440),
"Separate XYZ": (-1340, -440),
"Math.002": (-1120, -440),
"Vector Math": (-2240, -950),
"Separate XYZ.001": (-2010, -950),
"Position": (-2240, -1260),
"Separate XYZ.002": (-2010, -1260),
"Math.003": (-1790, -950),
"Math.004": (-1790, -1160),
"Math.005": (-1570, -950),
"Math.006": (-1340, -950),
"Math.007": (-1120, -950),
"Math.008": (-890, -440),
"Math.009": (-670, -440),
"Math.010": (-450, -440),
"Math.011": (-670, 310),
"Math.012": (-670, 70),
"Math.013": (-450, 70),
"Mix": (20, 440),
"Math.014": (240, 710),
"Switch": (460, 710),
"Extrude Mesh": (0, 0),
"Switch.001": (460, 310),
"Position.001": (280, 530),
"Separate XYZ.003": (460, 530),
"Combine XYZ": (660, 430),
"Set Position": (930, 0),
"Separate Geometry": (1150, 0),
"Flip Faces": (1600, 0),
"Combine XYZ.001": (1380, 570),
"Set Position.001": (1600, 330),
"Combine XYZ.002": (1150, -570),
"Set Position.002": (1380, -320),
"Flip Faces.001": (1600, -320),
"Join Geometry": (1870, 0),
"Merge by Distance": (2320, 0),
"Position.002": (1600, 1120),
"Separate XYZ.004": (1820, 1120),
"Combine XYZ.003": (2050, 950),
"Set Position.003": (2320, 680),
"Math.015": (2560, -270),
"Switch.002": (2560, 0),
"Set Shade Smooth": (2790, 0),
"Group Output": (3010, 0),
},
(
(("Extrude Mesh",), (-220, 0)),
(("Attribute Statistic",), (-1120, 850)),
(("Image Texture",), (-1790, -270)),
(("Math.002",), (-1340, -750)),
(("Vector Math",), (-2460, -950)),
(("Math.007",), (-1340, -1160)),
(("Math.010",), (-670, -650)),
(("Math.011", "Math.012"), (-890, 310)),
(("Switch",), (240, 920)),
(("Set Position.001",), (1380, 330)),
(("Set Position.002",), (1150, -320)),
(("Set Position.003",), (2100, 610)),
(("Math.015",), (2340, -270)),
),
),
}
def layout_geometry(group):
"""Apply the authored layout for one geometry asset."""
positions, inputs = LAYOUTS[group.name]
arrange_nodes(group, positions, inputs)