Add new tests and functionality for image processing and geometry handling
- Introduced color_image.py for preparing standalone color images for tests. - Added hdr_image.py to create HDR textures for testing. - Implemented test_image_depth_panorama.py to evaluate panorama topology, UVs, and depth discontinuities. - Created test_shadeless.py to validate the opacity and HDR color endpoints of the Shadeless group. - Developed moge3_export.py for exporting dynamic MoGe-3 backbone and ONNX graphs. - Added material.py to inherit material slots onto generated geometry. - Built image_depth_panorama.py to construct a quad panorama with depth separation and sampling.
This commit is contained in:
@@ -3,13 +3,9 @@
|
||||
import bpy
|
||||
|
||||
from ...common.image import (
|
||||
color_data_name,
|
||||
configure_color_alpha,
|
||||
image_empty_bounds,
|
||||
image_pixels,
|
||||
load_color_result_image,
|
||||
load_normal_result_image,
|
||||
require_image_empty,
|
||||
require_conversion_source,
|
||||
)
|
||||
from ...common.depth import (
|
||||
depth_uniform_scale,
|
||||
@@ -17,6 +13,7 @@ from ...common.depth import (
|
||||
load_depth_result_image,
|
||||
)
|
||||
from ...common.material import create_image_material
|
||||
from ...common.color_image import material_color_image
|
||||
from ...common.object import (
|
||||
finalize_object_result,
|
||||
modifier_input_identifier,
|
||||
@@ -30,20 +27,6 @@ from .image_plane import (
|
||||
)
|
||||
|
||||
|
||||
def create_color_image(source_object):
|
||||
source = source_object.data
|
||||
image = source.copy()
|
||||
if getattr(source, "source", None) == "GENERATED" or getattr(
|
||||
source, "is_dirty", False
|
||||
):
|
||||
pixels = image_pixels(source)
|
||||
image.pixels.foreach_set(pixels)
|
||||
image.update()
|
||||
image.name = color_data_name(source_object)
|
||||
configure_color_alpha(image)
|
||||
return image
|
||||
|
||||
|
||||
def create_plane_object(context, source_object, subdivisions, material):
|
||||
source_name = source_object.name
|
||||
plane = create_image_plane_object(
|
||||
@@ -54,10 +37,17 @@ def create_plane_object(context, source_object, subdivisions, material):
|
||||
matrix_world=source_object.matrix_world,
|
||||
subdivisions=subdivisions,
|
||||
)
|
||||
for polygon in plane.data.polygons:
|
||||
polygon.use_smooth = True
|
||||
plane["anyimage_mesh_shape"] = "PLANE"
|
||||
return finalize_object_result(context, source_object, plane)
|
||||
try:
|
||||
for polygon in plane.data.polygons:
|
||||
polygon.use_smooth = True
|
||||
plane["anyimage_mesh_shape"] = "PLANE"
|
||||
return finalize_object_result(context, source_object, plane)
|
||||
except Exception:
|
||||
mesh = plane.data
|
||||
bpy.data.objects.remove(plane, do_unlink=True)
|
||||
if mesh.users == 0:
|
||||
bpy.data.meshes.remove(mesh)
|
||||
raise
|
||||
|
||||
|
||||
def create_depth_plane_object(
|
||||
@@ -102,54 +92,43 @@ def create_depth_plane_object(
|
||||
modifier_input_identifier(node_group, name),
|
||||
value,
|
||||
)
|
||||
return finalize_object_result(context, source_object, plane)
|
||||
except Exception:
|
||||
if plane is not None:
|
||||
bpy.data.objects.remove(plane, do_unlink=True)
|
||||
if mesh.users == 0:
|
||||
bpy.data.meshes.remove(mesh)
|
||||
raise
|
||||
return finalize_object_result(context, source_object, plane)
|
||||
|
||||
|
||||
def create_depth_plane_from_result(context, result, operator):
|
||||
normal_space = {"DEPTH": "OBJECT", "RELIEF": "TANGENT"}[operator.plane_type]
|
||||
source_object = require_image_empty(operator.source_object_name)
|
||||
color_image = load_color_result_image(source_object, result.directory)
|
||||
color_image.name = color_data_name(source_object)
|
||||
source_object = require_conversion_source(operator)
|
||||
material = None
|
||||
depth_image = None
|
||||
normal_image = None
|
||||
try:
|
||||
depth_metadata = load_depth_metadata(result.file("depth_metadata"))
|
||||
depth_image = load_depth_result_image(
|
||||
result.file("depth"),
|
||||
source_object,
|
||||
depth_metadata,
|
||||
)
|
||||
normal_image = load_normal_result_image(
|
||||
result.file(f"{normal_space.lower()}_normal"),
|
||||
source_object,
|
||||
)
|
||||
material = create_image_material(
|
||||
source_object.data,
|
||||
color_image,
|
||||
normal_image=normal_image,
|
||||
normal_space=normal_space,
|
||||
scene=context.scene,
|
||||
)
|
||||
create_depth_plane_object(
|
||||
context,
|
||||
source_object,
|
||||
operator.mesh_detail,
|
||||
material,
|
||||
depth_image,
|
||||
depth_metadata,
|
||||
operator.plane_type,
|
||||
)
|
||||
with material_color_image(input_path=operator.color_path) as color_image:
|
||||
depth_metadata = load_depth_metadata(result.file("depth_metadata"))
|
||||
depth_image = load_depth_result_image(
|
||||
result.file("depth"), source_object, depth_metadata,
|
||||
)
|
||||
normal_image = load_normal_result_image(
|
||||
result.file(f"{normal_space.lower()}_normal"), source_object,
|
||||
)
|
||||
material = create_image_material(
|
||||
source_object.data, color_image,
|
||||
normal_image=normal_image, normal_space=normal_space,
|
||||
scene=context.scene,
|
||||
)
|
||||
create_depth_plane_object(
|
||||
context, source_object, operator.mesh_detail, material,
|
||||
depth_image, depth_metadata, operator.plane_type,
|
||||
)
|
||||
except Exception:
|
||||
if material is not None and material.users == 0:
|
||||
bpy.data.materials.remove(material, do_unlink=True)
|
||||
for image in (color_image, depth_image, normal_image):
|
||||
for image in (depth_image, normal_image):
|
||||
if image is not None and image.users == 0:
|
||||
bpy.data.images.remove(image, do_unlink=True)
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user