KK-Blender-Porter-Pack icon indicating copy to clipboard operation
KK-Blender-Porter-Pack copied to clipboard

KKBP Exporter and Plugin Updates

Open MediaMoots opened this issue 2 years ago • 93 comments

This update has two changes:

  1. Fixes issues like #81 In fact, KK always applies a small correction to the eyes even if all sliders are set to default, this update fixes this issue. Basically, the plugin will always clear all blend shapes before exporting.

  2. It now exports the Tears object please see #137 May need to solve this issue first before merging or there might be errors

MediaMoots avatar Mar 25 '22 09:03 MediaMoots

V1.21 Fixed eye white Shape keys (so no need for manual fixing) Fixed Sirome material name.

MediaMoots avatar Mar 26 '22 02:03 MediaMoots

V1.22 Exports the canine (Small Fangs) mesh image

it uses the same material as the teeth. image

MediaMoots avatar Mar 26 '22 02:03 MediaMoots

This is a really nice fix. I'm curious what it was though, are they using the armature to make those corrections or was it something else? You mention clearing the blendshapes. The fangs are exporting even when they're disabled. Is there a way to prevent this? It'd be nice to have the eyewhite shapekeys fixed in the exporter because the blender script that fixes them can crash the program, but the fix didn't seem to work (only the left eyewhite works). The script I had in shapekeys.py also doesn't fix them anymore and instead just leaves them static for all shapekeys.

FlailingFog avatar Mar 28 '22 01:03 FlailingFog

I'm curious what it was though, are they using the armature to make those corrections or was it something else?

It was the FaceBlendShape script that was constantly correcting the eyelids to a certain value and also if the character was exported with a face ptn applied it would cause the mesh to be exported with those blendshapes, problem is that the blendshapes were supposed to be applied to the base mesh, so clearing the blendshapes restores the base mesh.

The fangs are exporting even when they're disabled. Is there a way to prevent this?

Sure, ill add a check.

It'd be nice to have the eyewhite shapekeys fixed in the exporter because the blender script that fixes them can crash the program, but the fix didn't seem to work (only the left eyewhite works).

Oh no, I thought it fixed them. Which shapekeys are broken? I tested all the eye_siroR.sR00_* and eye_siroL.sL00_* which were broken before, but after the fix: image image

PS: the above is the raw model right after the cats import and hasn't gone through the kkbp scripts yet.

MediaMoots avatar Mar 28 '22 01:03 MediaMoots

Yeah I'm not sure what's up. All of the siroR shapekeys are still affecting the left eye (before running any scripts). I double checked I had the 1.22 exporter version and used chika as the test model.

FlailingFog avatar Apr 03 '22 21:04 FlailingFog

Yeah I'm not sure what's up. All of the siroR shapekeys are still affecting the left eye (before running any scripts). I double checked I had the 1.22 exporter version and used chika as the test model.

Thats so weird, I just tested it with Chika and the siroR only affects the right side image image

Which Koikatsu game was chika exported from? I used the OG Better repack RX11

MediaMoots avatar Apr 20 '22 06:04 MediaMoots

V1.30

Fixed exporting fangs Fix for https://github.com/FlailingFog/KK-Blender-Porter-Pack/issues/125 Fix for https://github.com/FlailingFog/KK-Blender-Porter-Pack/issues/151 Fix for https://github.com/FlailingFog/KK-Blender-Porter-Pack/issues/152

Also added support for exporting some SkinnedMeshRenderer data such as which bones/materials each renderer uses, it's a feature to help with porting characters to game engines other than Unity.

I had to shrink all the texture Postfixes to reduce file name length if not blender chops the file name.

As for the shapekeys, I'm not sure what the issue is since Chika works for me. Would it be possible for you to try this pmx file that I exported and see if the problem persists? Thanks! model.zip

MediaMoots avatar Apr 20 '22 10:04 MediaMoots

V1.32 0513821 Fix for #150 Fix for #118 Export fix for #147

The main feature of this version is that now all meshes that don't have bones (Accessories, hair, etc...) will be attached automatically to their ca_slotXX bone, gone are the days of manually setting vertex weights, haha.

Funnily enough issues #150 and #118 were the same problem just from a different angle, lol.

MediaMoots avatar Apr 21 '22 07:04 MediaMoots

V1.33 Fix for #139

The exporter will now export texture offset and scale data to a Json file, then the plugin will take that data and apply it to every imported texture node. image

Some shaders might need tweaking (eg. hitomi) but I'm scared of merge conflicts, so I didn't change the blend file.

MediaMoots avatar Apr 21 '22 09:04 MediaMoots

Hey, thanks a lot for the quick fix @MediaMoots! Can I test the new exporter with latest KKBP blender plugin release or there will be compatibility issues?

TigerHix avatar Apr 21 '22 09:04 TigerHix

@TigerHix

thanks a lot for the quick fix

No problem :)

Can I test the new exporter with latest KKBP blender plugin release or there will be compatibility issues?

No, it won't work, so for now please use the branch this PR is based on: https://github.com/MediaMoots/KK-Blender-Shader-Pack/tree/pluginupdate

MediaMoots avatar Apr 21 '22 09:04 MediaMoots

V1.34

Changed the meshes that have no bones to use its own GameObject/bone instead of its parent.

So now the bone hierarchy would be like so image ca_slotXX -> nc -> N-Move.XX -> MeshName

MediaMoots avatar Apr 21 '22 10:04 MediaMoots

Convert and apply colors to shader error.

Python: Traceback (most recent call last):
  File "C:\Users\user\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\KK-Blender-Porter-Pack-master\importing\importcolors.py", line 735, in execute
    load_json_colors(directory, lut_light, lut_dark, lut_selection)
  File "C:\Users\user\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\KK-Blender-Porter-Pack-master\importing\importcolors.py", line 507, in load_json_colors
    update_shaders(json_color_data, lut_selection, lut_light, light = True) # Set light colors
  File "C:\Users\user\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\KK-Blender-Porter-Pack-master\importing\importcolors.py", line 563, in update_shaders
    body_colors.append(to_rgba(color_to_KK(json_to_color(json[0]['colorInfo'][0]), active_lut) / 255))
  File "C:\Users\user\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\KK-Blender-Porter-Pack-master\importing\importcolors.py", line 246, in color_to_KK
    shader = gpu.types.GPUShader(vertex_default, current_code)
Exception: Shader Compile Error, see console for more details

location: <unknown location>:-1


ghost avatar Apr 22 '22 10:04 ghost

Convert and apply colors to shader error.

Python: Traceback (most recent call last):
  File "C:\Users\user\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\KK-Blender-Porter-Pack-master\importing\importcolors.py", line 735, in execute
    load_json_colors(directory, lut_light, lut_dark, lut_selection)
  File "C:\Users\user\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\KK-Blender-Porter-Pack-master\importing\importcolors.py", line 507, in load_json_colors
    update_shaders(json_color_data, lut_selection, lut_light, light = True) # Set light colors
  File "C:\Users\user\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\KK-Blender-Porter-Pack-master\importing\importcolors.py", line 563, in update_shaders
    body_colors.append(to_rgba(color_to_KK(json_to_color(json[0]['colorInfo'][0]), active_lut) / 255))
  File "C:\Users\user\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\KK-Blender-Porter-Pack-master\importing\importcolors.py", line 246, in color_to_KK
    shader = gpu.types.GPUShader(vertex_default, current_code)
Exception: Shader Compile Error, see console for more details

location: <unknown location>:-1

could you post the console contents please?

MediaMoots avatar Apr 22 '22 10:04 MediaMoots

could you post the console contents please?

Sure thing, sorry didn't knew I had to.

Info: Imported MMD model from "C:\Users\user\Documents\Koikatsu\Export_PMX\20220422200246_f_01a1.9.4\model.pmx"
Added:  Model_arm
====    KKBP Log    ====
Modifying armature...

Fixing shapekeys...
Warning: 1 x Draw window and swap: 15.7342 ms, average: 15.73419999 ms
Fixing eyewhite shapekeys...
Warning: 1 x Draw window and swap: 27.0496 ms, average: 27.04960000 ms
Combining shapekeys...
Warning: 1 x Draw window and swap: 14.9634 ms, average: 14.96340000 ms
Warning: 1 x Draw window and swap: 30.4166 ms, average: 30.41660000 ms
Warning: 1 x Draw window and swap: 5.8044 ms, average: 5.80440002 ms
Warning: 1 x Draw window and swap: 22.0869 ms, average: 22.08690002 ms
Warning: 1 x Draw window and swap: 45.6650 ms, average: 45.66500001 ms
Warning: 1 x Draw window and swap: 7.1936 ms, average: 7.19360000 ms
Warning: 1 x Draw window and swap: 23.5018 ms, average: 23.50179999 ms
Warning: 1 x Draw window and swap: 23.1627 ms, average: 23.16270000 ms
Warning: 1 x Draw window and swap: 12.4744 ms, average: 12.47439999 ms
Warning: 1 x Draw window and swap: 5.1748 ms, average: 5.17480000 ms
Warning: 1 x Draw window and swap: 5.6307 ms, average: 5.63070000 ms
Warning: 1 x Draw window and swap: 5.2318 ms, average: 5.23179999 ms
Warning: 1 x Draw window and swap: 5.2239 ms, average: 5.22389999 ms
Warning: 1 x Draw window and swap: 5.0913 ms, average: 5.09130000 ms
Warning: 1 x Draw window and swap: 4.9260 ms, average: 4.92599999 ms
Warning: 1 x Draw window and swap: 5.0264 ms, average: 5.02640000 ms
Warning: 1 x Draw window and swap: 4.9436 ms, average: 4.94360001 ms
Warning: 1 x Draw window and swap: 5.1039 ms, average: 5.10390001 ms
Warning: 1 x Draw window and swap: 5.1424 ms, average: 5.14239998 ms
Warning: 1 x Draw window and swap: 5.2509 ms, average: 5.25089999 ms
Warning: 1 x Draw window and swap: 5.1247 ms, average: 5.12469999 ms
Warning: 1 x Draw window and swap: 5.2104 ms, average: 5.21040001 ms
Warning: 1 x Draw window and swap: 5.1409 ms, average: 5.14090000 ms
Warning: 1 x Draw window and swap: 5.1396 ms, average: 5.13960002 ms
Warning: 1 x Draw window and swap: 4.9920 ms, average: 4.99200000 ms
Warning: 1 x Draw window and swap: 14.9403 ms, average: 14.94030000 ms
Warning: 1 x Draw window and swap: 15.1539 ms, average: 15.15389999 ms
Warning: 1 x Draw window and swap: 14.9701 ms, average: 14.97009999 ms
Warning: 1 x Draw window and swap: 14.7668 ms, average: 14.76679998 ms
Warning: 1 x Draw window and swap: 6.2753 ms, average: 6.27530002 ms
Warning: 1 x Draw window and swap: 5.3054 ms, average: 5.30540000 ms
Warning: 1 x Draw window and swap: 5.4481 ms, average: 5.44809998 ms
Warning: 1 x Draw window and swap: 5.4311 ms, average: 5.43110000 ms
Warning: 1 x Draw window and swap: 5.2106 ms, average: 5.21060001 ms
Warning: 1 x Draw window and swap: 5.0863 ms, average: 5.08629999 ms
Warning: 1 x Draw window and swap: 5.4110 ms, average: 5.41099999 ms
Warning: 1 x Draw window and swap: 5.2670 ms, average: 5.26700000 ms
Warning: 1 x Draw window and swap: 5.2196 ms, average: 5.21959999 ms
Warning: 1 x Draw window and swap: 5.3013 ms, average: 5.30130000 ms
Warning: 1 x Draw window and swap: 5.3354 ms, average: 5.33540000 ms
Warning: 1 x Draw window and swap: 5.1808 ms, average: 5.18079998 ms
Warning: 1 x Draw window and swap: 10.0950 ms, average: 10.09500001 ms
Warning: 1 x Draw window and swap: 6.4357 ms, average: 6.43570002 ms
Warning: 1 x Draw window and swap: 5.3911 ms, average: 5.39110001 ms
Warning: 1 x Draw window and swap: 5.2000 ms, average: 5.19999999 ms
Warning: 1 x Draw window and swap: 5.2950 ms, average: 5.29499998 ms
Warning: 1 x Draw window and swap: 5.3062 ms, average: 5.30620001 ms
Warning: 1 x Draw window and swap: 5.3966 ms, average: 5.39660000 ms

Separating body, clothes and shadowcast, then removing duplicate materials...
Warning: 1 x Draw window and swap: 14.5775 ms, average: 14.57750000 ms
Warning:        Material wasn't found when separating body materials: cf_m_tooth.001
Warning:        Material wasn't found when separating body materials: cf_m_face_00.001
Warning:        Material wasn't found when separating body materials: cm_m_body
Warning:        Material wasn't found when separating body materials: c_m_shadowcast
Warning:        Material wasn't found when separating body materials: Standard
Error: Nothing selected
Info: Removed 37 slots
Info: Shadowcast moved to Shadowcast Collection
Info: Removed 1467 vertice(s)
Info: Removed 0 vertice(s)
Info: Successfully set shapekey "Tear small" as the new Basis.
Info: Removed 0 vertice(s)
Info: Successfully set shapekey "Tear med" as the new Basis.
Info: Removed 0 vertice(s)
Info: Successfully set shapekey "Tear big" as the new Basis.
Info: Removed 13 slots

Categorizing bones into armature layers...
Warning: 1 x Draw window and swap: 21.4599 ms, average: 21.45990002 ms

Adding bone drivers...
Warning: 1 x Draw window and swap: 25.2960 ms, average: 25.29600001 ms
Reparenting bones and setting up IKs...
Warning: 1 x Draw window and swap: 21.6814 ms, average: 21.68140002 ms
Warning: 1 x Draw window and swap: 14.3742 ms, average: 14.37419999 ms
Setting up joint bones...
Warning: 1 x Draw window and swap: 15.2343 ms, average: 15.23429999 ms
Creating eye controller and renaming bones...
Warning: 1 x Draw window and swap: 15.9303 ms, average: 15.93030000 ms

Applying material templates and textures...
Info: Removed 4 slots
Warning:        material or template wasn't found: cf_m_sirome_00 / Template Eyewhites (sirome)
Warning:        material or template wasn't found: cm_m_body / Template Body
Warning:        material or template wasn't found: cf_m_tooth.001 / Template Fangs (tooth.001)
Warning: 1 x Draw window and swap: 181.7564 ms, average: 181.75640001 ms
Getting textures from: C:\Users\user\Documents\Koikatsu\Export_PMX\20220422200246_f_01a1.9.4\
File not found, skipping: cm_m_body_DM.png
File not found, skipping: cm_m_body_LM.png
File not found, skipping: cf_m_body_ot2.png
File not found, skipping: cm_m_body_ot1.png
File not found, skipping: cm_m_body_ot1.png
File not found, skipping: cf_m_face_00_T5.png
File not found, skipping: cf_m_noseline_00_MT_CT.png
File not found, skipping: cf_m_hair_b_00 -362714_MT_CT.png
File not found, skipping: cf_m_hair_b_00 -362714_DM.png
File not found, skipping: cf_m_hair_b_00 -362714_AM.png
Warning: 1 x Draw window and swap: 60.0520 ms, average: 60.05200002 ms
cf_m_hair_b_00 -362714 had no alphamask or maintex
Adding bone widgets...
Warning: 1 x Draw window and swap: 24.7139 ms, average: 24.71390000 ms

Converting Colors...
ERROR (gpu.shader): pyGPUShader FragShader:
      |
   73 |         gl_FragColor = vec4(shaderColor.rgb, 1);
      |
      | Error: C7616: global variable gl_FragColor is removed after version 420

Python: Traceback (most recent call last):
  File "C:\Users\user\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\KK-Blender-Porter-Pack-master\importing\importcolors.py", line 735, in execute
    load_json_colors(directory, lut_light, lut_dark, lut_selection)
  File "C:\Users\user\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\KK-Blender-Porter-Pack-master\importing\importcolors.py", line 507, in load_json_colors
    update_shaders(json_color_data, lut_selection, lut_light, light = True) # Set light colors
  File "C:\Users\user\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\KK-Blender-Porter-Pack-master\importing\importcolors.py", line 563, in update_shaders
    body_colors.append(to_rgba(color_to_KK(json_to_color(json[0]['colorInfo'][0]), active_lut) / 255))
  File "C:\Users\user\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\KK-Blender-Porter-Pack-master\importing\importcolors.py", line 246, in color_to_KK
    shader = gpu.types.GPUShader(vertex_default, current_code)
Exception: Shader Compile Error, see console for more details

location: <unknown location>:-1

ghost avatar Apr 22 '22 11:04 ghost

@stillnewtoblender Thanks! From the log I can see that you are still using the outdated version of the plugin, please make sure to use this branch https://github.com/MediaMoots/KK-Blender-Shader-Pack/tree/pluginupdate that this PR is based on, thanks!

MediaMoots avatar Apr 22 '22 11:04 MediaMoots

@MediaMoots But I am using the latest version of the plugin v1.34.

ghost avatar Apr 22 '22 11:04 ghost

@stillnewtoblender Ah, but the blender plugin has updates too, so please update the blender plugin also.

MediaMoots avatar Apr 22 '22 12:04 MediaMoots

@MediaMoots I did.

ghost avatar Apr 22 '22 12:04 ghost

@MediaMoots I did.

Yep, sorry, i made a mistake and forgot to fix another part of the code, i just pushed a new change, please try it out. :)

MediaMoots avatar Apr 23 '22 15:04 MediaMoots

Thats so weird, I just tested it with Chika and the siroR only affects the right side

I don't know what happened, but the eyewhites are working for me now so I removed the part in the script that fixes them. Hope that didn't screw anything up. I also got rid of the scaling for the eye textures in the blend file so the json could set them. Thanks for these extra updates!

FlailingFog avatar Apr 23 '22 19:04 FlailingFog

I don't know what happened, but the eyewhites are working for me now

Oh, that's good to hear, glad it worked.

Hope that didn't screw anything up.

hope not haha.

I also got rid of the scaling for the eye textures in the blend file so the json could set them.

Cool! I also found a way to export all the UVs so that will come in handy...

Thanks for these extra updates!

No prob :)

MediaMoots avatar Apr 24 '22 08:04 MediaMoots

Cool the exported UVs work well image This looks perfect image

https://github.com/JIexan/Koikatu-shaders-source/blob/master/main_skin.shader Line 491

MediaMoots avatar Apr 24 '22 09:04 MediaMoots

V1.35

Bugfixes and Multiple uv map export support.

I didn't change anything in the blend file, but tested the UVs and they worked well.

MediaMoots avatar Apr 24 '22 09:04 MediaMoots

@MediaMoots I am trying the latest branch (Blender plugin + exporter) but when I import KK shader and textures it gives:

Traceback (most recent call last):
  File "KK-Blender-Shader-Pack-pluginupdate\importing\importeverything.py", line 879, in execute
    template_error = get_templates_and_apply(directory, use_fake_user)
  File "KK-Blender-Shader-Pack-pluginupdate\importing\importeverything.py", line 199, in get_templates_and_apply
    tears = bpy.data.objects['Tears']
KeyError: 'bpy_prop_collection[key]: key "Tears" not found'

I can see the cf_m_namida material though:

image

I tried it a second time, the error became:

Traceback (most recent call last):
  File "KK-Blender-Shader-Pack-pluginupdate\importing\importeverything.py", line 879, in execute
    template_error = get_templates_and_apply(directory, use_fake_user)
  File "KK-Blender-Shader-Pack-pluginupdate\importing\importeverything.py", line 156, in get_templates_and_apply
    body.material_slots['Template General'].material = tongueTemplate
KeyError: 'bpy_prop_collection[key]: key "Template General" not found'

Any ideas what is going on? I am on Blender 3.0. Thanks!

**Edit: ** It seems like if I disable "Save partial shape keys", this error does not occur. Weird!

TigerHix avatar Apr 27 '22 22:04 TigerHix

@TigerHix Could I have the card you're getting this on?

FlailingFog avatar May 05 '22 23:05 FlailingFog

@FlailingFog https://github.com/FlailingFog/KK-Blender-Porter-Pack/issues/151

The card is attached in this issue. Thanks!

TigerHix avatar May 05 '22 23:05 TigerHix

@TigerHix This seems to work on blender 3.1 image

FlailingFog avatar May 05 '22 23:05 FlailingFog

@TigerHix This seems to work on blender 3.1 image

Is "Save partial shape keys" enabled for you? Indeed it worked the second time for me after I disabled "Save partial shape keys", but maybe that wasn't the root cause. 😮

TigerHix avatar May 05 '22 23:05 TigerHix

Oh my bad, I see it with that option. I'll add an exception for it

FlailingFog avatar May 06 '22 01:05 FlailingFog