diff --git a/leenkx/blender/lnx/props_ui.py b/leenkx/blender/lnx/props_ui.py index cdb6b3f..688908d 100644 --- a/leenkx/blender/lnx/props_ui.py +++ b/leenkx/blender/lnx/props_ui.py @@ -551,6 +551,51 @@ class LNX_OT_NewCustomMaterial(bpy.types.Operator): return{'FINISHED'} + +class LNX_OT_NextPassMaterialSelector(bpy.types.Operator): + """Select material for next pass""" + bl_idname = "lnx.next_pass_material_selector" + bl_label = "Select Next Pass Material" + + def execute(self, context): + return {'FINISHED'} + + def invoke(self, context, event): + context.window_manager.popup_menu(self.draw_menu, title="Select Next Pass Material", icon='MATERIAL') + return {'FINISHED'} + + def draw_menu(self, popup, context): + layout = popup.layout + + # Add 'None' option + op = layout.operator("lnx.set_next_pass_material", text="") + op.material_name = "" + + # Add materials from the current object's material slots + if context.object and hasattr(context.object, 'material_slots'): + for slot in context.object.material_slots: + if (slot.material is not None and slot.material != context.material): + op = layout.operator("lnx.set_next_pass_material", text=slot.material.name) + op.material_name = slot.material.name + +class LNX_OT_SetNextPassMaterial(bpy.types.Operator): + """Set the next pass material""" + bl_idname = "lnx.set_next_pass_material" + bl_label = "Set Next Pass Material" + + material_name: StringProperty() + + def execute(self, context): + if context.material: + context.material.lnx_next_pass = self.material_name + # Redraw the UI to update the display + for area in context.screen.areas: + if area.type == 'PROPERTIES': + area.tag_redraw() + return {'FINISHED'} + + + class LNX_PG_BindTexturesListItem(bpy.types.PropertyGroup): uniform_name: StringProperty( name='Uniform Name', @@ -634,18 +679,24 @@ class LNX_PT_MaterialPropsPanel(bpy.types.Panel): mat = bpy.context.material if mat is None: return - + + layout.prop(mat, 'lnx_sorting_order') layout.prop(mat, 'lnx_cast_shadow') columnb = layout.column() wrd = bpy.data.worlds['Lnx'] columnb.enabled = len(wrd.lnx_rplist) > 0 and lnx.utils.get_rp().rp_renderer == 'Forward' columnb.prop(mat, 'lnx_receive_shadow') layout.prop(mat, 'lnx_ignore_irradiance') + layout.prop(mat, 'lnx_compare_mode') layout.prop(mat, 'lnx_two_sided') columnb = layout.column() columnb.enabled = not mat.lnx_two_sided columnb.prop(mat, 'lnx_cull_mode') + row = layout.row(align=True) + row.prop(mat, 'lnx_next_pass', text="Next Pass") + row.operator('lnx.next_pass_material_selector', text='', icon='MATERIAL') layout.prop(mat, 'lnx_material_id') + layout.prop(mat, 'lnx_depth_write') layout.prop(mat, 'lnx_depth_read') layout.prop(mat, 'lnx_overlay') layout.prop(mat, 'lnx_decal') @@ -2908,6 +2959,8 @@ __REG_CLASSES = ( InvalidateCacheButton, InvalidateMaterialCacheButton, LNX_OT_NewCustomMaterial, + LNX_OT_NextPassMaterialSelector, + LNX_OT_SetNextPassMaterial, LNX_PG_BindTexturesListItem, LNX_UL_BindTexturesList, LNX_OT_BindTexturesListNewItem,