Files
AnyImage/docs/internals/operators/cutout-tool.md
nan f5aff50b13 Refactor and clean up codebase by removing unused functions and reorganizing imports
- Removed unused model keys and functions from properties.py.
- Deleted projection.py as its functions were no longer needed.
- Cleaned up model_catalog.py by removing unused model directory function.
- Updated imports in various test files to reflect new module structure.
- Removed deprecated test cases related to image editing tools.
- Added new tests for ONNX runtime provider selection logic.
2026-09-09 10:31:56 +08:00

40 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Cutout
Cutout 在静态 Image Empty 上圈定 Selection,按轮廓创建 Flat、Solid、Depth Solid 或 Depth Balloon。入口位于 `operators/cutout_tool/operators.py`,菜单与采样级别映射位于 `interaction.py`,标识和资产对应关系位于 `shape.py`。
```mermaid
flowchart TD
A[Lasso 拖动并提交 SelectionPath] --> B[选择 Shape]
B --> C[栅格化 SelectionMask 并读取源 RGBA]
C --> D{需要 Depth 或 Normal?}
D -- 是 --> E[准备 bounds 矩形 RGBA]
E --> F[generate-cutout-artifacts]
F --> G[加载 Depth、Metadata 与 Normal]
G --> H[源 Alpha 与 SelectionMask 组合]
D -- 否 --> H
H --> I[轮廓、采样、约束三角化与 o_balloon]
I --> J[BaseShape]
J --> K[创建材质、对象与对应节点修改器]
```
| 预设 | 节点组 | AI 产物 |
| --- | --- | --- |
| Flat | `O Image Cutout`,Thickness 0 | 可选 Tangent Normal |
| Solid | `O Image Cutout`,Thickness 1 | 可选 Tangent Normal |
| Depth Solid | `O Image Depth Cutout` | Depth 与 Object Normal |
| Depth Balloon | `O Image Depth Balloon` | Depth 与 Tangent Normal |
## 轮廓与网格
`geometry.py` 从内容 Alpha 提取连通轮廓和孔洞,按 Mesh Detail 采样并生成 `BaseShape`。Low、Medium、High、Ultra 分别以 32、16、8、4 个源像素作为基础间距,并受 Maximum Cutout Mesh Resolution 限制。
`fine_mesh.py` 负责 Fine Outline 的细节保留与约束网格,`polygon.py` 提供轮廓运算。Balloon Profile 按 Preferences 选择 Poisson 或 Teddy,生成所有预设共用的 POINT 属性 `o_balloon`。
## AI 与对象创建
Server 接收 Selection bounds 内保留源 Alpha 的 RGBA,一次 MoGe-2 推理按 `generate_depth` 与 `normal_mode` 返回产物。深度边缘延展使用所选 Alpha Threshold,Normal 使用原预测;AI 输入上限只影响分析分辨率。
`object.py` 的 `create_shape_object()` 消费 BaseShape、Color、Depth 和 Normal,加载对应节点组。基础网格位于局部 XY,向图片内部为 -Z;选择 +X 时节点与对象矩阵配对变换,保持世界几何一致。Object Normal 同步按方向转换。
材质使用 IOR 1.2,颜色进入 Image Layer,`o_normal_scale` 控制法线影响。Depth Solid 使用正面 FACE 标记,其他适用预设使用轮廓权重。节点计算见[节点资产](../node-assets.md)。