- Updated the depth plane node group to load from an asset and simplified the interface. - Created a new build script for depth plane geometry nodes. - Introduced material layer groups for image and depth materials with appropriate sockets. - Added functionality to connect balloon normal scale to the image material. - Enhanced tests to validate the new node groups and their connections. - Ensured that production code does not create node groups directly.
61 lines
2.8 KiB
Markdown
61 lines
2.8 KiB
Markdown
# 节点资产
|
||
|
||
AnyImage 将生产功能使用的可复用 Geometry Nodes 和 Shader 节点组统一构建到 `O_AnyImage.blend`,运行时只按名称加载,不动态创建节点组。
|
||
|
||
## 对应文件
|
||
|
||
```text
|
||
src/anyimage/
|
||
├── assets/O_AnyImage.blend
|
||
├── operators/common/mesh_result.py # 运行时资产加载与 Modifier 输入
|
||
└── operators/convert_to_plane/nodes.py # Plane 节点资产名称与加载入口
|
||
|
||
tools/node_assets/
|
||
├── build.py # 统一构建入口
|
||
├── node_graph.py # Cutout 资产构建专用节点图函数
|
||
├── build_mesh_plane.py
|
||
├── build_depth_plane.py
|
||
├── build_material_layers.py
|
||
├── build_shadeless.py
|
||
├── build_cutout.py
|
||
├── validate.py # 资产清单与基础接口
|
||
├── validate_mesh_plane.py
|
||
└── validate_cutout.py
|
||
```
|
||
|
||
## 构建与加载
|
||
|
||
```mermaid
|
||
flowchart TD
|
||
Scripts["tools/node_assets/build_*.py"] --> Build["Blender 后台构建"]
|
||
Build --> Blend["assets/O_AnyImage.blend"]
|
||
Blend --> Loader["operators/common/mesh_result.py"]
|
||
Loader --> Modifier["运行时 Node Group / Modifier"]
|
||
```
|
||
|
||
使用 Blender 而不是普通 Python 执行:
|
||
|
||
```bash
|
||
BLENDER_BIN="/c/Program Files/Blender Foundation/Blender 4.5/blender.exe"
|
||
|
||
"$BLENDER_BIN" --background --python tools/node_assets/build.py
|
||
"$BLENDER_BIN" --background --python tools/node_assets/validate.py
|
||
"$BLENDER_BIN" --background --python tools/node_assets/validate_mesh_plane.py
|
||
"$BLENDER_BIN" --background --python tools/node_assets/validate_cutout.py
|
||
```
|
||
|
||
`build.py` 从空 Factory 文件开始,依次构建 `O Mesh Plane`、`O Image Depth Plane`、`O Image Layer`、`O Image Depth Layer`、`O Shadeless`、四个 Cutout 内部节点组与公开修改器节点组 `O Image Cutout`,再保存唯一资产文件。`O Image Cutout` 用 Menu Switch 包装四个内部组;运行时 Loader 只加载这个稳定入口,Blender 4.5 根据 Shape 菜单依赖只显示当前分支实际使用的输入。
|
||
|
||
## 验证范围
|
||
|
||
基础验证检查完整发布资产清单、节点树类型、Modifier 标记、接口顺序和 Fake User。专项验证继续检查:
|
||
|
||
- Mesh Plane 的接口、细分、Thickness 和几何求值;
|
||
- `O Image Cutout` 的公开接口、Shape 菜单和四个内部组的依赖关系;
|
||
- 节点不重叠、主要连线保持从左向右;
|
||
- 局部 Group Input 未使用输出隐藏;
|
||
- Cleanup 只在四条分支之前执行,Smooth 只在菜单选择之后执行;
|
||
- Repeat Zone 数量和四种 Shape 的关键几何求值稳定。
|
||
|
||
节点资产接口变化时,应运行全部四个 Blender 入口和完整 Python 测试。只修改 Python、Markdown 或打包逻辑时无需重建 `.blend`。Blender 自动生成的 `.blend1` 等备份不属于发布资产。
|