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:
@@ -5,10 +5,13 @@ import pytest
|
||||
from mathutils import Euler, Vector, Matrix
|
||||
|
||||
from tests.support.materials import image_layer
|
||||
from anyimage.operators.cutout_tool.shape import CUTOUT_Z_TO_X
|
||||
from anyimage.common.object import blender_frame_rotation
|
||||
from tools.nodes.common.normal_map import ROTATION_ATTRIBUTE, FACE_ATTRIBUTE, AXIS_ATTRIBUTE
|
||||
|
||||
|
||||
SYMMETRY_Y_TO_X = Matrix.Rotation(1.5707963267948966, 4, "Z").to_3x3()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('image_layer', ['definition', 'asset'], indirect=True)
|
||||
@pytest.mark.parametrize('engine', ['CYCLES', 'BLENDER_EEVEE_NEXT'])
|
||||
def test_object_normals_follow_rotation_mirror_axis_and_wall_mask(image_layer, engine, tmp_path):
|
||||
@@ -65,12 +68,14 @@ def test_object_normals_follow_rotation_mirror_axis_and_wall_mask(image_layer, e
|
||||
links.new(emission.outputs[0], output.inputs['Surface'])
|
||||
obj.data.materials.append(material)
|
||||
value = normal.copy()
|
||||
if object_space:
|
||||
value = Matrix(blender_frame_rotation()).to_3x3() @ value
|
||||
if face and object_space:
|
||||
value = rotation.to_matrix().transposed() @ value
|
||||
if face == 2:
|
||||
value.z *= -1
|
||||
value.y *= -1
|
||||
if axis:
|
||||
value = Matrix(CUTOUT_Z_TO_X).to_3x3() @ value
|
||||
value = SYMMETRY_Y_TO_X @ value
|
||||
if strength == 0 or face == 3:
|
||||
value = Vector((0, 0, 1))
|
||||
expected.append((np.array(value) + 1) / 2)
|
||||
|
||||
Reference in New Issue
Block a user