FlailingFog / KK-Blender-Porter-Pack

Plugin pack for exporting Koikatsu characters to Blender.
310 stars 29 forks source link

KKBP Exporter and Plugin Updates #138

Closed MediaMoots closed 1 year ago

MediaMoots commented 2 years ago

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 commented 2 years ago

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

MediaMoots commented 2 years ago

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

it uses the same material as the teeth. image

FlailingFog commented 2 years ago

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.

MediaMoots commented 2 years ago

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 eyesiroR.sR00 and eyesiroL.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.

FlailingFog commented 2 years ago

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.

MediaMoots commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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.

TigerHix commented 2 years ago

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?

MediaMoots commented 2 years ago

@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 commented 2 years ago

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

ghost commented 2 years ago

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
MediaMoots commented 2 years ago

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?

ghost commented 2 years ago

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
MediaMoots commented 2 years ago

@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!

ghost commented 2 years ago

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

MediaMoots commented 2 years ago

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

ghost commented 2 years ago

@MediaMoots I did.

MediaMoots commented 2 years ago

@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. :)

FlailingFog commented 2 years ago

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!

MediaMoots commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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.

TigerHix commented 2 years ago

@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!

FlailingFog commented 2 years ago

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

TigerHix commented 2 years ago

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

The card is attached in this issue. Thanks!

FlailingFog commented 2 years ago

@TigerHix This seems to work on blender 3.1 image

TigerHix commented 2 years ago

@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. 😮

FlailingFog commented 2 years ago

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

MediaMoots commented 2 years ago

V1.36 Export Converted Normals

Now the plugin will export Normals that have been converted for use in Unity and UE4 and I guess blender too, but I haven't tested it. The unconverted Normals are still exported alongside the new ones.

image

MediaMoots commented 2 years ago

V1.37

KKBP Exporter Updates: Export ramp textures Export all values that materials with ShaderForge shaders have, to KK_MaterialData.json This means that the values in KK_TextureData.json are now deprecated but they are still being used in KKBP The exported model now has a dedicated Kage material slot that can be used.

KKBP Updates: image This can separate each object based on KK_SMRData.json renderers. It finds the Clothes object then separates the meshes from there.

Before: image

After: image image I moved the objects for a demo.

MediaMoots commented 2 years ago

@FlailingFog Do you think it would be possible to add a third mode for finallizing armatures?

This mode would leave a completely untouched rig without deletions or renames. However, this mode will still need to delete any bones on the same level as BodyTop for example like this bone. image o_head_ribbonB.001

But any bones under BodyTop will be kept, is this possible? Maybe make the Use modified armature setting a slider with 3 modes?

Thanks!

FlailingFog commented 2 years ago

You just made a very interesting change. The materialdata json includes the shader name, meaning the blender plugin can now pick out what materials use the "main_hair" / "_main_hair_front" shaders and skip the part where you have to separate the hair. I'm pretty sure the entire import process could be automated now. The current way is useful because you can separate and categorize objects, but if the user didn't want to do that, maybe they could use a new "express" button that just goes through all the steps automatically.

Is there a use for the Kage slot? It looks like it's sharing the same mesh as the eyeline up material. That third armature mode can be added, but I don't know if sliders are a thing. I can add it through a menu like the one on the 2b button.

MediaMoots commented 2 years ago

The materialdata json includes the shader name, meaning the blender plugin can now pick out what materials use the "main_hair" / "_main_hair_front" shaders and skip the part where you have to separate the hair

O_O Thats true... good catch : )

The current way is useful because you can separate and categorize objects, but if the user didn't want to do that, maybe they could use a new "express" button that just goes through all the steps automatically.

That would be quite helpful.

Is there a use for the Kage slot? It looks like it's sharing the same mesh as the eyeline up material.

In KK kage uses the same Shader as cf_m_eyeline_down and cf_m_eyeline_00_up the toon_eyew_lod0 shader, but in KKBP these shaders have been merged into 1, so the kage slot is just there for completeness. I think it can be dealt with the same as cf_m_eyeline_down.

MediaMoots commented 2 years ago

I should also explain how the values are stored in the materialdata json

This is just pseudocode and won't work, but it shows how data is stored.

// Parse Prop PropName elements
var ShaderPropName =  MaterialDataJson[i].ShaderPropNames[j];
string[] ParsedPropName = ShaderPropName.Split(" ")

// First index of parsed ShaderPropName is the shader value name
string PrpName = ParsedPropName[0];
// Second index of parsed ShaderPropName is the shader value type
string PrpType = ParsedPropName[1];
// Third index of parsed ShaderPropName is the index of the value in the corresponding array of values
int PrpIndex = ParsedPropName[2].ToInt();

if (PrpType == "Texture")
{
    // Get and format TextureName
    FString TextureName = MaterialDataJson[i].ShaderPropTextures[PrpIndex];
}

if (PrpType == "Texture_ST")
{
    // This Vector4 is stored as Offset_Scale (X = Offset.X, Y = Offset.Y, Z = Scale.X, W = Scale.Y)
    MaterialDataJson[i].ShaderPropTextureValues[PrpIndex];
}

if (PrpType == "Color")
{
    // Color Vec4
    MaterialDataJson[i].ShaderPropColorValues[PrpIndex]
}

if (PrpType == "Float")
{
    // Float value
    MaterialDataJson[i].ShaderPropFloatValues[PrpIndex]
}

I had to do it like this because unity's json serializer is limited.

MediaMoots commented 2 years ago

Oh, just had an idea, what if there was a ui that showed each step of the finalize process eg, shapekeys, hair, armature etc, and the user can selectively choose which steps they want, maybe as checkboxes or something. This is getting complicated, lol.

FlailingFog commented 2 years ago

So what do you think of this: image

Then, if you want to separate objects you could use a "Pause to categorize" option that would operate close to the way it does currently: image

And if you wanted to add the options you're talking about you could add it under the toggle area where the "Keep material templates" and stuff are. Certain steps depend on previous steps though, so I don't know how fine you could get with what you can select.

It's only the UI files but here it is if you want to look at it KK-Blender-Porter-Pack-1.zip

I should also explain how the values are stored in the materialdata json

Thanks for the info

MediaMoots commented 1 year ago

Yup, that looks good to me!

MediaMoots commented 1 year ago

V1.40

Added an option to export all variations of the current outfit. image

The resulting meshes can be separated with the tools in the extras section. image

MediaMoots commented 1 year ago

The Separate mesh tool will now be able to work before or after the template materials have been set. If used before creating the materials, it will also separate the eye objs from the body, this is to be able to export and use them in other software.

But when the tool is run after materials have been replaced, it will skip the body and only separate clothes.

MediaMoots commented 1 year ago

V1.41

Added an option to export the hit boxes, the meshes are prefixed with o_hit* image

But if Fix body seams is enabled when finalizing pmx, it will delete all body meshes, so for now if you export with hitboxes be sure to not enable that option.

MediaMoots commented 1 year ago

V1.42

Fixed #159 Plugin now exports more information from the character like clothes data and bones.

FlailingFog commented 1 year ago

Plugin now exports more information from the character like clothes data and bones.

Awesome! Having clothing variations is a nice feature. I'm assuming the _a object is the main object, and the _b and _c ones are the half on / half off ones? Is there a way to correlate the name of the object to the name of the material it uses? These alternate pieces could be separated automatically in blender, but the material's instance tag doesn't match with the object's instance tag, so I wouldn't know which to keep and which to hide by default.

I was also wondering, is it possible to export the alternate eye patterns like these? image

Do you think it would be possible to add a third mode for finallizing armatures? This mode would leave a completely untouched rig without deletions or renames. However, this mode will still need to delete any bones on the same level as BodyTop for example like this bone.

You'll get this if you switch the option on the top left to "PMX armature". Let me know if that's what you were looking for or not. image

Added an option to export the hit boxes, the meshes are prefixed with o_hit*

These are placed in their own collection labeled "Hitbox Collection"

The Separate mesh tool will now be able to work before or after the template materials have been set. If used before creating the materials, it will also separate the eye objs from the body, this is to be able to export and use them in other software.

For the case where you separate the eye objects, do you need the blender plugin to be able to apply the template materials after that, or do you intend for that feature to only be for exporting the meshes?

MediaMoots commented 1 year ago

These alternate pieces could be separated automatically in blender, but the material's instance tag doesn't match with the object's instance tag, so I wouldn't know which to keep and which to hide by default.

The clothes data stores the SMR name, and to get the material name you can cross reference it in the SMR data file. If you are familiar with C#, you could take a look at these functions in ChaControl.cs:

public IEnumerator ChangeClothesAsync()
public IEnumerator ChangeClothesTopAsync()

But simply put, KK stores clothing data in a ChaClothesComponent for each piece. CusClothesCmp stores the main pieces in the following order:

        enum ClothesKind
    {
        top,
        bot,
        bra,
        shorts,
        gloves,
        panst,
        socks,
        shoes_inner,
        shoes_outer
    }

CusClothesSubCmp are the parts of the top clothing, in this order:

    enum ClothesSubKind
    {
        partsA,
        partsB,
        partsC
    }

I was also wondering, is it possible to export the alternate eye patterns like these?

Yup.

You'll get this if you switch the option on the top left to "PMX armature". Let me know if that's what you were looking for or not.

I can't test it right now, but from the looks of it, it's perfect, thanks!

These are placed in their own collection labeled "Hitbox Collection"

Noice

For the case where you separate the eye objects, do you need the blender plugin to be able to apply the template materials after that, or do you intend for that feature to only be for exporting the meshes?

I only intended to export the meshes in my workflow, but I guess the templates could be applied? Either way is fine by me.

FlailingFog commented 1 year ago

Oops, I didn't even think to check that third file. Thanks.

I only intended to export the meshes in my workflow, but I guess the templates could be applied? Either way is fine by me.

I'll keep it as is then

MediaMoots commented 1 year ago

V2.00

KKS Support :)

6il4j4

The Plugin in "net3.5" is for KK The Plugin in "net4.6" is for KKS

Issues: The shader names when exported from KKS are different, so for now the import pipeline will not work. Users will need to manually change the pose into T-Pose when using KKS

FlailingFog commented 1 year ago

KKS Support :) The shader names when exported from KKS are different, so for now the import pipeline will not work.

Cool! I added the shader names, so it should work now.

Alternate clothing states are also separated by default and placed under the armature as a hidden object. image

MediaMoots commented 1 year ago

image image

Added these 2 options

Shapekeys options and Pause after finalizing pmx

Hope that's ok?

MediaMoots commented 1 year ago

V2.02

Fixed some bugs and changed scale