Refactor geometry generation to standardize Blender object coordinates

- Unified the canonical local frame for generated geometries (Plane, Depth Plane, Relief Plane, Cutout, Depth Cutout) to align with Blender's object coordinate system, setting X as horizontal, Z as up, and +Y as depth.
- Removed the `Depth Axis` parameter from `O Image Cutout` and `O Image Depth Cutout`, simplifying the geometry generation process.
- Updated the depth direction defaults to use +Y instead of -Z for `O Image Relief Plane` and Depth Symmetry.
- Adjusted the geometry nodes to ensure thickness, projection, and shell displacements operate along the Y-axis.
- Implemented new capabilities for handling object space normals to align with the new canonical frame.
- Enhanced the Depth Symmetry functionality to mirror across the canonical Y-axis and perform a final rotation to maintain the correct orientation.
- Added tests to validate the new coordinate system and ensure compatibility with existing assets.
This commit is contained in:
2026-09-15 13:33:37 +08:00
parent 591e62085a
commit 4035f5c9e4
47 changed files with 892 additions and 570 deletions

View File

@@ -0,0 +1,63 @@
## ADDED Requirements
### Requirement: Generated meshes use the Blender object frame
系统 SHALL 让 Plane、Depth Plane、Relief Plane、Cutout BaseShape 与 Depth Cutout 的输入网格使用统一的 Blender 对象局部坐标:X 为图片水平方向,Z 为图片 up,+Y 为图片纸内深度方向。所有未应用 modifier 的输入网格 MUST 位于 `Y=0` 的 XZ 平面。
#### Scenario: Create a Plane or Cutout BaseShape
- **WHEN** 用户创建 Plane 或 Cutout BaseShape
- **THEN** 未应用 modifier 的本地顶点 Y 坐标均为 0
- **AND** 顶点 X 范围对应源 Image Empty 的水平 bounds
- **AND** 顶点 Z 范围对应源 Image Empty 的 up bounds
### Requirement: Image UV maps to the XZ plane
系统 SHALL 将源图片的左右方向映射到本地 X,将源图片的上下方向映射到本地 Z,并保持 UV 采样在生成网格上的方向一致。
#### Scenario: Cutout UV corners follow image corners
- **WHEN** Cutout 从完整图片 bounds 生成 BaseShape
- **THEN** 图片左下角对应的本地顶点位于最小 X 和最小 Z
- **AND** 图片右上角对应的本地顶点位于最大 X 和最大 Z
- **AND** UV 读取的颜色纹理方向与源图片一致
### Requirement: Depth and thickness operate along Y
系统 SHALL 让 Depth Plane、Relief Plane、Cutout 与 Depth Cutout 的投影、厚度和 Shell 位移沿本地 Y 方向表达,并 SHALL 让 front 方向为 -Y、depth/纸内方向为 +Y。
#### Scenario: Depth Plane displaces toward positive Y
- **WHEN** Depth Plane 使用有效深度图且 Reference Depth 大于采样深度
- **THEN** 生成表面的 Y 坐标向 +Y 方向偏离输入平面
- **AND** 输入平面保持在 `Y=0`
#### Scenario: Cutout thickness grows along Y
- **WHEN** Cutout 设置非零 Thickness
- **THEN** 生成 Shell 的前后范围沿 Y 轴分布
- **AND** 没有几何沿 Z 轴被当作厚度方向
### Requirement: Depth Direction defaults to positive Y
`O Image Relief Plane` 与 Depth Symmetry 的 canonical 深度方向 SHALL 使用本地 +Y 作为默认方向,而不是 -Z。
#### Scenario: Relief Plane direction default
- **WHEN** 用户从资产加载 `O Image Relief Plane`
- **THEN** `Depth Direction` 默认值为 `(0, 1, 0)`
#### Scenario: Depth Symmetry canonical direction
- **WHEN** Depth Symmetry 使用默认方向校准
- **THEN** 对称前的 canonical 镜像轴 SHALL 为 Y
### Requirement: Cutout node assets no longer expose Depth Axis
`O Image Cutout` 与 `O Image Depth Cutout` MUST 不再公开 `Depth Axis` 输入,并且 MUST 不包含把最终几何从 -Z 转到 +X 的旧轴向旋转。
#### Scenario: Inspect Cutout interfaces
- **WHEN** 检查 `O Image Cutout` 和 `O Image Depth Cutout` 的输入接口
- **THEN** 不存在名为 `Depth Axis` 的 socket
- **AND** 节点组内不存在旧 `CUTOUT_Z_TO_X` 最终旋转

View File

@@ -0,0 +1,43 @@
## ADDED Requirements
### Requirement: Depth Symmetry mirrors across the canonical Y axis
`O Image Cutout Symmetry` SHALL 在 canonical Blender 对象坐标中沿 Y 轴镜像,即镜像面为 `Y=0` 的 XZ 平面。镜像前后的几何 MUST 在最终旋转前保持 `(x, y, z)` 与 `(x, -y, z)` 的对应关系。
#### Scenario: Canonical mirroring
- **WHEN** 上游 Depth Cutout 输出 canonical 几何并连接 `O Image Cutout Symmetry`
- **THEN** 对称节点先按 Y 轴删除越界半侧并镜像到另一侧
- **AND** Fill Sides 开启时沿 Y 方向连接对应边界
### Requirement: Final symmetry axis is X with Z up
`O Image Cutout Symmetry` SHALL 在 canonical Y 镜像完成后执行绕 Z 的固定旋转,使对称轴从 +Y 变为 +X,并保持 +Z 为 up。最终结果 MUST 在本地坐标中关于 `X=0` 对称。
#### Scenario: Default Depth Symmetry result
- **WHEN** 用户通过 Depth Symmetry 入口生成对象
- **THEN** 最终 evaluated local geometry 关于 `X=0` 对称
- **AND** 最终 Z 范围反映图片 up 范围
- **AND** 对象保持 up=Z
### Requirement: Depth Symmetry final front direction may change
Depth Symmetry 的最终朝向 SHALL 允许 canonical front `-Y` 随最终 yaw 旋转变为 `-X`。系统 MUST 不要求 Depth Symmetry 最终继续满足 front=-Y。
#### Scenario: Final front direction
- **WHEN** 使用把 +Y 映射到 +X 的最终 yaw 旋转
- **THEN** canonical front 方向 -Y 映射为 -X
- **AND** up 方向 +Z 保持不变
### Requirement: Depth Symmetry path has no Cutout Depth Axis
Depth Symmetry 创建流程 SHALL 不设置或依赖 `O Image Depth Cutout` 的 `Depth Axis`。所有最终轴向语义 MUST 只由 `O Image Cutout Symmetry` 承担。
#### Scenario: Create Depth Symmetry modifiers
- **WHEN** 用户通过 Depth Symmetry 入口创建对象
- **THEN** 上游 `O Image Depth Cutout` 不包含 `Depth Axis` 输入
- **AND** 上游 Cutout 输出 canonical +Y 深度结果
- **AND** `O Image Cutout Symmetry` 决定最终 X 朝向

View File

@@ -0,0 +1,35 @@
## ADDED Requirements
### Requirement: Object Space Normal follows the canonical object frame
系统 SHALL 让 Plane、Depth Plane、Relief Plane、Cutout 与 Depth Cutout 的 Object Space Normal 贴图按新的 canonical Blender 对象坐标解释:X 为图片水平、Z 为 up、Y 为深度方向。Object Space Normal 渲染结果 MUST 与最终 evaluated geometry 的几何法线方向一致。
#### Scenario: Depth object uses Object Space Normal
- **WHEN** Depth Plane 或 Depth Solid 使用 Object Space Normal 贴图渲染
- **THEN** 平面法线朝向 -Y
- **AND** 深度表面产生的 normal 变化围绕 -Y 基准
- **AND** 渲染 normal 不再按旧 `-Z` 基准解释
### Requirement: Depth Symmetry normal maps follow mirror and final orientation
`O Image Cutout Symmetry` SHALL 为 Object Space Normal 提供最终朝向所需的面属性。材质 SHALL 对 canonical front 保持 normal,对 canonical back 反射 Y 分量,并应用最终 yaw 旋转;侧壁 SHALL 关闭 normal map 影响。
#### Scenario: Front, back, and wall normals
- **WHEN** Depth Symmetry 对象启用 Object Space Normal 并分别渲染 front、back 和 side wall
- **THEN** front normal 按 canonical 方向解释
- **AND** back normal 的 Y 分量相对 front 发生反射
- **AND** 最终 X 朝向旋转被应用
- **AND** side wall 不显示 Object Space Normal 细节
### Requirement: Old Depth Axis normal compensation is removed
材质和 normal-map 辅助代码 MUST 不再为 `O Image Cutout` 或 `O Image Depth Cutout` 的旧 `Depth Axis=+X` 提供 `CUTOUT_Z_TO_X` 补偿。Object Normal 的最终轴向转换 SHALL 只来自 Depth Symmetry 的新朝向属性。
#### Scenario: Inspect normal transform attributes
- **WHEN** 检查 `O Image Layer` 使用的 Object Normal 转换逻辑
- **THEN** 不存在以旧 `Depth Axis` 为输入的轴向补偿
- **AND** Depth Symmetry 的最终朝向属性由 `O Image Cutout Symmetry` 写入
- **AND** 材质按该属性执行最终 normal 旋转