From a215a3c85ad950e38d344205701b4258201f8412 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 29 Aug 2019 11:44:18 +0200 Subject: Principled Node added in Add Images as Planes This is about replacing the Diffuse shader with a principled shader, so that exporting to other formats like OBJ, FBX, GLTF becomes hassle - free as the textures are also imported along with it , as mentioned in the Task [[ https://developer.blender.org/T66299 | T66299 ]] Reviewers: mont29, lichtwerk Reviewed By: mont29 Subscribers: Dok11, lichtwerk Tags: #add-ons Differential Revision: https://developer.blender.org/D5610 --- io_import_images_as_planes.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/io_import_images_as_planes.py b/io_import_images_as_planes.py index ca55ef70..742623cb 100644 --- a/io_import_images_as_planes.py +++ b/io_import_images_as_planes.py @@ -21,7 +21,7 @@ bl_info = { "name": "Import Images as Planes", "author": "Florian Meyer (tstscr), mont29, matali, Ted Schundler (SpkyElctrc)", - "version": (3, 2, 2), + "version": (3, 3, 0), "blender": (2, 80, 0), "location": "File > Import > Images as Planes or Add > Mesh > Images as Planes", "description": "Imports images and creates planes with the appropriate aspect ratio. " @@ -727,11 +727,11 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): # ------------------------------ # Properties - Material / Shader SHADERS = ( - ('DIFFUSE', "Diffuse", "Diffuse Shader"), + ('PRINCIPLED',"Principled","Principled Shader"), ('SHADELESS', "Shadeless", "Only visible to camera and reflections"), ('EMISSION', "Emit", "Emission Shader"), ) - shader: EnumProperty(name="Shader", items=SHADERS, default='DIFFUSE', description="Node shader to use") + 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, @@ -1009,8 +1009,8 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): tex_image = self.create_cycles_texnode(context, node_tree, img_spec) - if self.shader == 'DIFFUSE': - core_shader = node_tree.nodes.new('ShaderNodeBsdfDiffuse') + if self.shader == 'PRINCIPLED': + core_shader = node_tree.nodes.new('ShaderNodeBsdfPrincipled') elif self.shader == 'SHADELESS': core_shader = get_shadeless_node(node_tree) else: # Emission Shading @@ -1021,13 +1021,7 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper): node_tree.links.new(core_shader.inputs[0], tex_image.outputs[0]) if self.use_transparency: - bsdf_transparent = node_tree.nodes.new('ShaderNodeBsdfTransparent') - - mix_shader = node_tree.nodes.new('ShaderNodeMixShader') - node_tree.links.new(mix_shader.inputs[0], tex_image.outputs[1]) - node_tree.links.new(mix_shader.inputs[1], bsdf_transparent.outputs[0]) - node_tree.links.new(mix_shader.inputs[2], core_shader.outputs[0]) - core_shader = mix_shader + node_tree.links.new(core_shader.inputs[18], tex_image.outputs[1]) node_tree.links.new(out_node.inputs[0], core_shader.outputs[0]) -- cgit v1.2.3