- Implemented `image_plane.py` to build the Image Plane Geometry Nodes group with customizable parameters for geometry, subdivide, and thickness. - Created `image_plane_validation.py` to validate the functionality of the image plane, ensuring correct geometry generation and material assignment. - Developed `material_layers.py` to construct shader node groups for image materials, including depth and normal handling. - Authored `plane_layouts.py` to define node arrangements for image geometry assets. - Introduced `shadeless.py` to create a shadeless shader node group that displays color without scene lighting while preserving shadows and reflections.
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
import unittest
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
|
SOURCE_ROOT = PROJECT_ROOT / "src" / "anyimage"
|
|
|
|
|
|
class NodeAssetsTest(unittest.TestCase):
|
|
def test_geometry_assets_pass_layout_overlap_checks(self):
|
|
import bpy
|
|
|
|
sys.path.insert(0, str(PROJECT_ROOT / "tools" / "node_assets"))
|
|
from node_layout import validate_node_layout
|
|
|
|
bpy.ops.wm.read_factory_settings(use_empty=True)
|
|
with bpy.data.libraries.load(
|
|
str(SOURCE_ROOT / "assets" / "O_AnyImage.blend")
|
|
) as (source, target):
|
|
target.node_groups = list(source.node_groups)
|
|
groups = [
|
|
group
|
|
for group in target.node_groups
|
|
if group.bl_idname == "GeometryNodeTree"
|
|
]
|
|
self.assertEqual(len(groups), 5)
|
|
for group in groups:
|
|
validate_node_layout(group)
|
|
|
|
def test_production_code_does_not_create_node_groups(self):
|
|
offenders = []
|
|
for path in SOURCE_ROOT.rglob("*.py"):
|
|
if "bpy.data.node_groups.new" in path.read_text(encoding="utf-8"):
|
|
offenders.append(path.relative_to(PROJECT_ROOT).as_posix())
|
|
self.assertEqual(offenders, [])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|