Skip to content

Commit

Permalink
feat: Expose passes in the config UI
Browse files Browse the repository at this point in the history
Signed-off-by: Mahid Sheikh <[email protected]>
  • Loading branch information
StandingPadAnimations committed Nov 26, 2024
1 parent ee91537 commit 351271a
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion MCprep_addon/vivy_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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'}:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 351271a

Please sign in to comment.