From dd17fe902e06db262fa801d063b124381979bdab Mon Sep 17 00:00:00 2001 From: William Herald Snyder Date: Mon, 3 Oct 2022 12:07:52 -0400 Subject: [PATCH] Normal mapping support, though bump mapping is not supported yet. To support it, .tga.option files will have to be read and the various bump mapping munge parameters will need proper interpretation. Emulating the bump effect via shader nodes is straightforward. --- addons/io_scene_swbf_msh/msh_material_operators.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/addons/io_scene_swbf_msh/msh_material_operators.py b/addons/io_scene_swbf_msh/msh_material_operators.py index 0d84e75..c77882b 100644 --- a/addons/io_scene_swbf_msh/msh_material_operators.py +++ b/addons/io_scene_swbf_msh/msh_material_operators.py @@ -173,6 +173,20 @@ to provide an exact emulation""" surfaces_output = mix + if "NORMALMAP" in mat_props.rendertype and mat_props.normal_map and os.path.exists(mat_props.normal_map): + normalMapTexImage = material.node_tree.nodes.new('ShaderNodeTexImage') + normalMapTexImage.image = bpy.data.images.load(mat_props.normal_map) + normalMapTexImage.image.alpha_mode = 'CHANNEL_PACKED' + normalMapTexImage.image.colorspace_settings.name = 'Non-Color' + texture_input_nodes.append(normalMapTexImage) + + normalMapNode = material.node_tree.nodes.new('ShaderNodeNormalMap') + material.node_tree.links.new(normalMapNode.inputs["Color"], normalMapTexImage.outputs["Color"]) + + material.node_tree.links.new(bsdf.inputs['Normal'], normalMapNode.outputs["Normal"]) + + + output = material.node_tree.nodes.new("ShaderNodeOutputMaterial") material.node_tree.links.new(output.inputs['Surface'], surfaces_output.outputs[0])