From b53da37ad5681e3178f81cb5844420c79529d4ce Mon Sep 17 00:00:00 2001 From: Sun Kim Date: Tue, 3 Oct 2023 20:46:13 +0900 Subject: [PATCH 1/8] Update Images as Planes per new APIs Update per new shader and nodes APIs so Shadless and Emission types work again. --- io_import_images_as_planes.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/io_import_images_as_planes.py b/io_import_images_as_planes.py index 97e1dbb91..b3b93d357 100644 --- a/io_import_images_as_planes.py +++ b/io_import_images_as_planes.py @@ -320,8 +320,8 @@ def get_shadeless_node(dest_node_tree): output_node = node_tree.nodes.new('NodeGroupOutput') input_node = node_tree.nodes.new('NodeGroupInput') - node_tree.outputs.new('NodeSocketShader', 'Shader') - node_tree.inputs.new('NodeSocketColor', 'Color') + node_tree.interface.new_socket('Shader', in_out='OUTPUT', socket_type='NodeSocketShader') + node_tree.interface.new_socket('Color', in_out='INPUT', socket_type='NodeSocketColor') # This could be faster as a transparent shader, but then no ambient occlusion diffuse_shader = node_tree.nodes.new('ShaderNodeBsdfDiffuse') @@ -1079,7 +1079,7 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): if self.shader in {'PRINCIPLED', 'SHADELESS'}: node_tree.links.new(core_shader.inputs[0], tex_image.outputs['Color']) elif self.shader == 'EMISSION': - node_tree.links.new(core_shader.inputs['Emission'], tex_image.outputs['Color']) + node_tree.links.new(core_shader.inputs['Emission Color'], tex_image.outputs['Color']) if self.use_transparency: if self.shader in {'PRINCIPLED', 'EMISSION'}: -- 2.30.2 From 852d7965e606a812051461a86075ff6199190275 Mon Sep 17 00:00:00 2001 From: Sun Kim Date: Tue, 3 Oct 2023 23:04:28 +0900 Subject: [PATCH 2/8] First pass of layout change --- io_import_images_as_planes.py | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/io_import_images_as_planes.py b/io_import_images_as_planes.py index b3b93d357..b32ab04b9 100644 --- a/io_import_images_as_planes.py +++ b/io_import_images_as_planes.py @@ -804,6 +804,8 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): def draw_material_config(self, context): # --- Material / Rendering Properties --- # layout = self.layout + layout.use_property_split = True + layout.use_property_decorate = False box = layout.box() box.label(text="Compositing Nodes:", icon='RENDERLAYERS') @@ -812,24 +814,19 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): box = layout.box() box.label(text="Material Settings:", icon='MATERIAL') - box.label(text="Material Type") row = box.row() - row.prop(self, 'shader', expand=True) + row.prop(self, 'shader', expand=False) if self.shader == 'EMISSION': box.prop(self, "emit_strength") - box.label(text="Blend Mode") row = box.row() - row.prop(self, 'blend_method', expand=True) - if self.use_transparency and self.alpha_mode != "NONE" and self.blend_method == "OPAQUE": - box.label(text="'Opaque' does not support alpha", icon="ERROR") + row.prop(self, 'blend_method', expand=False) if self.blend_method == 'BLEND': row = box.row() row.prop(self, "show_transparent_back") - box.label(text="Shadow Mode") row = box.row() - row.prop(self, 'shadow_method', expand=True) + row.prop(self, 'shadow_method', expand=False) row = box.row() row.prop(self, "use_backface_culling") @@ -842,17 +839,15 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): layout = self.layout box = layout.box() box.label(text="Texture Settings:", icon='TEXTURE') - box.label(text="Interpolation") row = box.row() - row.prop(self, 'interpolation', expand=True) - box.label(text="Extension") + row.prop(self, 'interpolation', expand=False) row = box.row() - row.prop(self, 'extension', expand=True) + row.prop(self, 'extension', expand=False) row = box.row() row.prop(self, "use_transparency") - if self.use_transparency: - sub = row.row() - sub.prop(self, "alpha_mode", text="") + row = box.row() + row.enabled = self.use_transparency + row.prop(self, "alpha_mode") row = box.row() row.prop(self, "use_auto_refresh") @@ -861,18 +856,18 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): layout = self.layout box = layout.box() - box.label(text="Position:", icon='SNAP_GRID') + box.label(text="Transform:", icon='SNAP_GRID') box.prop(self, "offset") col = box.column() row = col.row() - row.prop(self, "offset_axis", expand=True) + row.prop(self, "offset_axis", expand=False) row = col.row() row.prop(self, "offset_amount") col.enabled = self.offset - box.label(text="Plane dimensions:", icon='ARROW_LEFTRIGHT') + box.label(text="Plane dimensions:") row = box.row() - row.prop(self, "size_mode", expand=True) + row.prop(self, "size_mode", expand=False) if self.size_mode == 'ABSOLUTE': box.prop(self, "height") elif self.size_mode == 'CAMERA': @@ -887,7 +882,7 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): row.prop(self, "align_axis") row = box.row() row.enabled = 'CAM' in self.align_axis - row.alignment = 'RIGHT' + row = box.row() row.prop(self, "align_track") def draw(self, context): -- 2.30.2 From 6573541033658d16c58a95c53acfc23e5b4faf0e Mon Sep 17 00:00:00 2001 From: Sun Kim Date: Wed, 4 Oct 2023 00:25:17 +0900 Subject: [PATCH 3/8] First pass of name and tooltip changes --- io_import_images_as_planes.py | 51 ++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/io_import_images_as_planes.py b/io_import_images_as_planes.py index b32ab04b9..00d77b35e 100644 --- a/io_import_images_as_planes.py +++ b/io_import_images_as_planes.py @@ -609,7 +609,7 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): # Properties - Importing force_reload: BoolProperty( name="Force Reload", default=False, - description="Force reloading of the image if already opened elsewhere in Blender" + description="Force reload the image if it is already opened elsewhere in Blender" ) image_sequence: BoolProperty( @@ -629,7 +629,10 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): 'Z-': Vector(( 0, 0, -1)), } - offset: BoolProperty(name="Offset Planes", default=True, description="Offset Planes From Each Other") + offset: BoolProperty( + name="Offset Planes", default=True, + description="Offset planes from each other. " + "If disabled, multiple planes will be created at the same location") OFFSET_MODES = ( ('X+', "X+", "Side by Side to the Left"), @@ -640,24 +643,24 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): ('Z-', "Z-", "Stacked Below"), ) offset_axis: EnumProperty( - name="Orientation", default='X+', items=OFFSET_MODES, + name="Offset Direction", default='X+', items=OFFSET_MODES, description="How planes are oriented relative to each others' local axis" ) offset_amount: FloatProperty( - name="Offset", soft_min=0, default=0.1, description="Space between planes", + name="Offset Distance", soft_min=0, default=0.1, description="Set distance between each plane", subtype='DISTANCE', unit='LENGTH' ) AXIS_MODES = ( - ('X+', "X+", "Facing Positive X"), - ('Y+', "Y+", "Facing Positive Y"), - ('Z+', "Z+ (Up)", "Facing Positive Z"), - ('X-', "X-", "Facing Negative X"), - ('Y-', "Y-", "Facing Negative Y"), - ('Z-', "Z- (Down)", "Facing Negative Z"), - ('CAM', "Face Camera", "Facing Camera"), - ('CAM_AX', "Main Axis", "Facing the Camera's dominant axis"), + ('X+', "X+", "Facing positive X"), + ('Y+', "Y+", "Facing positive Y"), + ('Z+', "Z+", "Facing positive Z"), + ('X-', "X-", "Facing negative X"), + ('Y-', "Y-", "Facing negative Y"), + ('Z-', "Z-", "Facing negative Z"), + ('CAM', "Face Camera", "Facing camera"), + ('CAM_AX', "Camera's Main Axis", "Facing the camera's dominant axis"), ) align_axis: EnumProperty( name="Align", default='CAM_AX', items=AXIS_MODES, @@ -667,7 +670,7 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): prev_align_axis: EnumProperty( items=AXIS_MODES + (('NONE', '', ''),), default='NONE', options={'HIDDEN', 'SKIP_SAVE'}) align_track: BoolProperty( - name="Track Camera", default=False, description="Always face the camera" + name="Track Camera", default=False, description="Add a constraint to make the planes to track the camera" ) # ----------------- @@ -686,21 +689,21 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): SIZE_MODES = ( ('ABSOLUTE', "Absolute", "Use absolute size"), - ('CAMERA', "Camera Relative", "Scale to the camera frame"), - ('DPI', "Dpi", "Use definition of the image as dots per inch"), - ('DPBU', "Dots/BU", "Use definition of the image as dots per Blender Unit"), + ('CAMERA', "Scale to Camera Frame", "Scale to fit or fill the camera frame"), + ('DPI', "Pixels per Inch", "Scale based on pixels per inch"), + ('DPBU', "Pixels per Blender Unit", "Scale based on pixels per Blender Unit"), ) size_mode: EnumProperty( name="Size Mode", default='ABSOLUTE', items=SIZE_MODES, update=update_size_mode, - description="How the size of the plane is computed") + description="Set how the size of the plane is computed") FILL_MODES = ( ('FILL', "Fill", "Fill camera frame, spilling outside the frame"), ('FIT', "Fit", "Fit entire image within the camera frame"), ) fill_mode: EnumProperty(name="Scale", default='FILL', items=FILL_MODES, - description="How large in the camera frame is the plane") + description="Method to scale the plane with the camera frame") height: FloatProperty(name="Height", description="Height of the created plane", default=1.0, min=0.001, soft_min=0.001, subtype='DISTANCE', unit='LENGTH') @@ -713,13 +716,13 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): SHADERS = ( ('PRINCIPLED',"Principled","Principled Shader"), ('SHADELESS', "Shadeless", "Only visible to camera and reflections"), - ('EMISSION', "Emit", "Emission Shader"), + ('EMISSION', "Emission", "Emission Shader"), ) shader: EnumProperty(name="Shader", items=SHADERS, default='PRINCIPLED', description="Node shader to use") emit_strength: FloatProperty( - name="Strength", min=0.0, default=1.0, soft_max=10.0, - step=100, description="Brightness of Emission Texture") + name="Emission Strength", min=0.0, default=1.0, soft_max=10.0, + step=100, description="Strength of emission") use_transparency: BoolProperty( name="Use Alpha", default=True, @@ -743,7 +746,7 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): use_backface_culling: BoolProperty( name="Backface Culling", default=False, - description="Use back face culling to hide the back side of faces") + description="Use backface culling to hide the back side of faces") show_transparent_back: BoolProperty( name="Show Backface", default=True, @@ -751,11 +754,11 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): overwrite_material: BoolProperty( name="Overwrite Material", default=True, - description="Overwrite existing Material (based on material name)") + description="Overwrite existing material with the same name)") compositing_nodes: BoolProperty( name="Setup Corner Pin", default=False, - description="Build Compositor Nodes to reference this image " + description="Build compositor nodes to reference this image " "without re-rendering") # ------------------ -- 2.30.2 From f80c9587c39bcd3764b13d096a0aedd20cb3738b Mon Sep 17 00:00:00 2001 From: Sun Kim Date: Wed, 4 Oct 2023 00:54:43 +0900 Subject: [PATCH 4/8] Second pass of layout changes - Reorder groups: Size settings -> Align settings -> Offset settings (importing a single plane would be more commons use case) - Remove header "Plane dimensions:" - Remove header "Orientation:" - Hide Track Camera if Align option is not Main Axis or Face Camera --- io_import_images_as_planes.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/io_import_images_as_planes.py b/io_import_images_as_planes.py index 00d77b35e..29be955f7 100644 --- a/io_import_images_as_planes.py +++ b/io_import_images_as_planes.py @@ -812,7 +812,10 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): box = layout.box() box.label(text="Compositing Nodes:", icon='RENDERLAYERS') - box.prop(self, "compositing_nodes") + row = box.row(align=True) + row.use_property_split = False + row.prop(self, "compositing_nodes") + layout = self.layout box = layout.box() box.label(text="Material Settings:", icon='MATERIAL') @@ -860,15 +863,7 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): box = layout.box() box.label(text="Transform:", icon='SNAP_GRID') - box.prop(self, "offset") - col = box.column() - row = col.row() - row.prop(self, "offset_axis", expand=False) - row = col.row() - row.prop(self, "offset_amount") - col.enabled = self.offset - box.label(text="Plane dimensions:") row = box.row() row.prop(self, "size_mode", expand=False) if self.size_mode == 'ABSOLUTE': @@ -879,14 +874,21 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): else: box.prop(self, "factor") - box.label(text="Orientation:") row = box.row() row.enabled = 'CAM' not in self.size_mode row.prop(self, "align_axis") + if 'CAM' in self.align_axis: + row = box.row() + row.prop(self, "align_track") + row = box.row() - row.enabled = 'CAM' in self.align_axis - row = box.row() - row.prop(self, "align_track") + row.prop(self, "offset") + col = box.column() + row = col.row() + row.prop(self, "offset_axis", expand=False) + row = col.row() + row.prop(self, "offset_amount") + col.enabled = self.offset def draw(self, context): -- 2.30.2 From b64b8bd2fe72144ebe5eaf5bff89010f19851cde Mon Sep 17 00:00:00 2001 From: Sun Kim Date: Wed, 8 Nov 2023 17:06:46 +0900 Subject: [PATCH 5/8] Remove colons from headers --- io_import_images_as_planes.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/io_import_images_as_planes.py b/io_import_images_as_planes.py index c17e8b4c2..19c4db3dc 100644 --- a/io_import_images_as_planes.py +++ b/io_import_images_as_planes.py @@ -806,7 +806,7 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): layout = self.layout box = layout.box() - box.label(text="Import Options:", icon='IMPORT') + box.label(text="Import Options", icon='IMPORT') row = box.row() row.active = bpy.data.is_saved row.prop(self, "relative") @@ -821,14 +821,14 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): layout.use_property_decorate = False box = layout.box() - box.label(text="Compositing Nodes:", icon='RENDERLAYERS') + box.label(text="Compositing Nodes", icon='RENDERLAYERS') row = box.row(align=True) row.use_property_split = False row.prop(self, "compositing_nodes") layout = self.layout box = layout.box() - box.label(text="Material Settings:", icon='MATERIAL') + box.label(text="Material Settings", icon='MATERIAL') row = box.row() row.prop(self, 'shader', expand=False) @@ -854,7 +854,7 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): box.prop(self, "overwrite_material") layout = self.layout box = layout.box() - box.label(text="Texture Settings:", icon='TEXTURE') + box.label(text="Texture Settings", icon='TEXTURE') row = box.row() row.prop(self, 'interpolation', expand=False) row = box.row() @@ -872,7 +872,7 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): layout = self.layout box = layout.box() - box.label(text="Transform:", icon='SNAP_GRID') + box.label(text="Transform", icon='SNAP_GRID') row = box.row() row.prop(self, "size_mode", expand=False) -- 2.30.2 From bca73565c17fe904a6458ebd14faca9703f5358e Mon Sep 17 00:00:00 2001 From: Sun Kim Date: Wed, 8 Nov 2023 17:12:28 +0900 Subject: [PATCH 6/8] Use in-line style for alpha option --- io_import_images_as_planes.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/io_import_images_as_planes.py b/io_import_images_as_planes.py index 19c4db3dc..76eda86dd 100644 --- a/io_import_images_as_planes.py +++ b/io_import_images_as_planes.py @@ -859,11 +859,12 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): row.prop(self, 'interpolation', expand=False) row = box.row() row.prop(self, 'extension', expand=False) - row = box.row() - row.prop(self, "use_transparency") - row = box.row() - row.enabled = self.use_transparency - row.prop(self, "alpha_mode") + col = box.column(align=False, heading="Alpha") + row = col.row(align=True) + row.prop(self, "use_transparency", text="") + sub = row.row(align=True) + sub.active = self.use_transparency + sub.prop(self, "alpha_mode", text="") row = box.row() row.prop(self, "use_auto_refresh") -- 2.30.2 From 289dd91ad08150224484b23d74daa15253b6fc29 Mon Sep 17 00:00:00 2001 From: Sun Kim Date: Wed, 8 Nov 2023 17:24:59 +0900 Subject: [PATCH 7/8] Fix typo --- io_import_images_as_planes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io_import_images_as_planes.py b/io_import_images_as_planes.py index 76eda86dd..b09a77e74 100644 --- a/io_import_images_as_planes.py +++ b/io_import_images_as_planes.py @@ -764,7 +764,7 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): overwrite_material: BoolProperty( name="Overwrite Material", default=True, - description="Overwrite existing material with the same name)") + description="Overwrite existing material with the same name") compositing_nodes: BoolProperty( name="Setup Corner Pin", default=False, -- 2.30.2 From 14e15ff9679536b84b1d372cdd9435276a77b5bd Mon Sep 17 00:00:00 2001 From: Sun Kim Date: Wed, 8 Nov 2023 17:30:33 +0900 Subject: [PATCH 8/8] Reorder texture settings to match the material properties --- io_import_images_as_planes.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/io_import_images_as_planes.py b/io_import_images_as_planes.py index b09a77e74..7486845a1 100644 --- a/io_import_images_as_planes.py +++ b/io_import_images_as_planes.py @@ -835,17 +835,17 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): if self.shader == 'EMISSION': box.prop(self, "emit_strength") + row = box.row() + row.prop(self, "use_backface_culling") + row = box.row() row.prop(self, 'blend_method', expand=False) - if self.blend_method == 'BLEND': - row = box.row() - row.prop(self, "show_transparent_back") row = box.row() row.prop(self, 'shadow_method', expand=False) - - row = box.row() - row.prop(self, "use_backface_culling") + if self.blend_method == 'BLEND': + row = box.row() + row.prop(self, "show_transparent_back") engine = context.scene.render.engine if engine not in ('CYCLES', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'): -- 2.30.2