FlailingFog / KK-Blender-Porter-Pack

Plugin pack for exporting Koikatsu characters to Blender.
Other
375 stars 30 forks source link

KKBP 7.0.0, keyerror: 'color' #589

Closed AyaFrost closed 3 weeks ago

AyaFrost commented 3 months ago

I've been trying to get the importer working with the beta 7.0.0 but every time i try to port a model it gives me the same error. I've tried using different dependencies and have used a fresh install of HF patch 3.28 and i still get the same problem every time.

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\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\modifymaterial.py", line 74, in execute self.load_json_colors() File "C:\Users\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\modifymaterial.py", line 1020, in load_json_colors self.update_shaders(json_color_data, self.lut_selection, self.lut_light, light = True) # Set light colors ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\modifymaterial.py", line 1252, in update_shaders face_colors.append(self.color_to_KK(to_255(colors.get("_overcolor1 Color 1", {"r":1,"g":0,"b":0,"a":1})), active_lut)) #lipstick ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\modifymaterial.py", line 1124, in color_to_KK batch = batch_for_shader(shader, 'TRI_STRIP', {'a_position': ((-1, -1), (1, -1), (1, 1), (-1, 1), (-1, -1)),}) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files (x86)\Steam\steamapps\common\Blender\4.2\scripts\modules\gpu_extras\batch.py", line 64, in batch_for_shader attr_len = recommended_attr_len(name) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files (x86)\Steam\steamapps\common\Blender\4.2\scripts\modules\gpu_extras\batch.py", line 41, in recommended_attr_len item = content[attr_name][0]


KeyError: 'color'

Error: Traceback (most recent call last):
  File "C:\Users\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\modifymaterial.py", line 74, in execute
    self.load_json_colors()
  File "C:\Users\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\modifymaterial.py", line 1020, in load_json_colors
    self.update_shaders(json_color_data, self.lut_selection, self.lut_light, light = True) # Set light colors
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\modifymaterial.py", line 1252, in update_shaders
    face_colors.append(self.color_to_KK(to_255(colors.get("_overcolor1 Color 1", {"r":1,"g":0,"b":0,"a":1})), active_lut)) #lipstick
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Traceback (most recent call last):
  File "C:\Users\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\importbuttons.py", line 97, in execute
    function()
  File "C:\Users\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\importbuttons.py", line 71, in <lambda>
    lambda:bpy.ops.kkbp.modifymaterial('INVOKE_DEFAULT'),
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files (x86)\Steam\steamapps\common\Blender\4.2\scripts\modules\bpy\ops.py", line 107, in __call__
    ret = _op_call(self.idname_py(), kw, C_exec, C_undo)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Error: Traceback (most recent call last):
  File "C:\Users\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\modifymaterial.py", line 74, in execute
    self.load_json_colors()
  File "C:\Users\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\modifymaterial.py", line 1020, in load_json_colors
    self.update_shaders(json_color_data, self.lut_selection, self.lut_light, light = True) # Set light colors
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\modifymaterial.py", line 1252, in update_shaders
    face_colors.append(self.color_to_KK(to_255(colors.get("_overcolor1 Color 1", {"r":1,"g":0,"b":0,"a":1})), active_lut)) #lipstick
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\modifymaterial.py", line 1124, in color_to_KK
    batch = batch_for_shader(shader, 'TRI_STRIP', {'a_position': ((-1, -1), (1, -1), (1, 1), (-1, 1), (-1, -1)),})
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files (x86)\Steam\steamapps\common\Blender\4.2\scripts\modules\gpu_extras\batch.py", line 64, in batch_for_shader
    attr_len = recommended_attr_len(name)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files (x86)\Steam\steamapps\common\Blender\4.2\scripts\modules\gpu_extras\batch.py", line 41, in recommended_attr_len
    item = content[attr_name][0]
           ~~~~~~~^^^^^^^^^^^
KeyError: 'color'
vermilionshadow-vk commented 2 months ago

Got this issue as well, seemingly going on with any model as well on my end. The log I'm about to post as well is when I was testing with Chikarin to see if it was maybe something with the mods I was using that's making the importer not happy with my custom characters but it seems that even Koi's default model doesn't want to fully load up.

setup_gag_eye_material_drivers operation took 0.002 seconds add_outlines_to_body operation took 0.075 seconds add_outlines_to_hair operation took 0.278 seconds add_outlines_to_clothes operation took 0.639 seconds convert_main_textures operation took 0.003 seconds

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\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\modifymaterial.py", line 74, in execute self.load_json_colors() File "C:\Users\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\modifymaterial.py", line 1016, in load_json_colors self.update_shaders(json_color_data, self.lut_selection, self.lut_light, light = True) # Set light colors ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\modifymaterial.py", line 1248, in update_shaders face_colors.append(self.color_to_KK(to_255(colors.get("_overcolor1 Color 1", {"r":1,"g":0,"b":0,"a":1})), active_lut)) #lipstick ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\modifymaterial.py", line 1120, in color_to_KK batch = batch_for_shader(shader, 'TRI_STRIP', {'a_position': ((-1, -1), (1, -1), (1, 1), (-1, 1), (-1, -1)),}) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\Blender Foundation\Blender 4.2\4.2\scripts\modules\gpu_extras\batch.py", line 64, in batch_for_shader attr_len = recommended_attr_len(name) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\Blender Foundation\Blender 4.2\4.2\scripts\modules\gpu_extras\batch.py", line 41, in recommended_attr_len item = content[attr_name][0]


KeyError: 'color'

Error: Traceback (most recent call last):
  File "C:\Users\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\modifymaterial.py", line 74, in execute
    self.load_json_colors()
  File "C:\Users\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\modifymaterial.py", line 1016, in load_json_colors
    self.update_shaders(json_color_data, self.lut_selection, self.lut_light, light = True) # Set light colors
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\modifymaterial.py", line 1248, in update_shaders
    face_colors.append(self.color_to_KK(to_255(colors.get("_overcolor1 Color 1", {"r":1,"g":0,"b":0,"a":1})), active_lut)) #lipstick
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File Traceback (most recent call last):
  File "C:\Users\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\importbuttons.py", line 112, in execute
    function()
  File "C:\Users\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\importbuttons.py", line 86, in <lambda>
    lambda:bpy.ops.kkbp.modifymaterial('INVOKE_DEFAULT'),
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Blender Foundation\Blender 4.2\4.2\scripts\modules\bpy\ops.py", line 107, in __call__
    ret = _op_call(self.idname_py(), kw, C_exec, C_undo)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Error: Traceback (most recent call last):
  File "C:\Users\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\modifymaterial.py", line 74, in execute
    self.load_json_colors()
  File "C:\Users\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\modifymaterial.py", line 1016, in load_json_colors
    self.update_shaders(json_color_data, self.lut_selection, self.lut_light, light = True) # Set light colors
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\modifymaterial.py", line 1248, in update_shaders
    face_colors.append(self.color_to_KK(to_255(colors.get("_overcolor1 Color 1", {"r":1,"g":0,"b":0,"a":1})), active_lut)) #lipstick
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\me\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\modifymaterial.py", line 1120, in color_to_KK
    batch = batch_for_shader(shader, 'TRI_STRIP', {'a_position': ((-1, -1), (1, -1), (1, 1), (-1, 1), (-1, -1)),})
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Blender Foundation\Blender 4.2\4.2\scripts\modules\gpu_extras\batch.py", line 64, in batch_for_shader
    attr_len = recommended_attr_len(name)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Blender Foundation\Blender 4.2\4.2\scripts\modules\gpu_extras\batch.py", line 41, in recommended_attr_len
    item = content[attr_name][0]
           ~~~~~~~^^^^^^^^^^^
KeyError: 'color'

And this is what my Blender looks like when the error occurs:
![image](https://github.com/user-attachments/assets/2945b15e-caed-4b31-bcb3-d31f1f66df8c)

Material view sometimes just, doesn't work (like in this case with Chikarin). When it does work for say one of my models, the outfits are all white and yellow.
FrankV724 commented 2 months ago

I confirm the exact same issue on Blender 4.2.0 with KKBP 7.0.0, but also checking out the material view the model is very yellow. Same console results as well when testing with default Chika. image

ecchichuu commented 1 month ago

I'm getting the same error and yellow result like Frank

RiccioGamer56 commented 3 weeks ago

This might be a issue related to amd gpu since I also have it. Currently I dont know the fix but some users said that they tried both nvidia and amd cards and they didnt get this problelm with nvidia.

vermilionshadow-vk commented 3 weeks ago

Good point, I also have an AMD GPU as well. I imagine Blender is designed around CUDA APIs in mind, which is an Nvidia thing. Not sure if there's any sort of direct workaround, would love to hear from anyone that's far more experienced in Blender to see if there might be a solution.

FlailingFog commented 3 weeks ago

It's failing at the part where it uses the blender 4.2 gpu library to saturate the model colors. I'm going to see if I can get this alternative saturation method working first. That method should work regardless of what gpu you have.

I've never heard of anyone having this issue when the plugin was using the bgl library, so if that first method doesn't pan out, I can likely fall back to saturating the colors with the older blender 2.90/3.6 bgl library and it'll still work for everyone

deckultra734 commented 3 weeks ago

This might be a issue related to amd gpu since I also have it.

Can confirm that it's a AMD GPU issue, using NVIDIA with a custom stubbed build on Linux and it imports "correctly" without needing wine.

FlailingFog commented 3 weeks ago

I updated the plugin in another branch. Hopefully this version will work:

KK-Blender-Porter-Pack-numpy-saturation-method.zip

vermilionshadow-vk commented 3 weeks ago

Just tried it with the numpy saturation method version and seems to go through everything just fine Some missing textures/glasses transparency I'll need to look into for this model but otherwise it seems to saturate the model unlike before. image

RiccioGamer56 commented 3 weeks ago

I updated the plugin in another branch. Hopefully this version will work:

KK-Blender-Porter-Pack-numpy-saturation-method.zip

Yeah this works, thank you

FlailingFog commented 3 weeks ago

fixed in kkbp 7.1.0