WolvenKit / Cyberpunk-Blender-add-on

The Cyberpunk add-on for Blender bridges complex game assets with Blender.
66 stars 17 forks source link

UnboundLocalError: cannot access local variable 'MaskTexture' where it is not associated with a value #130

Closed Surasia closed 2 months ago

Surasia commented 2 months ago

While importing lizzy wizzy's ep1 (phantom liberty) model ENT, some mask textures fail to import with this error in the console:

UnboundLocalError: cannot access local variable 'MaskTexture' where it is not associated with a value
None
Mask image not found for layer  1
Traceback (most recent call last):
  File "C:\Users\---\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\i_scene_cp77_gltf\importers\import_with_materials.py", line 167, in CP77GLBimport
    bpymat = Builder.create(index)
             ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\---\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\i_scene_cp77_gltf\main\setup.py", line 61, in create
    multilayered.create(rawMat["Data"],bpyMat)
  File "C:\Users\---\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\i_scene_cp77_gltf\material_types\multilayered.py", line 664, in create
    self.createLayerMaterial(os.path.basename(Data["MultilayerSetup"])[:-8]+"_Layer_",LayerCount,CurMat,Data["MultilayerMask"],LayerNormal)
  File "C:\Users\---\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\i_scene_cp77_gltf\material_types\multilayered.py", line 192, in createLayerMaterial
    MaskN = create_node(CurMat.nodes,"ShaderNodeTexImage",(-2400,400-100*x), image = MaskTexture,label="Layer_"+str(x+1))
                                                                                     ^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'MaskTexture' where it is not associated with a value

I'm using Blender 4.2 Alpha, with Wolvenkit 8.13.0-nightly.2024-04-01 and the latest release version of the addon.

Simarilius-uk commented 2 months ago

your masks havent been written by wkit to the depot for some reason. Someone had this the other day and used a new folder for their depot in wkit and reran the export and it worked ok. try that. (or empty the depot and rerun the export)

DoctorPresto commented 2 months ago

Also please note that you won't be able to import any meshes back into Wolvenkit with anything past blender 4.02. I'd really recommend against using alpha builds of blender (or even beta builds) as there are often API changes which will require the rest of the tool chain to be updated. 4.2 isn't scheduled to release until mid July.

Surasia commented 2 months ago

Hm, the issue seems to persist even after moving/emptying the depot, re-exporting a few times and redoing the project. I'll try an earlier version of Blender- I appreciate the heads up on the blender versions. Had me wondering why my imports weren't working :D Will report back with 4.0.2 in a moment.

Surasia commented 2 months ago

Yep, same issue with older versions of Blender and Wolvenkit. I'll close the issue for now as it is highly likely I have something misconfigured, or that it is an issue with Wolvenkit not reading files properly. Before the openJSON changes the imports would be wrongly misconfigured as well, but now there are also tracebacks. The issues started around when I updated the game to 2.1, so I'll try everything in a completely clean environment (VM) with a new install.

DoctorPresto commented 2 months ago

Just want to be sure as this is a common misunderstanding I've ran into. You changed the depot path that you have set in wolvenkit - tools - settings and then re exported everything and the error persisted?

Can you confirm you have done the above and not just removed files from the project?

Can you also confirm that you did not change the depot path in the blender plugin preferences?

Surasia commented 2 months ago

Yep, I made sure to check the depot path, re-export with the new depot settings, wiped the depot, not the project. Same textures, with the same issue.

Surasia commented 1 month ago

With the latest uploaded build (through github actions) and Wolvenkit 8.13.0-nightly.2024-04-21, everything seems to work! All models import properly. *except some minor roughness issues, think some defaults aren't set properly