WolvenKit / Cyberpunk-Blender-add-on

The Cyberpunk add-on for Blender bridges complex game assets with Blender.
82 stars 20 forks source link

Feature suggestion: "Import Noesis FBX" #66

Closed manavortex closed 11 months ago

manavortex commented 11 months ago

The plugin could have a custom option for Noesis FBX files that will rotate the armature and rename the submeshes so that it's glb-ready..

Here's the code snippet from my dirty repo that pretty much has all the logic (although for export):

    rotation = armature.rotation_quaternion
    if (isNoesisExport):
        armature.rotation_quaternion.w = 0.0
        armature.rotation_quaternion.z = -1.0
    else:
        armature.rotation_quaternion.w = 1.0
        armature.rotation_quaternion.z = 0.0   

    # rename submeshes
    try:         
        meshNumberMatch = re.search('[0-9]+', mesh.name).group()
        print(meshNumberMatch)
        if (isNoesisExport):
            mesh.name = "submesh{}".format(re.sub('^0', '', str(meshNumberMatch)))
        else:
            mesh.name = "submesh_{}_LOD_1".format(meshNumberMatch.zfill(2)) # prefix with leading zero
    except:
        print("couldn't find a numeric index for {}".format(mesh.name))
Simarilius-uk commented 11 months ago

would need to be Noesis FBX (no mats). Be more inclined to just add a 'fix Noesis import' button to the mesh panel (didnt DrP already put in a rotate armature button?).

manavortex commented 11 months ago

I'm thinking from an UX perspective here - IMO, a menu entry would be way clearer than a button. Can see people spamming "fix armature rotation" whenever they run into a Wolvenkit import error and then complaining when it doesn't work 😅

Besides, you'd only need this once, on import... or wouldn't you?

Simarilius-uk commented 11 months ago

mainly just dont want to deal with people asking why their fbx doesnt have materials

manavortex commented 11 months ago

if the fbx is a REDmod export from Wolvenkit, then it should have materials (@DoctorPresto would know). Otherwise, how about a big-ass popup or... a plane with "Noesis export, no materials generated" projected on it? :D

Simarilius-uk commented 11 months ago

No, it wont, as the redmod materials json isnt the same format as the wkit one, and the only reason glb has materials is we process the wkit json.

manavortex commented 11 months ago

Ah, damn, we need to parse that file into a regular json, don't we -.-

https://github.com/WolvenKit/WolvenKit/issues/1423

DoctorPresto commented 11 months ago

I'm not opposed to adding another toggle to the existing fbx importer, the button that will do this though is pretty clear that it's not a fix, it says "Rotate Object" currently in my dev build. As for the mats... Redmod material.xml basically just points to a couple xbm files, I'm really not sure how useful it would even be as it feels very much like it's something just leftover from witcher 3 modkit. We'd asked once if it was at all possible to trigger wolvenkit to generate the material .json on a redmod export but no one was really sure how much effort that would take and it's obviously not a high priority on the wkit side.

manavortex commented 11 months ago

Probably not, but maybe somebody is bored enough? :D

DoctorPresto commented 11 months ago

😅 I'm going to start putting actual effort into c# again while I'm off in December

kmirea commented 11 months ago

mainly just dont want to deal with people asking why their fbx doesnt have materials

heya. just wondering, is this due to the export with materials / export with rig, are seperate methods, and dont have a combiined one, or iis something else noesis related ? I could possibly offer insight. i wrote a fullon cr2w in noesis at one point, parsing anim buffers and all, the nutter thaat i am, will try dig it up and post on DC.. Just on a sidenote, does the Noesis export rig, if not can do Obj + textures, and spit out a generic MTL noesis is a PITA when it comes to naming and relative paths, but if u include obj/mtl and txts in same folder, or even textures in subfolder, should be good, keep everything lowercase, no dashes, or underscore, and stick to png for normals and jpg/png for other txt's. it doesnt like DDS iirc \

aside from that if i remember rightk there was an issue ewhreby the required material entries were lost or did not show us (1 entry per mesh part, defining corresppnding texture). and there was just single material entry. Againm, im foggy, but fairly sure it was some manner of limitation to how noesis would handle each thread, or import action (having only one armature and one material entry - or something). I evevntually overcame this by looping the whole import method, for eachc seperate submesh, thus giving it its own mat, but with any complex characters or vechiles it would throw a shitfit, and cause cpu/mem spikes. i had reported the issue to Rich back in the day, but lets just say it did not even make the bottom of his todo listl]]

I was then and still am a noon that was just winging it mostly, and was building ontop of AlphaZomegas original script. Will post my last version, but it was pre 1.1 and would need some work. AlphaZomega if still around is the true Noesis Savant. shold definately hit him up, he would probably know exactly whaty causing the textures issue.

kmirea commented 11 months ago

also need to give each meshpart a unique namel, short as possible. lowercase. another option, how easy idk, but if u use blenders combine/group meshes into single mesh (can always undo it later) and bake textures to single diffuse (noesis cant handle fancy shaders or complex mats) then that might just solve issues,

kmirea commented 11 months ago

Probably not worth digging through these, but oneo f these builds you will find a FacialSetup.cs or Facial.cs or FacialAnims,cs, in the folder containing the other mesh/mat/anim parsers u will find the export mesh_with_rig_with_materials method, nothing fancy just combined the 2 seperate methods and added in some entries iinto gltf ewxtra data, namely, the material names per mesh part, / submesh, and original location of cr2w, and each parts index, and so on. essentially similar tocode above, but just super useful whebn adding a line to gltf inmporter to blender, renaming the meshparts on import to tjueior actual definitions (body parts, or vehicle parts), and then restoring names on export.. would ust need to convert camelcase names to LC for noesis.

https://mega.nz/folder/W5RiXYpa#5dA1J_ME0JjGnxbPuQmB7w

DoctorPresto commented 11 months ago

the noesis issue is just FBX orientation which we have a button to fix already + the naming of submeshes which I've added a bundled script to the plugin script manager to deal with, I'm not sure we want to go much further down the road of support beyond that