Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRick Astley <mrbimax>2022-09-05 13:38:26 +0300
committerBastien Montagne <bastien@blender.org>2022-09-05 13:50:52 +0300
commit2ec6aba72cd3f64bbf8a4844a976696be942900a (patch)
treeaa07add3045feba2c475709d62fa21557813c689
parent25ffc6f430fc995b1c046b01acba1c3e6c1896b0 (diff)
Update for "Import Images as Planes" Addon.
Add more features for Material and ImageTexture settings: 1. The ability to change Interpolation Mode of the texture (linear, closest, cubic, smart). Before there was only linear as default. 2. The ability to change the extension parameter. 3. The ability to change a Blend Mode (Blend, Clip, Hashed). Before there was only Blend (or Opaque if "Use Alpha" is unchecked) as default. 4. In "Alpha Blend" case, added the "Show Backface" checkbox. 5. The ability to change the Shadow Mode (Clip, Hashed, Opaque) or disable casting shadows. Before there was only "Alpha Clip" as default. 6. The ability to enable Backface Culling. Reworked: 1. Compositing Nodes, Material Settings and Texture Settings are in different layouts now. 2. "Use Alpha" checkbox has moved from "Texture Setting" to "Material Settings". Differential Revision: https://developer.blender.org/D15744
-rw-r--r--io_import_images_as_planes.py98
1 files changed, 85 insertions, 13 deletions
diff --git a/io_import_images_as_planes.py b/io_import_images_as_planes.py
index 50a56238..ef63ec52 100644
--- a/io_import_images_as_planes.py
+++ b/io_import_images_as_planes.py
@@ -2,8 +2,8 @@
bl_info = {
"name": "Import Images as Planes",
- "author": "Florian Meyer (tstscr), mont29, matali, Ted Schundler (SpkyElctrc)",
- "version": (3, 4, 0),
+ "author": "Florian Meyer (tstscr), mont29, matali, Ted Schundler (SpkyElctrc), mrbimax",
+ "version": (3, 5, 0),
"blender": (2, 91, 0),
"location": "File > Import > Images as Planes or Add > Mesh > Images as Planes",
"description": "Imports images and creates planes with the appropriate aspect ratio. "
@@ -718,6 +718,34 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper):
name="Strength", min=0.0, default=1.0, soft_max=10.0,
step=100, description="Brightness of Emission Texture")
+ use_transparency: BoolProperty(
+ name="Use Alpha", default=True,
+ description="Use alpha channel for transparency")
+
+ BLEND_METHODS = (
+ ('BLEND',"Blend","Render polygon transparent, depending on alpha channel of the texture"),
+ ('CLIP', "Clip","Use the alpha threshold to clip the visibility (binary visibility)"),
+ ('HASHED', "Hashed","Use noise to dither the binary visibility (works well with multi-samples)"),
+ ('OPAQUE', "Opaque","Render surface without transparency"),
+ )
+ blend_method: EnumProperty(name="Blend Mode", items=BLEND_METHODS, default='BLEND', description="Blend Mode for Transparent Faces")
+
+ SHADOW_METHODS = (
+ ('CLIP', "Clip","Use the alpha threshold to clip the visibility (binary visibility)"),
+ ('HASHED', "Hashed","Use noise to dither the binary visibility (works well with multi-samples)"),
+ ('OPAQUE',"Opaque","Material will cast shadows without transparency"),
+ ('NONE',"None","Material will cast no shadow"),
+ )
+ shadow_method: EnumProperty(name="Shadow Mode", items=SHADOW_METHODS, default='CLIP', description="Shadow mapping method")
+
+ use_backface_culling: BoolProperty(
+ name="Backface Culling", default=False,
+ description="Use back face culling to hide the back side of faces")
+
+ show_transparent_back: BoolProperty(
+ name="Show Backface", default=True,
+ description="Render multiple transparent layers (may introduce transparency sorting problems)")
+
overwrite_material: BoolProperty(
name="Overwrite Material", default=True,
description="Overwrite existing Material (based on material name)")
@@ -729,9 +757,20 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper):
# ------------------
# Properties - Image
- use_transparency: BoolProperty(
- name="Use Alpha", default=True,
- description="Use alpha channel for transparency")
+ INTERPOLATION_MODES = (
+ ('Linear', "Linear", "Linear interpolation"),
+ ('Closest', "Closest", "No interpolation (sample closest texel)"),
+ ('Cubic', "Cubic", "Cubic interpolation"),
+ ('Smart', "Smart", "Bicubic when magnifying, else bilinear (OSL only)"),
+ )
+ interpolation: EnumProperty(name="Interpolation", items=INTERPOLATION_MODES, default='Linear', description="Texture interpolation")
+
+ EXTENSION_MODES = (
+ ('CLIP', "Clip", "Clip to image size and set exterior pixels as transparent"),
+ ('EXTEND', "Extend", "Extend by repeating edge pixels of the image"),
+ ('REPEAT', "Repeat", "Cause the image to repeat horizontally and vertically"),
+ )
+ extension: EnumProperty(name="Extension", items=EXTENSION_MODES, default='CLIP', description="How the image is extrapolated past its original bounds")
t = bpy.types.Image.bl_rna.properties["alpha_mode"]
alpha_mode_items = tuple((e.identifier, e.name, e.description) for e in t.enum_items)
@@ -766,27 +805,53 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper):
box.label(text="Compositing Nodes:", icon='RENDERLAYERS')
box.prop(self, "compositing_nodes")
-
+ layout = self.layout
+ box = layout.box()
box.label(text="Material Settings:", icon='MATERIAL')
+ box.label(text="Material Type")
row = box.row()
row.prop(self, 'shader', expand=True)
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")
+ 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 = box.row()
+ row.prop(self, "use_backface_culling")
+
engine = context.scene.render.engine
if engine not in ('CYCLES', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'):
box.label(text="%s is not supported" % engine, icon='ERROR')
box.prop(self, "overwrite_material")
-
+ 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 = box.row()
+ row.prop(self, 'extension', expand=True)
row = box.row()
row.prop(self, "use_transparency")
- sub = row.row()
- sub.active = self.use_transparency
- sub.prop(self, "alpha_mode", text="")
- box.prop(self, "use_auto_refresh")
+ if self.use_transparency:
+ sub = row.row()
+ sub.prop(self, "alpha_mode", text="")
+ row = box.row()
+ row.prop(self, "use_auto_refresh")
def draw_spatial_config(self, context):
# --- Spatial Properties: Position, Size and Orientation --- #
@@ -970,6 +1035,8 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper):
tex_image = node_tree.nodes.new('ShaderNodeTexImage')
tex_image.image = img_spec.image
tex_image.show_texture = True
+ tex_image.interpolation = self.interpolation
+ tex_image.extension = self.extension
self.apply_texture_options(tex_image, img_spec)
return tex_image
@@ -985,8 +1052,13 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper):
material = bpy.data.materials.new(name=name_compat)
material.use_nodes = True
- if self.use_transparency:
- material.blend_method = 'BLEND'
+
+ material.blend_method = self.blend_method
+ material.shadow_method = self.shadow_method
+
+ material.use_backface_culling = self.use_backface_culling
+ material.show_transparent_back = self.show_transparent_back
+
node_tree = material.node_tree
out_node = clean_node_tree(node_tree)