veryfancypants / hs2_blender_export

35 stars 4 forks source link

How does it work, I can't see the video #1

Open Uqbc9 opened 2 years ago

ViraAngel commented 1 year ago

Someone purged the videos or is gatekeeping information! I shall enlighten you with the video I found. https://vimeo.com/780198400

But even so, the code in this video does not match the current 2021 upload. So when I run the script, it displays an error, and not all textures get setup; or in different models, the body is deformed.

Look at the code change on October 16, 2021: https://github.com/veryfancypants/hs2_blender_export/commit/d44833949a5875e23c2f10dfdff5149cdf809d99#diff-de792ac8f74de70d362f452d6c8d082c2cb344961fed11c3f6020f50b35708a8

Line 34 in the old code (red) says: dump='c:[\\temp\\dump.txt](file:////dump.txt)' But in the new code (green), it is line 36 and says: dumpfilename='c:\\temp\\dump.txt'

So “dump” was changed to “dumpfilename.” We can use this as a version identifier. But if we download the “current” version with the Blender files, open it, go to line 34/36, we see that it says “dump” not “dumpfile.” This proves that the newer Blender file has not been updated with the newer code change. But it also does not work with the old code (of meshexporter.py). Something in the Blender file mismatches, and I get errors.

For even so, if I manually copy the new code of meshexporter.py into the Blender Script tab, I get an error when running it. What is this chaos?

The video (older version) also does not show how to use the UI. But a new video has not been shown.

We summon @veryfancypants @veryfancy @Lzzdyyy @youtoo123 to assist us in these dark times. You can upload a new video on www.vimeo.com which allows nudity (if that was the reason Youtube took down the prior video).

Help us get this script to work for HS2 BR8. I get mismatch errors and:

  1. = bpy_prop_collection[index]: index 0 out of range, size 0
  2. Warning: 'hs2rigmain' does not contain ' PT_' with prefix and suffix || FBX version: 7400
  3. b'LayerElementColor' '' missing data
  4. ERROR: failed to find texture head BumpMap2_converted
  5. File "C:\temp\hs2_blender_export-main\prefab_materials_meshexporter.blend\meshexporter.py", line 292, in load_textures || IndexError: bpy_prop_collection[index]: index 0 out of range, size 0
  6. KeyError: 'bpy_prop_collection[key]: key "o_body_cf.045" not found' || Error: Python script failed, check the message in the system console
ViraAngel commented 1 year ago

We summon @IllusionMods @ManlyMarco

How do we get this Export-Material fixer to work in 2022 with HS2 BR8 models, to setup the FBX file in Blender 3.0, 3+? Was this mod made it only work in ancient versions of Blender? Help us please in these dark days.

veryfancypants commented 1 year ago

I am downloading the latest torrent (BR11) and I will update the scripts to work with it. It will take a while though (probably won't happen for at least two weeks).

ViraAngel commented 1 year ago

@veryfancypants Thank you for returning, and for saying you'll update.

  1. Can you confirm if you/who made a mistake in the lastest upload (2021), regarding the Blender file we got and its Meshes, did not match the script in use?
  2. Can you PLEASE also make a version that works with BR8 (if it works for BR11 and 8 that's fine). But my model/install is with BR8, and I heard that some mods stopped working. I don't want to risk installing 11 yet.
  3. So if you can please do #2, I will donate to you on gumroad.com. Can you please make one or any donation site that accepts Credit card payment (preferably not Paypal). Thanks for your time :)
veryfancypants commented 1 year ago

I thought it was working correctly, but I may have messed it up somehow. I found the BR8 torrent, going to download it and try it first. Any specific models you'd like me to test?

ViraAngel commented 1 year ago

Thank you. Can you clarify which setting counts as a model in HS2 (you mean a setting that changes the body weights correct)? Please test what I am using:

  1. BR8, and whichever slider mod it had installed. (I believe it is not vanilla because I can scale sliders higher. But I don't know the exact name, if you can direct me where to look in my BR8 settings.)
  2. Face: Contour = Type 02; Skin = 02; Wrinkles = none.
  3. Body: Overall: Height = 55, Head = 70; Uncensor Female BP4 Meaty 1; (But Material Editor > Skin Shader = Hanmen/Next-Gen Body, and Head Shader = Hanmen/Next-Gen Face, not sure if that changes bod/head weights besides the settings below?)
  4. Body Skin Type: [hooh] Pogskin Active; Build = [nyaacho] detail 05.
  5. Accessories: I have 24 and some slots are Skipped as empty, e.g. Slot 10 used, 11 empty, 12 used. Does the old file have an accessory limit or get confused about skipped empty slots? I got one error: _"File "C:\temp\hs2_blender_export-main\prefab_materials_meshexporter.blend\meshexporter.py", line 292, in load_textures || IndexError: bpy_propcollection[index]: index 0 out of range, size 0" Thank you :)
ViraAngel commented 1 year ago

RE Body: Uncensor Female BP4 Meaty 1

FYI, I just noticed that if I set my model to use the custom pussy (not use Default), (and then export), that merely changing the pussy adds extra bones (vagina) and toe bones. So maybe that is one reason why your Blender body meshes/rig didn't match (if your rig didn't have the extra vagina and toe bones)? Hope it helps.

veryfancypants commented 1 year ago

By 'model' I mean one of the included characters, but I'll try to build one as you describe.

In the mean time, I've pushed an updated blend file, it's work in progress but see if it works for you any better. I've decided that asking users to edit the Python script is too problematic, so there are UI controls instead. (For now, ignore the "presets" controls, they aren't fully hooked up.)

Updated procedure: Export textures+fbx with MeshExporter and make a unity dump. Supposing that the export is in c:\temp\HS2\export\BR-Chan, it should be arranged like so: c:\temp\HS2\export\BR-Chan\ . BR-Chan.fbx . unity_dump.txt (can be named anything you want, as long as it's a .txt) . Textures\ .. cf_m_skin_body_00_MainTex.png .. ... (lots more png's)

Put "c:\temp\HS2\export\BR-Chan" in "Char directory:" Hit "Import model"

One thing I've noticed is that getting the correct Unity dump may be difficult, because there are many different "cf_J_Root" nodes in the scene, and only one of them is "correct". If you dump the wrong one, the armature won't work correctly. As an alternative, you can dump the "CommonSpace" node instead, there should be only one of those. You can tell that you have the correct dump if, after import, shoulder/elbow/wrist bones start inside the body.

ViraAngel commented 1 year ago

Wow beautiful! I have never seen a working Blender file except in the Cira 2021 video. Thank you so much for continuing your work on this.

What is your Gumroad so I can donate? :)

FYI everyone: Troubleshooting:

  1. Studio > Grey's > Export model, you must check “Create generic shader/materials” or your script fails. i. Attempt to convert Grayscale ii. Save both original and converted iii. Create generic shader/materials
  2. This "cf_J_Root" under "CommonSpace" worked for me. ME-2022 step 1

{My notes/questions to you are in these brackets.} {To make problems easier to recreate for you, I Exported the vanilla Hayashi model so we have the same settings (but also my character worked/errored in the same ways below:}

Pending Issues:

  1. After “Import model” the Head texture does not complete, it is gray.

  2. Body main texture did not seem to load at all, it is a generic skin color without the details of the skin texture, e.g. no freckles, spots.

  3. Body texture has nail texture, but no Nipple texture/color (generic skin color).

  4. Eyes: I don't know how to setup the texture layers in Blender, but the Iris color is being blocked by another eye mesh, that isn't set to transparent or alpha/Mask is wrong.

  5. Eyebrows: the alpha is not showing correct to “Mask” and only display the lash pixels. Instead it shows the full eyebrow mesh as a color. ME-2022 eyeball mesh not masked

  6. Clothes: the alpha is not showing correct to “Mask” and only display the correct parts. ME-2022 Alpha Masks not correct

  7. The accessories are not positioned to the correct bones. They are on the floor (0, 0, 0). A. {If you import the FBX character in Blender using Better FBX plugin, then this mod puts the accessories on the correct bones. But Better FBX loads bone orientation differently than your file. Thus I am unsure which mod to use first.}

Questions:

  1. I found cf_J_ArmElboura_dam_L (not weighted), which is the controller bone for cf_J_ArmElboura_s_L (weighted). Why does HS2 use 2 bones to do the job when one bone could be moved (with the weights)?

  2. I see you have the joint corrections working for the elbow/arm bend (extra Weight paints). I see the Copy Rotation. Did your script/the dump file set those up? It was my understanding that FBX files cannot save Bone Contraints (the Grey's export), and must be baked into animations as FBX files (if we want to export anims out of Blender)?

  3. Do you want me to start specific Issue threads for specific issues? Thank you so much :)

veryfancypants commented 1 year ago
ViraAngel commented 1 year ago

Thanks for giving reply updates :) How can I donate to you?

Does it matter which Blender version we use for your file? I'm in 3.0. Here are files (dump, text, Fbx, + Character cards) for 2 characters:

  1. Vanilla Hayashi_Ayaka (as control for your testing, but I don't need her) https://we.tl/t-vxWEIMbdEX
  2. And modded BR chan, with Hanmen skin (which I need to use the skin) https://we.tl/t-oplE1xeN8N
    • And I added a sample bracelet to #2 if you want to add the script for putting accessories on the correct bones (I have 20 on another character). Or if the dump file doesn't have that bone info, if you can add a fill in the box script that performs the Blender function (below), and it Parents the selected mesh on the correct bone?
    • Object mode > select Accessory mesh > Object Properties > expand RELATIONS > Parent = Armature, Type Bone, Parent Bone = cf_J_Hand_Wrist_s_L. Tracking +Y, Up Axis Z (That's what Better FBX Import sets up automatically from reading the FBX file. But I don't understand your bone orientation, which axis to use.) Greys export settings

Thanks for doing those constraints, it is a lot. Is there a way to verify if they are correct (HS2)? I want to edit anims and have wrist twisting. Then put back into HS2.

Do you know the hierarchy bone list for HS2 rig, or know someone who does? The names are cryptic.

veryfancypants commented 1 year ago

As long as you're not getting warnings about incompatible versions, Blender version shouldn't matter. I'm using 3.3.1.

The first dump works correctly here. The script has a few difficulties with the second dump, one major problem is that it pulls in hat textures into the head material in several places. I'm going to try to figure out why it happens.

Here's what I get after manually fixing the textures and tweaking a few material settings: image

I've added some logic to place accessories in the right places (work in progress), and it adds the veins as subsurface material. The Hanmen skin shader probably has some additional tricks but I'd need to look into it to get the full effect.

I'll push the updated blend file later, after I've worked out why it loads wrong textures.

What do you mean by twist bones? You have one pose bone per joint. E.g. in the left arm, you have cf_J_Shoulder_L (breastbone to clavicle), cf_J_ArmUp00_L (clavicle to upper arm), cf_J_ArmLow01_L (elbow), and cf_J_Hand_L (wrist), each can be rotated around all three axes (which is kind of cheating, since you don't have three degrees of freedom in your real joints, but I didn't get the "correct" constraints fully worked out, and sometimes you can't get the pose you want without cheating.) There's a couple of s bones in each joint with weight paints. And there are dam bones that do joint corrections. E.g., when you twist cf_J_ArmUp00_L along its length, joint corrections rotate cf_J_ArmUp01_s_L and cf_J_ArmUp02_s_L in the opposite direction, so that you get a smooth increase in twist from shoulder to elbow.

You can see the architecture in Blender, just expand the armature in the outliner window.

ViraAngel commented 1 year ago

As long as you're not getting warnings about incompatible versions, Blender version shouldn't matter. I'm using 3.3.1.

Wow, thank you for confirming the version you use, and that statement is incorrect. I installed Blender 3.3.2 LTS (Long Term Support version, which was the closest I could find to 3.3.1). https://www.blender.org/download/lts/3-3/

And so many things were fixed:

  1. Eyes and Eyelashes
  2. Body Skin and nips (for Vanilla Hayashi and Hanmen skin BR-Chan-Mod2)
  3. Head Skin (for Vanilla Hayashi only. Hanmen Head skin failed on BR-Chan-Mod2, but worked on another Hanmen skin character)
  4. Also fixed was how the model coloring looked in Viewport shading > Material preview mode. (In Blender 3.0, I could see the blocky quad lines of the geometry, instead of it shaded smooth, as in your pictures and in my "Solid Mode" display (white shading mode). I was going to ask if your script was modifying the geometry, which made it look unsmooth. But my Blender version was wrong.) Need Blender 3 3 1 or 3 3 2 LTS version

Things that aren't fixed for me:

  1. The Alpha Mask for the swimsuit still isn't working for Vanilla Hayashi (and probably other clothes that have Masks to erase parts?)
  2. And you said you're working on the Head skin fix for BR-Chan-Mod2 (as an example of using Hanmen skins on the head).

    one major problem is that it pulls in hat textures into the head material in several places. I'm going to try to figure out why it happens.

  3. Also the skin seams are wrong for the Hanmen body skin at the shoulder seam (neck to arm), and around the arm-shoulder (where body seam joins to arm). I believe his material is a different formula than the Vanilla that your script is setup to use, and his needs a Mask or something at the seam edges, to blend together the seams?

Thanks for your work on this :) How about a https://ko-fi.com/about that I can donate to you, if you don't have Gumroad?

ViraAngel commented 1 year ago

Can you please help with an issue in the meantime? Thank you.

  1. How do I apply/finalize my Armature proportions to the Meshes that your script sets up (from the default HS2 proportions of your Mesh files, but I want your script to set the Mesh proportions to my Character)?
veryfancypants commented 1 year ago

I got Hanmen's next gen textures and managed to enable subsurface scattering effects similar to what his "next gen body/face" shaders do. It's not quite the same but it produces some interesting effects. Cycles without SSS (some manual tweaking, HairTool hair and eyebrows): face_nosss Cycles with SSS: face_sss

"How do I apply/finalize my Armature proportions to the Meshes that your script sets up"

If I understand the question correctly, unchecking "Refactor armature" will do the job.

shabadus-alt commented 1 year ago
  • Eye/hair colors are not in the dump. The dump is strictly geometry. That's one of the difficulties with doing a proper export - settings like hair colors, skin gloss levels, bump levels (athletic/skinny/etc), need to be set up manually. If you make a preset file, you can put colors for each char in there, otherwise it starts with defaults. There are also hidden settings associated with each item of clothing, which the script can't set up automatically (you can see them in Material Editor), so, even if the script correctly identifies the object as clothing, to get it to look exactly like in the game, it needs to be tweaked by hand.

Sorry for posting to an old-ish thread, but couldn't you parse the character card png for all of this info? From what I understand, all customization data is appended after the IEND block. I don't know how practical or possible it is to shift through png bytes in Blender, but it would be a pretty concise way of accessing it all without needing to dump multiple components from Unity.

CttCJim has a nifty little standalone character editor which may have some ideas on how to do it/what to look for. It's written in C#, though.

https://github.com/CttCJim/HS2CharEdit