EpicGames / MetaHuman-DNA-Calibration

https://epicgames.github.io/MetaHuman-DNA-Calibration/
Other
454 stars 120 forks source link

Some questions about script "dna_viewer_grab_changes_from_scene_and_propagate_to_dna.py"? #29

Closed 1165048017 closed 1 year ago

1165048017 commented 1 year ago

This script shows 5 steps need to be done:

  1. Start Maya
  2. open maya scene (do 2.1 or 2.2) 2.2. start DNA Viewer GUI (dna_viewer_run_in_maya.py)
  3. Run this script to the part called "load data"
  4. In the scene, make modifications to the neutral mesh and joints
  5. Run this script from the part called "propagate changes to dna" to the end

I tried this but meet some problem:

  1. The step3 will load DNA again, why I need to do step2 first? The code build_rig(dna=dna, config=config) in step3 will reload DNA and overwrite the maya scene
  2. After step3, I tried to modify the bone translation and the vertex of blendshape/head_lod0_mesh! but when I run step4:
    
    reader = load_dna_reader(CHARACTER_DNA)
    calibrated = DNACalibDNAReader(reader)

run_joints_command(reader, calibrated)

for name, item in current_vertices_positions.items(): new_vertices_positions = get_mesh_vertex_positions_from_scene(name) if new_vertices_positions: run_vertices_command( calibrated, item["positions"], new_vertices_positions, item["mesh_index"] ) save_dna(calibrated) assemble_maya_scene()


Only bone translation is wiritten into dna file, the changes of blendshape and head_lod0_mesh has been reset in maya. Also, I can't see my changes except bone translate after loading dna files into UE.
Sometimes the step4 will report an error:
`TypeError: file <maya console> line 73: MSelectionList.getDagPath() takes exactly one argument (2 given)`

Are there any video tutorials? Maybe I am not so familiar with Maya. Thank you very much for helping me.

There is a same problem in UE Forums: [Metahuman DNA Calib Library Export Import Issue](https://forums.unrealengine.com/t/metahuman-dna-calib-library-export-import-issue/765782)
djiangvfx commented 1 year ago

I just commented out the line where it says build_rig and u r good to go!

1165048017 commented 1 year ago

@djiangvfx Thank you; I did the same thing, and it worked. BTW, how do you deal with the modifications of blendshapes as descripted in Question2 ? Transfer the BS through FBX file? ^_^

djiangvfx commented 1 year ago

I do not believe blendshape is part of propagate scene changes example script as the joint command only calls for:

SetNeutralJointTranslationsCommand() SetNeutralJointRotationsCommand()

for blendshape delta, you would need to use

SetBlendShapeTargetDeltasCommand()

which is not part of the example script

djiangvfx commented 1 year ago

personally, in my pipeline, I have stored any component of the asset outside the dna for flexibility in the pipeline

dna will only hold the accurate rig logic to be used in RL node inside of maya as well as the SKM in the engine, the mesh, blendshape and skin info is seperated from the original dna

however for max portability, it will be nice to pack the entire asset inside the dna, but it is still not fully achieve as dependency such as the shader and textures, how the rig assembles, as well as any other attaching asset won't be able to packed inside the dna.

1165048017 commented 1 year ago

@djiangvfx I tried to convert dna to json and then convert it back. In json file, I saw so many informations including blendshapes. I will try to modify blendshapes in json file and then convert it to dna file to see if it can be worked in maya and UE. The shader and texture is not important for me currently, I just want to repair some blenshapes and the base mesh's vertices. Thank you, I will come back after trying this.

djiangvfx commented 1 year ago

have you tried integrate SetBlendShapeTargetDeltasCommand() into your function and did not work? I can provide an example code once I am at my workstation

1165048017 commented 1 year ago

@djiangvfx Hi, I have tried to modify the blendshapes and lod0's base mesh in my dna file. It is very strange, because the modifications seem to work in Maya, but didn't in UE. image

I just wonder if the way I import DNA to UE is wrong or the blendshapes in UE can't be overwrote?

I have supplied my metahuman mbb file which can be imported to metahuman creator website and also the original dna and modified dna! I will keep trying to make all the modifications in dna work in UE, or maybe the FBX is the only way to port the modifications into UE. https://1drv.ms/f/s!Algxor64B8ZTpg-tRv9lzb9cyauQ?e=vYglU7

djiangvfx commented 1 year ago

Sorry! I can't crack open the file right now! But on top of my head, you have to make sure the blendshape target name matches, in maya it defaults to be the expression name, but in unreal u need to tokenize the mesh name and rename each target for example:

brow_down_L head_lod0_mesh__brow_down_L

you either have to toggle "mesh name to blendshape channel name" in the extra options of the dna viewer when you build the rig

image

or on an already built metahuman asset, if nothing is renamed, you can run the following script before exporting your SKM

`lod0Blendshapes = cmds.ls("*_lod0_mesh_blendShapes")

print lod0Blendshapes

for bsNode in lod0Blendshapes:

bsNode = "cartilage_lod0_mesh_blendShapes"

bslist = cmds.listAttr(bsNode+'.weight', m=True)
print (bslist)
nodeName = bsNode.replace("blendShapes","_")
for each in bslist:
    cmds.aliasAttr (nodeName+each, bsNode+"."+each)`
1165048017 commented 1 year ago

@djiangvfx Thank you for informing me that. I just want to change my metahuman through dna file not fbx file. I don't want to export fbx file from maya , and then import this fbx and the corresponding dna file into UE. It seems like that you make your modifications work in UE by reimporting/importing both fbx and dna files? However, I tried many times and finally found that UE can only get bone modifications from DNA . Maybe as this issue descripted, if we want to import blendshape modifications, we need both fbx and dna file as well as your procedures.

djiangvfx commented 1 year ago

From my understanding importing dna into UE will only embed the rig logic onto an existing skm. Any modification to the skm component of the asset including neutral mesh, skin, bs minus rest bone position is done via stand skm workflow.

Ideally ur skm bindposition still align with the dna’s neutral bone position…

However I could be wrong. I never figured if you can import the entire skm of the head via dna file. There is a function in the dna calibration tool to export fbx files from dna which further justify my thought of needing fbx with the dna to embed the dna onto proper skm.

maybe someone from 3lateral can clarify this!

david

1165048017 commented 1 year ago

@djiangvfx Yeah. Currently, I think you are right. I have tried the scirpt to export fbx, everything goes right. But I hate fbx file as all the informations are already in dna.

Maya loads dna to an empty project everytime, so all the things including bind pose, blendshapes are both from dna. But UE has an initial skeletal mesh for metahuman, only the rig logic part can be overwrote when reimport a modified dna file, the changes related to blendshapes and mesh vertices will not overwrite the existing informations in UE.

Hope UE can make dna system more complete ^_^

1165048017 commented 1 year ago

@djiangvfx Hi, I have developed an UE5.2 plugin. With this plugin, you can transfer dna's modifications directly into metahuman in UE. As we discussed before, the dna has all the informations including basemesh/morphs/skinweights/joints, so the simplest way is to read these informations in UE and change the skeleteal mesh. I will publish it in UE Marketplace.

djiangvfx commented 1 year ago

Sounds amazing! Thank you

On Sat, Aug 12, 2023 at 9:51 AM Bingo @.***> wrote:

@djiangvfx https://github.com/djiangvfx Hi, I have developed an UE5.2 plugin. With this plugin, you can transfer dna's modifications directly into metahuman in UE. As we discussed before, the dna has all the informations including basemesh/morphs/skinweights/joints, so the simplest way is to read these informations in UE and change the skeleteal mesh. I will publish it in UE Marketplace.

— Reply to this email directly, view it on GitHub https://github.com/EpicGames/MetaHuman-DNA-Calibration/issues/29#issuecomment-1676001811, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM2PERVI7TLXQI4MBH67XQTXU6X77ANCNFSM6AAAAAA25KEGIU . You are receiving this because you were mentioned.Message ID: @.***>

1165048017 commented 1 year ago

@djiangvfx , Hi ,here is the video for preview. I will close this issue as I have solved it by developing an UE plugin.

booomji commented 1 year ago

have you tried integrate SetBlendShapeTargetDeltasCommand() into your function and did not work? I can provide an example code once I am at my workstation

Hi djiangvfx, I know I am late and this issue is resolved (1165048017 has a plugin on the marketplace now) . But please could you post an example. I am struggling with exactly this and it would be a great to see how this is done using the DNA tools .

Thank you, b

1165048017 commented 1 year ago

have you tried integrate SetBlendShapeTargetDeltasCommand() into your function and did not work? I can provide an example code once I am at my workstation

Hi djiangvfx, I know I am late and this issue is resolved (1165048017 has a plugin on the marketplace now) . But please could you post an example. I am struggling with exactly this and it would be a great to see how this is done using the DNA tools .

Thank you, b

Hi, @djiangvfx I have made a tutorial about the DNAUpdater plugin and another tool to modify dna file! you can see here for English: https://youtu.be/GPRjWz9aGsQ Here for Chinese: https://www.bilibili.com/video/BV1wu411A7J8?t=1.0

booomji commented 1 year ago

have you tried integrate SetBlendShapeTargetDeltasCommand() into your function and did not work? I can provide an example code once I am at my workstation

Hi djiangvfx, I know I am late and this issue is resolved (1165048017 has a plugin on the marketplace now) . But please could you post an example. I am struggling with exactly this and it would be a great to see how this is done using the DNA tools . Thank you, b

Hi, @djiangvfx I have made a tutorial about the DNAUpdater plugin and another tool to modify dna file! you can see here for English: https://youtu.be/GPRjWz9aGsQ Here for Chinese: https://www.bilibili.com/video/BV1wu411A7J8?t=1.0

Thank you for the English version Bingo. I just wanted to see how the SetBlendShapeTargetDeltasCommand() works in Maya . So was hoping David would post an example.

Cheers, b