1. Welcome to VRCat! Please note that this message board is not related to VRChat in any official manner. It is run entirely by the community, and moderated by the community. Any content present has not been reviewed by VRChat moderators or staff. Your use of these forums implies understanding of this message. Thanks!
    Dismiss Notice

How can i use UV/Material morphs (blendshapes/ shape keys) in blender/unity

Discussion in 'General' started by Keii, Jan 20, 2018.

  1. Keii

    Keii Member

    Joined:
    Jan 13, 2018
    Messages:
    20
    Likes Received:
    0
    VRChat:
    -
    I'd prefer to use them in unity directly if possible for animation.
     
  2. Lhun

    Lhun Member

    Joined:
    Jan 21, 2018
    Messages:
    113
    Likes Received:
    49
    VRChat:
    Lhun
    you can, it's not hard at all.
    Duplicate your avatar in the scene with ctrl+d. Click your original and click the "disabled" button on the top level so you don't accidentally do things to the good working one.

    Make sure there's no avatarcontrollertemplate on your duplicate.
    Click on the animation tab at the bottom, then click create new animation, name it.
    Click the record key, and go to your character blendshapes and make changes, it'll automatically create items on your timeline.
     
  3. Keii

    Keii Member

    Joined:
    Jan 13, 2018
    Messages:
    20
    Likes Received:
    0
    VRChat:
    -
    I did not meant it that way, i know how to animate blendshapes in unity. But especially UV and Material blendshapes (morphs/shape-keys) dont show up where the normal Vertex blendshapes show up.

    Here's a screen of the morphs i mean listed in Pmx editor/viewer.



    the morphs with the V are Vertex, UV(obviously) UV, M - Material morphs

    The normal morphs (Vertex) show in unity under skinned mesh render but the UV/Material morphs are not there.
    So my question was where i find those UV/Material morphs to animate them
     
  4. Lhun

    Lhun Member

    Joined:
    Jan 21, 2018
    Messages:
    113
    Likes Received:
    49
    VRChat:
    Lhun
    Unity BlendShapes does support vertex level animation on vertices, normals and tangents - All meshes imported with BlendShapes will use SkinnedMeshRenderer (if it has skin or not), but you need to:

    1) Set Normals import mode to Calculate, this way same logic will be used for calculating normals on a mesh and BlendShapes.
    2) Export smoothing groups information to the source file. This way, Unity will calculate normals from smoothing groups for mesh and BlendShapes.

    If you want tangents on your BlendShapes then set Tangents import mode to Calculate.

    The other thing you might need to do is click "optimize game objects" on your avatar controller and add the whole avatar potentially. This should add some of the ones you're missing, like bodysize and whatnot. You need to experiment a bit but I can tell you mmd4mech does it where cats doesn't always.
     
    #4 Lhun, Jan 23, 2018
    Last edited: Jan 23, 2018
    Keii likes this.
  5. Keii

    Keii Member

    Joined:
    Jan 13, 2018
    Messages:
    20
    Likes Received:
    0
    VRChat:
    -
    How do i do the second thing ? (2)
     
  6. Lhun

    Lhun Member

    Joined:
    Jan 21, 2018
    Messages:
    113
    Likes Received:
    49
    VRChat:
    Lhun
    Keii likes this.
  7. Keii

    Keii Member

    Joined:
    Jan 13, 2018
    Messages:
    20
    Likes Received:
    0
    VRChat:
    -
  8. Keii

    Keii Member

    Joined:
    Jan 13, 2018
    Messages:
    20
    Likes Received:
    0
    VRChat:
    -
    I did everything as you said and also tried out the non' blender tutorial version but in the end im still missing the UV morphs under SkinnedMehsRender, the last thing probably is to create a Vmd animation in MMD and try to export it into Unity, what do you think?
     
  9. Lhun

    Lhun Member

    Joined:
    Jan 21, 2018
    Messages:
    113
    Likes Received:
    49
    VRChat:
    Lhun
    You are using the material (what a UV is in unity) offset location as a legacy animation in the timeline correct? Just for example, you can also use UV animation inside shader, which is how NoeNoe's shaders work (you can find on this forum).

    I didn't realize exactly what you were asking, I thought you were asking more like in a mechanim way. If I understand you correctly, All you need to do is make an animation of the "Offset" of the material itself, or change the uv set if it has one - Check it out, I made you a quick screenshot.

    https://i.imgur.com/dAYm3je.png
     
  10. Keii

    Keii Member

    Joined:
    Jan 13, 2018
    Messages:
    20
    Likes Received:
    0
    VRChat:
    -
    I am trying to override animations via blendshapes thats it, and all i've been trying to do is create animations with the UV Morphs ( blendshapes/shape-keys) in the Animator like with every other blendshape.
    The problem is that the UV morphs also change texture. One UV morph i have changes the color of the eyes and i just dont know how to animate it if its not under Skinned mesh render.
     
  11. Lhun

    Lhun Member

    Joined:
    Jan 21, 2018
    Messages:
    113
    Likes Received:
    49
    VRChat:
    Lhun
    So did you try what I just said? Change the offset of the texture or choose uv1 in the drop-down and see what happens to your character. Or, host the file somewhere and I'll try to do it and make a step by step. I'm sure the solution is modifying the slider or offset on the material inspector.
     
  12. Lhun

    Lhun Member

    Joined:
    Jan 21, 2018
    Messages:
    113
    Likes Received:
    49
    VRChat:
    Lhun
    An animation is just changing the property of something over x frames. You can transform bones or a move a blendshape value ORRR a material offset (rotation) or even a material uv set if it has alternates ones which I suspect this is.
     
  13. Keii

    Keii Member

    Joined:
    Jan 13, 2018
    Messages:
    20
    Likes Received:
    0
    VRChat:
    -
    Well i can only change the offset of the texture, for the morph with changing eye color(s) changing the offset would not just change the eyes but the whole face so everything is messed up.

    If i choose UV1/0 on some textures nothing happens to my model atleast i cant tell the difference ( the face texture has no UV-sets)
     
  14. Lhun

    Lhun Member

    Joined:
    Jan 21, 2018
    Messages:
    113
    Likes Received:
    49
    VRChat:
    Lhun
    You may want to try my tutorial and try doing a splitmesh without merge - a full splitmesh with xdef extra. It's possible material merging killed them
     
  15. Keii

    Keii Member

    Joined:
    Jan 13, 2018
    Messages:
    20
    Likes Received:
    0
    VRChat:
    -
    Actually i tried your tutorial and added to that im not even doing anything to the model anymore to test this, i import the pmx into blender and instantly export to fbx without doing anything to it, with that fbx i tested everything you told me.
     
  16. Lhun

    Lhun Member

    Joined:
    Jan 21, 2018
    Messages:
    113
    Likes Received:
    49
    VRChat:
    Lhun
    Also it's possible you normally have several face materials and some are meant to be transparent. This is bad for vr chat of course, as few materials as possible. It might just be a matter of selecting the right one, the cats plugin is good for optimization but not so good for mmd stuff. You can try importing a vhd that does have that blend animation and watch how mmd4mech does the transform/blend and copy it.

    My normal tutorial merges meshes but usually leaves materials- try instead doing a full split without combine and try fbx texture as an option too. You may have to play with it.

    With the default settings mmd4mech is a nearly complete solution with a generic rig, all facials animate.
     
  17. Keii

    Keii Member

    Joined:
    Jan 13, 2018
    Messages:
    20
    Likes Received:
    0
    VRChat:
    -
    I would try to animate it in mmd export the animation file to blender and bake it in the fbx added to your suggestion.

    also, Did you also work with UV morphs from mmd models in unity? Just wondering why it is so hard for me to animate a UV changing blendshape in Unity.
     
  18. Lhun

    Lhun Member

    Joined:
    Jan 21, 2018
    Messages:
    113
    Likes Received:
    49
    VRChat:
    Lhun
    I have, often the issue is that one of the facial materials is meant to be set to fade or have an albido or specular texture. See if you can get it to work with mmd4mechs native shaders
     
  19. Keii

    Keii Member

    Joined:
    Jan 13, 2018
    Messages:
    20
    Likes Received:
    0
    VRChat:
    -
    I'll also private message you a link with the original file from the creator if you want to try it out yourself.
     
  20. Keii

    Keii Member

    Joined:
    Jan 13, 2018
    Messages:
    20
    Likes Received:
    0
    VRChat:
    -
    okay, i tried importing a mmd created animation/motion file (vmd) which had the UV morphs animated. This doesnt work. normal motion files work but when im animating the UV morph in mmd it just does nothing in blender.

    Now when i tried importing the vmd file together with the model via MMD4Mec. I just get a white/grey model without textures so i can't look if it works.

    I think it messed up the texture assigning