Files
AnyImage/docs/surface.md
nan 0cf04a13c6 feat: Implement upscale functionality with ONNX models
- Added upscale operator to handle image upscaling by 4x using AI models.
- Introduced new jobs for upscale processing in the server, including debug and standard upscale jobs.
- Created a new ONNX model handler for upscale operations, supporting tiled inference and resource management.
- Updated tests to cover new upscale functionality, including input validation and output verification.
- Added documentation for the upscale feature, detailing usage and model options.
2026-08-23 20:34:35 +08:00

3.1 KiB
Raw Blame History

Surface

Surface 从单张图片生成带透视关系的相机空间网格。它比 Depth Plane 更接近真实空间结构,适合需要匹配相机或继续编辑拓扑的场景。操作方法见Surface 使用指南。

数据流

flowchart LR
    Image["单张 Image Empty"] --> Model["DA3 / MoGe-2"]
    Model --> Builder["Surface Builder"]
    Builder --> Mesh["mesh.npz"]
    Mesh --> Blender["Blender 导入"]
    Blender --> Nodes["Geometry Nodes 后处理"]
    Nodes --> Result["Surface + Material"]
    Blender --> Camera["可选匹配相机"]

模型提供深度、相机和有效区域,Surface Builder 将其转换为统一的相机空间网格。Blender 导入网格后,用 Geometry Nodes 完成清理、重拓扑、平滑和 UV 重投影。

模型数据

来源 用于建网格的数据 材质附加数据
DA3 Depth、confidence、intrinsics 原图颜色
MoGe-2 Metric depth、mask、intrinsics 原图颜色与 normal

两种模型共享同一 Surface Builder 和网格文件格式。启用 Remove Background 时,输入 Alpha 与 BEN2 Alpha 相乘后的结果会在建网格阶段移除背景三角面;这是几何裁剪,转换后关闭材质 Mask 不会恢复已删除的面。

源网格

mesh.npz 保存:

  • camera-space vertices 与 faces
  • 原图坐标对应的 uv
  • intrinsics 与 image_size
  • 用于整体尺度的 reference_depth
  • Geometry Nodes 使用的深度、Mask、置信度或连续性属性

源网格保持模型空间信息,视觉清理集中在 Geometry Nodes 中完成。这样可以调整参数、比较结果,也可以 Apply 修改器后继续普通建模。

Geometry Nodes

DA3 使用 O DA3 Surface,MoGe-2 使用 O MoGe2 Surface。两者采用相同的处理顺序:

  1. 根据有效区域、深度连续性和可用置信度剔除不可靠面
  2. 合并和修复拓扑
  3. 清理小岛并平滑表面
  4. 从源网格重新投影 UV

常用控制包括 Iterations、Resolution、Smooth、Depth Continuity、Confidence 和 Mask。节点资产由扩展复用,多个 Surface 不会各自复制一套节点图。

空间与相机

网格在 camera space 中生成,再通过源 Image Empty 的 Transform 放入场景。导入过程会匹配图片可见尺寸、宽高比、Offset 与主点位置。

启用 Create Matching Camera 时,AnyImage 根据模型 intrinsics 创建相机并使用相同坐标变换,使网格与相机视图保持一致。模型估计的焦距和主点决定透视关系;reference_depth 决定整体尺度。

材质与文件

颜色统一写为 image.0001.*,导入时沿用源 Image 名称,由 Blender 自动解决同名冲突。MoGe-2 还会输出 normal.png,用于材质法线。材质名称以源 Image datablock 为基名。

单图结果可以 Pack 到 .blend。模型原始结果与 mesh.npz 保留在 Job 目录中,便于调试和重新检查。

适用范围

Surface 面向单张图片。它生成可编辑的透视网格,但遮挡区域仍来自单视图估计,无法恢复图片中不可见的真实几何。视频和序列帧应使用 Depth Plane。