Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Local Variable 'diffuse_tex' Referenced Before Assignment" Error on Import #15

Open
WildKarrde1138 opened this issue Jun 25, 2024 · 1 comment

Comments

@WildKarrde1138
Copy link

Some vanilla models, such as 003ebol.mdl/mdx from TSL, fail to completely import and return the error "local variable 'diffuse_tex' referenced before assignment" when using KotorBlender 3.10.3 with Blender 4.0. I am still able to import the model using version 3.5.2 with Blender 2.93, so I'm guessing it's something that changed between those two versions. I have attached 003ebol.mdl/mdx for reference.
003ebol.zip

@DarthParametric
Copy link

DarthParametric commented Nov 3, 2024

To provide some additional context, it seems like it chokes when parsing the mesh engpanlight (which is the only mesh with the LEH_light01 diffuse). It is lightmapped and has self-illum, if that is relevant.

Loading image: G:\Star Wars Knights of the Old Republic\-=TOOLS=-\KOTOR Tool\working\TEXTURES\K1\LEH_light01.tga
Traceback (most recent call last):
  File "D:\Blender\3.6.2 LTS\3.6\scripts\addons\io_scene_kotor\ops\lyt\importop.py", line 68, in execute
    lyt.load_lyt(self, self.filepath, options)
  File "D:\Blender\3.6.2 LTS\3.6\scripts\addons\io_scene_kotor\io\lyt.py", line 61, in load_lyt
    mdl.load_mdl(operator, mdl_path, options, room[1:])
  File "D:\Blender\3.6.2 LTS\3.6\scripts\addons\io_scene_kotor\io\mdl.py", line 80, in load_mdl
    model_root = model.add_to_collection(collection, options, position)
  File "D:\Blender\3.6.2 LTS\3.6\scripts\addons\io_scene_kotor\scene\model.py", line 70, in add_to_collection
    self.import_nodes_to_collection(child, root_obj, collection, options)
  File "D:\Blender\3.6.2 LTS\3.6\scripts\addons\io_scene_kotor\scene\model.py", line 105, in import_nodes_to_collection
    obj = node.add_to_collection(collection, options)
  File "D:\Blender\3.6.2 LTS\3.6\scripts\addons\io_scene_kotor\scene\modelnode\trimesh.py", line 158, in add_to_collection
    material.rebuild_object_materials(
  File "D:\Blender\3.6.2 LTS\3.6\scripts\addons\io_scene_kotor\scene\material.py", line 79, in rebuild_object_materials
    rebuild_material_textured(
  File "D:\Blender\3.6.2 LTS\3.6\scripts\addons\io_scene_kotor\scene\material.py", line 228, in rebuild_material_textured
    links.new(mul_diffuse_lightmap.inputs[0], diffuse_tex.outputs[0])
UnboundLocalError: local variable 'diffuse_tex' referenced before assignment

Alternatively, the node after that one is the walkmesh, then the following one is Box19, which has a lightmap but no diffuse.

Edit: Yes, it's meshes with lightmaps but no diffuse that it is choking on. Occurs with both 003EBOl and 003EBOq (meshes Box19 and Box18, respectively). Editing those in KMax to assign a diffuse and then recompiling, KBlender will load the layout without error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants