From 351271ab57a247de4601debb89247f3d390b6e5d Mon Sep 17 00:00:00 2001 From: Mahid Sheikh Date: Mon, 25 Nov 2024 20:08:06 -0600 Subject: [PATCH] feat: Expose passes in the config UI Signed-off-by: Mahid Sheikh --- MCprep_addon/vivy_editor.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/MCprep_addon/vivy_editor.py b/MCprep_addon/vivy_editor.py index a35ad187..2a4bc5bb 100644 --- a/MCprep_addon/vivy_editor.py +++ b/MCprep_addon/vivy_editor.py @@ -22,6 +22,11 @@ def set_name(self, value): desc: bpy.props.StringProperty(name="Desc", description="Description of Vivy material", default="DESC") base_material: bpy.props.EnumProperty(name="Base Mat", items=items_materials, description="Base material of Vivy material") + # Passes + diffuse: bpy.props.StringProperty(name="Diffuse Pass", description="Name of node that holds diffuse pass", default="DIFFUSE") + specular: bpy.props.StringProperty(name="Specular Pass", description="Name of node that holds specular pass", default="SPECULAR") + normal: bpy.props.StringProperty(name="Normal Pass", description="Name of node that holds normal pass", default="NORMAL") + class VivyEditorProps(bpy.types.PropertyGroup): vivy_materials: bpy.props.CollectionProperty(type=ListVivyMaterials) vivy_materials_index: bpy.props.IntProperty(default=0) @@ -36,6 +41,12 @@ def reload_vivy_materials(context): vmat.desc = material_data[mat]["desc"] vmat.base_material = material_data[mat]["base_material"] + # passes + passes_data = material_data[mat]["passes"] + vmat.diffuse = passes_data["diffuse"] if "diffuse" in passes_data else "" + vmat.specular = passes_data["specular"] if "specular" in passes_data else "" + vmat.normal = passes_data["normal"] if "normal" in passes_data else "" + class VIVY_UL_materials(bpy.types.UIList): def draw_item(self, context, layout, data, item, icon, active_data, active_propname): if self.layout_type in {'DEFAULT', 'COMPACT'}: @@ -81,11 +92,22 @@ def execute(self, context): original_data = data["materials"].pop(old_name) original_data["desc"] = mat.desc original_data["base_material"] = mat.base_material + + # passes + orig_passes = original_data["passes"] + orig_passes["diffuse"] = name.diffuse + orig_passes["specular"] = name.specular + orig_passes["normal"] = name.normal data["materials"][mat.name] = original_data else: data["materials"][mat.name] = { "desc": mat.desc, - "base_material": mat.base_material + "base_material": mat.base_material, + "passes" : { + "diffuse": mat.diffuse, + "specular": mat.specular, + "normal": mat.normal + } } json_path = vivy_materials.get_vivy_json() with open(json_path, 'w') as f: @@ -124,6 +146,12 @@ def draw(self, context): row.prop(mat, "desc") row = box.row() row.prop(mat, "base_material") + row = box.row() + row.prop(mat, "diffuse") + row = box.row() + row.prop(mat, "specular") + row = box.row() + row.prop(mat, "normal") layout.operator("vivy.apply_changes") else: layout.operator("vivy.reload_editor")