- 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.
75 lines
2.4 KiB
Python
75 lines
2.4 KiB
Python
import unittest
|
|
from pathlib import Path
|
|
from types import SimpleNamespace
|
|
from common_test_support import load_common_modules
|
|
PROJECT_ROOT=Path(__file__).resolve().parents[1]
|
|
|
|
class MaterialSettingsTest(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
cls.modules = load_common_modules()
|
|
|
|
def test_material_color_space_matches_scene_view_transform(self):
|
|
mappings = {
|
|
"ACES 1.3": "ACES 1.3 sRGB",
|
|
"ACES 2.0": "ACES 2.0 sRGB",
|
|
"AgX": "AgX Base sRGB",
|
|
"Filmic": "Filmic sRGB",
|
|
"Khronos PBR Neutral": "Khronos PBR Neutral sRGB",
|
|
"Standard": "sRGB",
|
|
}
|
|
for view_transform, expected in mappings.items():
|
|
with self.subTest(view_transform=view_transform):
|
|
scene = SimpleNamespace(
|
|
view_settings=SimpleNamespace(
|
|
view_transform=view_transform,
|
|
)
|
|
)
|
|
self.assertEqual(
|
|
self.modules.material.material_color_space_name(scene),
|
|
expected,
|
|
)
|
|
|
|
|
|
def test_material_color_space_falls_back_when_unsupported(self):
|
|
class ColorSpaceSettings:
|
|
def __init__(self):
|
|
self._name = "sRGB"
|
|
|
|
@property
|
|
def name(self):
|
|
return self._name
|
|
|
|
@name.setter
|
|
def name(self, value):
|
|
if value != "sRGB":
|
|
raise TypeError("unsupported color space")
|
|
self._name = value
|
|
|
|
image = SimpleNamespace(
|
|
colorspace_settings=ColorSpaceSettings(),
|
|
users=0, use_fake_user=False, alpha_mode="STRAIGHT",
|
|
)
|
|
scene = SimpleNamespace(
|
|
view_settings=SimpleNamespace(view_transform="ACES 2.0")
|
|
)
|
|
|
|
result = self.modules.material.configure_material_color_image(image, scene)
|
|
|
|
self.assertIs(result, image)
|
|
self.assertEqual(image.alpha_mode, "PREMUL")
|
|
self.assertEqual(image.colorspace_settings.name, "sRGB")
|
|
|
|
|
|
def test_surface_displacement_is_set_to_displacement_only(self):
|
|
class Material:
|
|
surface_displacement_method = "BUMP"
|
|
|
|
material = Material()
|
|
self.modules.material.set_displacement_only(material)
|
|
|
|
self.assertEqual(
|
|
material.surface_displacement_method,
|
|
"DISPLACEMENT",
|
|
)
|