FlailingFog / KK-Blender-Porter-Pack

Plugin pack for exporting Koikatsu characters to Blender.
305 stars 28 forks source link

Importer doesn't work on blender 3.6 #508

Open Zero-One-Dawn opened 4 months ago

Zero-One-Dawn commented 4 months ago

I used the default card to test, as i had this issue in the past as well

Error: Unknown python error occurred. Make sure the default model imports correctly before troubleshooting on this model!

Traceback (most recent call last): File "C:\Users\jgeff\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\KK-Blender-Porter-Pack-master\importing\modifymaterial.py", line 73, in execute self.load_json_colors() File "C:\Users\jgeff\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\KK-Blender-Porter-Pack-master\importing\modifymaterial.py", line 993, in load_json_colors self.update_shaders(json_color_data, self.lut_selection, self.lut_light, light = True) # Set light colors File "C:\Users\jgeff\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\KK-Blender-Porter-Pack-master\importing\modifymaterial.py", line 1604, in update_shaders shadow_color} UnboundLocalError: local variable 'shadow_color' referenced before assignment

Error: Traceback (most recent call last): File "C:\Users\jgeff\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\KK-Blender-Porter-Pack-master\importing\modifymaterial.py", line 73, in execute self.load_json_colors() File "C:\Users\jgeff\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\KK-Blender-Porter-Pack-master\importing\modifymaterial.py", line 993, in load_json_colors self.update_shaders(json_color_data, self.lut_selection, self.lut_light, light = True) # Set light colors File "C:\Users\jgeff\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\KK-Blender-Porter-Pack-master\importing\modifymaterial.py", line 1604, in update_shaders shadow_color} UnboundLocalError: local variable 'shadow_color' referenced before assignment

Traceback (most recent call last): File "C:\Users\jgeff\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\KK-Blender-Porter-Pack-master\importing\importbuttons.py", line 85, in execute function() File "C:\Users\jgeff\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\KK-Blender-Porter-Pack-master\importing\importbuttons.py", line 62, in lambda:bpy.ops.kkbp.modifymaterial('INVOKE_DEFAULT'), File "C:\Program Files\Blender Foundation\Blender 3.6\3.6\scripts\modules\bpy\ops.py", line 111, in call ret = _op_call(self.idname_py(), C_dict, kw, C_exec, C_undo) RuntimeError: Error: Traceback (most recent call last): File "C:\Users\jgeff\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\KK-Blender-Porter-Pack-master\importing\modifymaterial.py", line 73, in execute self.load_json_colors() File "C:\Users\jgeff\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\KK-Blender-Porter-Pack-master\importing\modifymaterial.py", line 993, in load_json_colors self.update_shaders(json_color_data, self.lut_selection, self.lut_light, light = True) # Set light colors File "C:\Users\jgeff\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\KK-Blender-Porter-Pack-master\importing\modifymaterial.py", line 1604, in update_shaders shadow_color} UnboundLocalError: local variable 'shadow_color' referenced before assignment

Currently using Blender 3.6, MMD Tools 2.10.2, and an up to date Koikatsu Sunshine install

Yajnn commented 4 months ago

Wanted to add to this.

Tested only on Koikatsu Sunshine (KKS) and on default character. Release 6.6.2 + KKB Exporter v. 4.30 doesn't work for KKS material colors but 6.5.0 + KKB Exporter v. 4.21 works just fine. This may be due to the change in assigning the color values from the KK_MaterialData.json in 6.6.2 versus from the KK_CharacterColors.json in 6.5.0.

With the change of reading from material data instead of character colors, KKS is missing all it's color assignments.

Looks like majority of the KKS color issues may be due to the plugin not exporting the ShaderPropNames, ShaderPropTextures, ShaderPropTextureValues, ShaderPropColorValues, or ShaderPropFloatValues lists in the KK_MaterialData.json file. Those exported lists are always empty.

A quick fix I did for the above issue was initializing the shadow_color before assigning it like so, in modifymaterial.py on lines 1469-1473

# Assign shadow color before trying to find it (if lists are empty, atleast we'll have a default value)
shadow_color = {"r":0.764,"g":0.880,"b":1,"a":1}
for entry in colors:
    if '_ShadowColor ' in entry:
        shadow_color = colors[entry]
        break

Afterwards, import works fine for image textures, but not for colored textures like hair, eyelashes, or eyebrows. My guess is that this is supposed to be assigned from the material data.

Hope this helped devs!