feat(node_assets): add image plane geometry nodes and validation scripts
- Implemented `image_plane.py` to build the Image Plane Geometry Nodes group with customizable parameters for geometry, subdivide, and thickness. - Created `image_plane_validation.py` to validate the functionality of the image plane, ensuring correct geometry generation and material assignment. - Developed `material_layers.py` to construct shader node groups for image materials, including depth and normal handling. - Authored `plane_layouts.py` to define node arrangements for image geometry assets. - Introduced `shadeless.py` to create a shadeless shader node group that displays color without scene lighting while preserving shadows and reflections.
This commit is contained in:
@@ -1,68 +1,43 @@
|
||||
# 程序架构
|
||||
|
||||
AnyImage 由 Blender 交互层、BlendJob Runtime 和独立 Job Server 三部分组成。AI 依赖运行在 Server Environment 中,Blender 数据在主线程创建和修改。
|
||||
|
||||
## 对应文件
|
||||
|
||||
```text
|
||||
src/anyimage/
|
||||
├── __init__.py # 类型、工具、菜单与 Runtime 注册
|
||||
├── menu.py # Image Empty 上下文入口
|
||||
├── panel.py # Server 与 Debug 面板
|
||||
├── preferences.py # Storage Root、Device 与功能默认值
|
||||
├── properties.py # Scene 状态、模型状态与动态枚举
|
||||
├── runtime.py # Environment 和 JobRuntime
|
||||
├── common/ # Blender 侧共享原子能力
|
||||
├── operators/ # Blender 侧业务入口
|
||||
└── server/ # 独立计算端
|
||||
```
|
||||
|
||||
## 职责
|
||||
|
||||
| 层次 | 职责 |
|
||||
| 模块 | 职责 |
|
||||
| --- | --- |
|
||||
| Blender 交互层 | UI、手势、RNA 状态、输入准备、结果导入和 Undo |
|
||||
| BlendJob Runtime | Environment、Server 生命周期、队列、进度、取消和 Job 目录 |
|
||||
| Job Server | 媒体解码、ONNX 推理、数组派生和文件输出 |
|
||||
| `__init__.py` | 注册类型、工具、菜单、快捷键与 Runtime |
|
||||
| `menu.py`、`panel.py` | Image Empty 上下文菜单与 Job Server 面板 |
|
||||
| `preferences.py` | 扩展设置及读取入口 |
|
||||
| `properties.py` | Scene 手势状态、视频帧数、模型状态与枚举 |
|
||||
| `common/` | Blender 侧公共能力 |
|
||||
| `operators/` | 交互、任务参数、结果导入和 Undo |
|
||||
| `server/` | 独立环境内的媒体处理、推理和产物写出 |
|
||||
|
||||
Operator 向 Server 发送普通字典。Server 返回文件名和 Job 目录;Operator 的 `response()` 再读取这些文件,并在 Blender 主线程中创建 Image、Mesh、Material 和 Geometry Nodes Modifier。
|
||||
|
||||
## 注册与状态
|
||||
## 注册与配置
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
Register["anyimage.register()"] --> Types["注册 Preferences / PropertyGroup / Operator / Panel"]
|
||||
Types --> Tools["注册 Image Edit 与 Cutout WorkspaceTool"]
|
||||
Tools --> RNA["挂载 Scene 与 Image Property"]
|
||||
RNA --> Menu["挂载上下文菜单和剪贴板快捷键"]
|
||||
Menu --> Runtime["注册 JobRuntime"]
|
||||
A[register] --> B[按 CLASSES 顺序注册类型]
|
||||
B --> C[注册 Frame、Mask、Rectify、Cutout 工具]
|
||||
C --> D[挂载 Scene.anyimage_settings]
|
||||
D --> E[挂载 View3D 与 Outliner 菜单及剪贴板快捷键]
|
||||
E --> F[注册 JobRuntime]
|
||||
```
|
||||
|
||||
`__init__.py` 按依赖顺序注册,并在注销时逆序清理。扩展级设置统一由 `preferences.addon_preferences()` 读取;`runtime.py` 只消费 `configured_storage_root` 回调,不持有 Blender 偏好设置的定位逻辑。交互中的临时状态和 Debug 参数保存在 `Scene.anyimage_settings`。`max_ai_input_size`、`max_frame_resolution` 与 `max_cutout_mesh_resolution` 都在 `preferences.py` 定义与读取:它们分别限制 AI 分析图、Frame 输出和 Cutout 几何采样的最长边。Upscale 还用 AI 输入上限判断当前 Image 是否允许执行。
|
||||
注销先关闭 Runtime 和交互入口,再移除 Scene 属性,按 `CLASSES` 逆序注销类型。设备、存储目录、模型、材质显示适配和功能上限统一通过 `preferences.py` 读取。
|
||||
|
||||
## 同步与异步路径
|
||||
**Maximum AI Input Size** 限制模型分析图和 Upscale 可提交源图;**Maximum Frame Resolution** 限制 Frame 输出;**Maximum Cutout Mesh Resolution** 限制轮廓网格采样。三者各自作用于对应数据阶段。
|
||||
|
||||
无需 AI 或媒体处理的功能直接在 Blender 中完成,例如 Plane、Frame、Mask、Rectify,以及不生成 Normal Map 的 Surface 和 Balloon。需要模型或独立文件处理时,功能 Operator 派生自 `JobOperatorBase`:
|
||||
## 执行边界
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant User as 用户
|
||||
participant Op as Blender Operator
|
||||
participant RT as JobRuntime
|
||||
participant Job as Server Job
|
||||
User->>Op: 执行功能
|
||||
Op->>Op: 准备文件与普通字典
|
||||
Op->>RT: 提交 Job
|
||||
RT->>Job: 排队执行
|
||||
Job-->>RT: 写入产物并返回索引
|
||||
RT-->>Op: 主线程 response
|
||||
Op->>Op: 导入数据并提交 Undo
|
||||
flowchart TD
|
||||
A[Operator 在主线程读取 Blender 数据] --> B[准备输入文件]
|
||||
B --> C[request 返回普通字典]
|
||||
C --> D[BlendJob 队列执行 Server Job]
|
||||
D --> E[模型与媒体处理写入 Job 目录]
|
||||
E --> F[主线程 response 加载结果]
|
||||
F --> G[提交 Image 或 Object 修改及 Undo]
|
||||
G --> H[清理临时输入]
|
||||
```
|
||||
|
||||
`server/` 保持纯 Python 实现;Operator 在 Blender 主线程读取产物并创建 RNA 数据。
|
||||
Plane、Frame、Mask、Rectify 和无需 AI 的 Cutout 在 Blender 内执行。Server 的 `jobs/` 编排任务,`models/` 负责模型适配,`geometry/` 处理深度与法线产物。Server 模块通过内部相对导入共享能力,Blender 侧通过 `common/` 复用。
|
||||
|
||||
几何模型的原始输出先由 `server/models/` 适配为单帧 `GeometryFrame`。它统一保存 Depth、Validity、Intrinsics,以及可选的 Normal 和 Points;Depth、Normal 与 Metadata Writer 只消费该结构。MoGe-2 的 Mask 转为 `0/1` Validity,DA3 的 Confidence 作为连续 Validity。
|
||||
|
||||
## 共享能力
|
||||
|
||||
`common/` 按 AI、Image、Selection、Viewport、Depth、Material、Object 和 Node 八个业务模块提供 Blender 侧复用能力。公开函数见[Common 公共函数](common.md)。
|
||||
MoGe-2 输出统一为 `GeometryFrame`:包含 Depth、Validity、Intrinsics,以及按需提供的 Normal 和 Points。产物写入器消费同一个 Frame,保持深度、法线和相机数据一致。参见 [Runtime](runtime.md) 与 [产物协议](outputs.md)。
|
||||
|
||||
Reference in New Issue
Block a user