Don't change rendertype on matfill and fill texture_0 as well as diffuse map

This commit is contained in:
William Herald Snyder 2022-10-03 21:16:59 -04:00
parent 1252a6d192
commit 8bf2196991
1 changed files with 11 additions and 3 deletions

View File

@ -55,8 +55,8 @@ class FillSWBFMaterialProperties(bpy.types.Operator):
if i > 0: if i > 0:
tex_name = tex_name[0:i+4] tex_name = tex_name[0:i+4]
mat.swbf_msh_mat.rendertype = 'NORMAL_BF2'
mat.swbf_msh_mat.diffuse_map = tex_name mat.swbf_msh_mat.diffuse_map = tex_name
mat.swbf_msh_mat.texture_0 = tex_name
break break
except: except:
# Many chances for null ref exceptions. None if user reads doc section... # Many chances for null ref exceptions. None if user reads doc section...
@ -120,7 +120,9 @@ to provide an exact emulation"""
texture_input_nodes = [] texture_input_nodes = []
surface_output_nodes = [] surface_output_nodes = []
# Op will give up if no diffuse map is present.
# Eventually more nuance will be added for different
# rtypes
diffuse_texture_path = mat_props.diffuse_map diffuse_texture_path = mat_props.diffuse_map
if diffuse_texture_path and os.path.exists(diffuse_texture_path): if diffuse_texture_path and os.path.exists(diffuse_texture_path):
@ -149,6 +151,7 @@ to provide an exact emulation"""
surface_output_nodes.append(tuple(('BSDF', bsdf))) surface_output_nodes.append(tuple(('BSDF', bsdf)))
# Glow (adds another shader output)
if mat_props.glow: if mat_props.glow:
emission = material.node_tree.nodes.new("ShaderNodeEmission") emission = material.node_tree.nodes.new("ShaderNodeEmission")
@ -174,7 +177,7 @@ to provide an exact emulation"""
surfaces_output = mix surfaces_output = mix
# Normal/bump mapping (needs more rendertype support!)
if "NORMALMAP" in mat_props.rendertype and mat_props.normal_map and os.path.exists(mat_props.normal_map): 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 = material.node_tree.nodes.new('ShaderNodeTexImage')
normalMapTexImage.image = bpy.data.images.load(mat_props.normal_map) normalMapTexImage.image = bpy.data.images.load(mat_props.normal_map)
@ -212,6 +215,11 @@ to provide an exact emulation"""
material.node_tree.links.new(output.inputs['Surface'], surfaces_output.outputs[0]) material.node_tree.links.new(output.inputs['Surface'], surfaces_output.outputs[0])
# Scrolling
# This approach works 90% of the time, but notably produces very incorrect results
# on mus1_bldg_world_1,2,3
# Clear all anims in all cases # Clear all anims in all cases
if material.node_tree.animation_data: if material.node_tree.animation_data:
material.node_tree.animation_data.action.fcurves.clear() material.node_tree.animation_data.action.fcurves.clear()