WolvenKit / Cyberpunk-Blender-add-on

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

Loading materials error #142

Open Tosyk opened 3 weeks ago

Tosyk commented 3 weeks ago

trying to load Lexington handhun (e.g.: base\weapons\firearms\handgun\militech_lexington\w_handgun__militech_lexington__base1.ent) into blender 4.0 and 4.1 with latest blender plugin + tried dev build. no luck

here's the errors from console:

apps -  ['default']
Importing Entity w_handgun__militech_lexington_default
no anim rig found
no rig json loaded
appearance matched, id =  0
appearance matched, id =  0
Chunks found
default
F:\_r\gms\Cyberpunk_2077_pc\_tools\Mods\MyMod\source\raw\base\weapons\firearms\handgun\militech_lexington\entities\meshes\w_handgun__militech_lexington__base1_01.glb Loaded; With materials: True
Mask image not found for layer  1
Traceback (most recent call last):
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\i_scene_cp77_gltf\importers\import_with_materials.py", line 170, in CP77GLBimport
    bpymat = Builder.create(index)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\i_scene_cp77_gltf\main\setup.py", line 61, in create
    multilayered.create(rawMat["Data"],bpyMat)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\4.0\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\User\AppData\Roaming\Blender Foundation\Blender\4.0\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: local variable 'MaskTexture' referenced before assignment
None
default
F:\_r\gms\Cyberpunk_2077_pc\_tools\Mods\MyMod\source\raw\base\weapons\firearms\handgun\militech_lexington\entities\meshes\w_handgun__militech_lexington__base1_01_rail_01.glb Loaded; With materials: True
Mask image not found for layer  1
Traceback (most recent call last):
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\i_scene_cp77_gltf\importers\import_with_materials.py", line 170, in CP77GLBimport
    bpymat = Builder.create(index)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\i_scene_cp77_gltf\main\setup.py", line 61, in create
    multilayered.create(rawMat["Data"],bpyMat)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\4.0\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\User\AppData\Roaming\Blender Foundation\Blender\4.0\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: local variable 'MaskTexture' referenced before assignment
None
default
F:\_r\gms\Cyberpunk_2077_pc\_tools\Mods\MyMod\source\raw\base\weapons\firearms\handgun\militech_lexington\entities\meshes\w_handgun__militech_lexington__mag_std_01.glb Loaded; With materials: True
Mask image not found for layer  1
Traceback (most recent call last):
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\i_scene_cp77_gltf\importers\import_with_materials.py", line 170, in CP77GLBimport
    bpymat = Builder.create(index)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\i_scene_cp77_gltf\main\setup.py", line 61, in create
    multilayered.create(rawMat["Data"],bpyMat)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\4.0\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\User\AppData\Roaming\Blender Foundation\Blender\4.0\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: local variable 'MaskTexture' referenced before assignment
None
default
F:\_r\gms\Cyberpunk_2077_pc\_tools\Mods\MyMod\source\raw\base\weapons\firearms\handgun\militech_lexington\entities\meshes\w_handgun__militech_lexington__mag_std_01_decal_01.glb Loaded; With materials: True
default
F:\_r\gms\Cyberpunk_2077_pc\_tools\Mods\MyMod\source\raw\base\weapons\firearms\handgun\militech_lexington\entities\meshes\w_handgun__militech_lexington__base1_01_decals_01.glb Loaded; With materials: True
default
F:\_r\gms\Cyberpunk_2077_pc\_tools\Mods\MyMod\source\raw\base\weapons\firearms\handgun\militech_lexington\entities\meshes\w_handgun__militech_lexington__mag_stdr_01.glb Loaded; With materials: True
Mask image not found for layer  1
Traceback (most recent call last):
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\i_scene_cp77_gltf\importers\import_with_materials.py", line 170, in CP77GLBimport
    bpymat = Builder.create(index)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\i_scene_cp77_gltf\main\setup.py", line 61, in create
    multilayered.create(rawMat["Data"],bpyMat)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\4.0\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\User\AppData\Roaming\Blender Foundation\Blender\4.0\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: local variable 'MaskTexture' referenced before assignment
None
default
F:\_r\gms\Cyberpunk_2077_pc\_tools\Mods\MyMod\source\raw\base\weapons\firearms\handgun\militech_lexington\entities\meshes\w_handgun__militech_lexington__mag_std_01_decal_01.glb Loaded; With materials: True
Exported default
--- 0.826167106628418 seconds ---

Illustration of what I see in the blender image5

p.s.: it works with other models, but sometimes failed to import random materials. p.p.s.: wkit is also latest, + tried nightly.

Simarilius-uk commented 2 weeks ago

pretty sure its a bust ent. Try downloading https://www.nexusmods.com/cyberpunk2077/mods/9077 and using the lexington ent from that.

Simarilius-uk commented 2 weeks ago

the mask images thing looks like you've got a depot with older files in it and a newer wkit/plugin. Make sure your using a nightly wkit and the latest plugin, and empty your depot out and rerun the exports.

Dizcordum commented 2 weeks ago

https://github.com/Simarilius-uk/Cyberpunk-Blender-add-on/commit/0da3a5fd333415d02d16eaafecf8d629a83a3b07

  1. Heres the problem, older wkit depot generator generated a *_layers folder inside a textures folder
  2. Blender addon searched for mask textures only inside the textures folder, no further I had similar problem a while ago, and fixed it by just .bat batch dragged image masks from that '*_layers' folders up one lvl, basicly to the 'textures' folder (wkit do that now)

something changed and now new wkit generating depot without that layers folder, with storing all the mask just in in 'textures' but thats seems the problem because now blender doesnt load that material at all and blender doesnt create any materials because of it

i used 1.5.3 addon that loaded filename of the mask but not actual file until i dragged the masks out: 1

heres is usage of blender addon different version new 1.5.5 old 1.5.3 image

Dizcordum commented 2 weeks ago

@Tosyk try 1.5.3

DoctorPresto commented 2 weeks ago

Simarilius-uk@0da3a5f

  1. Heres the problem, older wkit depot generator generated a *_layers folder inside a textures folder
  2. Blender addon searched for mask textures only inside the textures folder, no further I had similar problem a while ago, and fixed it by just .bat batch dragged image masks from that '*_layers' folders up one lvl, basicly to the 'textures' folder (wkit do that now)

something changed and now new wkit generating depot without that layers folder, with storing all the mask just in in 'textures' but thats seems the problem because now blender doesnt load that material at all and blender doesnt create any materials because of it

i used 1.5.3 addon that loaded filename of the mask but not actual file until i dragged the masks out: 1

heres is usage of blender addon different version new 1.5.5 old 1.5.3 image

This also can be fixed by just changing your depot path in wolvenkit and re exporting the meshes as Sim had suggested. To be clear, there is no need to generate material depot for the plugin, Wolvenkit automatically does this when you export meshes. Only need to do a full material depot for mlsb