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.

This commit is contained in:
William Herald Snyder 2022-10-03 12:07:52 -04:00
parent 226682de8b
commit dd17fe902e
1 changed files with 14 additions and 0 deletions

View File

@ -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])