Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Blend Shapes Preset Tool [Released]

Discussion in 'Assets and Asset Store' started by kalagaan, Nov 8, 2017.

  1. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    732


    BSPT generates templates of blendshapes presets that can be shared between different characters.

    You can easily create facial expressions by combining multiple blend shapes into presets. Each preset is controled by a single parameter. So it's really easy to include the API in your game script.
    You can create different templates with variations using the same expression name, so you can create differences between characters without any line of code, just by changing the template.
    Another advantage is that you don't have to deal with the original blendshapes names, you can use your own naming. If two characters don't have the same blend shapes names, you can unify them with two template files (one for each character) using the same presets names.

    Different blend modes are available :
    Blend, Min, Max, Override.

    The tool is really easy to use, you can modify the presets and see the result in the editor.






    Demo - Doc

    AssetStore links : Basic - Pro

    The pro version includes the source code.
     
    r3ndesigner and wetcircuit like this.
  2. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    732
    The version 1.0.1 has been submitted to the asset store, it should be available soon.
    The preset controller can manage additionnal renderer,
    very usefull for characters with separate meshes (eyes, mouth...)



    The additionnal renderers must have the same blendshape structure (names & order)

     
    Last edited: Nov 8, 2017
    r3ndesigner and wetcircuit like this.
  3. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    732
    The version 1.0.1 is available ;)
     
  4. sentar

    sentar

    Joined:
    Feb 27, 2017
    Posts:
    30
    Hi kalagaan,

    I have a quick question for you, Is there a limitations as to what model I can use? Does a model have to have some sort of blendshapes (already set) to use this? Could I (theoretically) grab some random free model off of the asset store and try to apply this to that model?
     
  5. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    732
    Hi,
    The model must have blendshapes, BSPT doesn't modify the mesh, it generates some preset templates of the existing blendshapes.
    This is usefull for character with complex face expressions.

    If you want to add blendshapes to a model, you can use PolyMorpher.
     
  6. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,781
    Does this tool allow for negative morphs/blend shapes?
    In 3D it is common to set a negative blend from a defined blend - to get a larger range or allow for a frown from a smile morph/blend.
    Unity does not support negative blend shapes out of the box.
     
  7. witcher101

    witcher101

    Joined:
    Sep 9, 2015
    Posts:
    434
    can this copy blendshapes to other skinrender. Like if i create a char with blendshape which makes char fat. Then i attach a skinned cloth without blendshape in it. Can this copy shape to ckinned cloth to allow cloth to fit with char as it expands in size
     
  8. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    732
    BSPT rely on the unity BlendShape API, so it doesn't allow negative weights. :(
     
    HamFar and theANMATOR2b like this.
  9. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    732
    No, you can't transfer blendShapes from a model to another one.
    You have to create the blendShapes on your cloth model.
    If the blenshapes are the same (name & order), you can use BSPT to synchronize blendshapes weights for the both models.
     
    Last edited: Nov 17, 2017
  10. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    964
    @kalagaan ,

    Do you know if Manuel bastioni characters from blender have blendshapes and whether they work with this asset... Would be a big selling point!
     
  11. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    732
    Yes, Bastioni lab exports blendshapes :)
    The BSPT demo is made with a Bastioni lab mesh, so the eye controller demo script works with any character generated by the bastioni lab.
    The facial expression system (MBL 1.6.1) is very close to BSPT, It's really cool :p
    I'm using MBL for a character and I'll include a BSPT template with it.
    you can copy (manually) each blendshape weight for each expression preset into BSPT.

    It would be really cool if I could create a blender script for exporting blendshapes into a readable format for BSPT.
    I've never worked with blender script, so I don't know if I could do this easily.
     
    Last edited: Feb 3, 2018
  12. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    964
    @kalagaan ,

    Great news. Will save up and buy. Some presets for Bastioni and Makehuman would really be good...
     
  13. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    732
    Bastioni lab expressions are stored into json files, I've written an importer for the BSPT editor ;)
    I'll add it in the next version.
     
  14. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    964
  15. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    964
    Assuming this asset can alter not just facial expressions but body proportions etc ?
     
  16. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    732
    BSPT works with existing blendshapes, Bastioni lab doesn't export body proportions as blendshapes.
     
  17. Gobstar

    Gobstar

    Joined:
    Nov 12, 2015
    Posts:
    4
    The blendshapes created with Blendshape tool are really amazing but for some reason it wont keyframe any animation no matter what I try. Is there a re reason for this?

    It kind makes the asset useless for animation purposes if its difficult to create animation keyframes! :(
     
    nomax5 likes this.
  18. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    732
    I'll push the animation script in the next update.
    Thank you for your review :)
     
    nomax5 likes this.
  19. nomax5

    nomax5

    Joined:
    Jan 27, 2011
    Posts:
    326
    Hey kalagaan,

    Thanks for making the asset I bought it the other day and I'm enjoying playing with it.

    I want to have it working over the network in multiplayer and I thought I'd ask on the forum
    how people would go about doing it?.
    I'm using Manuel Bastioni characters and they will all have the same BSPC

    The setup I have at the moment is if not local player turn a bunch of stuff off character controller camera etc.
    So i need a way to communicate the blendshape data to all the other clients.
    like a blendshape version of the network animator.

    and advice greatly appreciated.

    Roy
     
  20. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    732
    Hi Roy,
    The preset weights are stored in the list m_presetState of the BSPC,
    you can share all the weights to the other clients.
     
    nomax5 likes this.
  21. nomax5

    nomax5

    Joined:
    Jan 27, 2011
    Posts:
    326
    Ahh ofcouse they are Doh...
    Thanks matey I'll have a fiddle
     
  22. nomax5

    nomax5

    Joined:
    Jan 27, 2011
    Posts:
    326
    Thinking about it I guess that making all my Blendshape Presets into Animations means that the Network Animator component will take care of the multiplayer networking side?
     
  23. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    732
    That should work :)
    I'll push a new version to the assetstore tomorrow, including a demo scene for the animation script. ;)
    If you want a fix before the assetstore release, please send me an email (contact@kalagaan.com) with your invoice number.
     
  24. nomax5

    nomax5

    Joined:
    Jan 27, 2011
    Posts:
    326
    That is fantastic news !!
    I don't need a fix before then I got plenty of stuff to be getting on with..
     
  25. nomax5

    nomax5

    Joined:
    Jan 27, 2011
    Posts:
    326
    Whoohoo I noticed an update on the Asset store, so I deleted BlendShapePresetTool from my project and reinstalled it.
    Hows does it work?

    I'm quite new to unity animation mecanim etc. and I'm a bit thick.

    I see you have what looks to be the original Female head and now a male head at the side.
    They both have the Head Controller script but the male has an additional Animator conponent with no controller.
    They both have the new Blend Shapes Preset Animator script

    I just want multiplayer belndshapes over the network, so when my local player smiles all the other players see my character smile.

    What do I need to do please?

    Roy
     
  26. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    732
    The animation script is a list of float that can be animated in a Unity animation file.
    have a look to the demo, there's an animation component. The animation file is shared between the characters.

    If you want to share the animation you have to use the network components to share the animation to the other clients, or you could do it with a custom script.
    I don't use the network system, but according to the documentation
    https://docs.unity3d.com/Manual/UNetStateSync.html

    it should look like this :

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Networking;
    5. using Kalagaan.BlendShapesPresetTool;
    6.  
    7. public class BSPTNtworkTest : NetworkBehaviour
    8. {
    9.  
    10.     [SyncVar]
    11.     public float m_preset0_Weight = 0f;
    12.  
    13.     BlendShapesPresetController m_ctrl;
    14.  
    15.     // Use this for initialization
    16.     void Start () {
    17.         m_ctrl = GetComponent<BlendShapesPresetController>();
    18.  
    19.     }
    20.  
    21.     // Update is called once per frame
    22.     void Update () {
    23.         m_ctrl.SetWeight(0, m_preset0_Weight);
    24.  
    25.     }
    26. }
    27.  
    I hope that it will help you.
     
  27. HamFar

    HamFar

    Joined:
    Nov 16, 2014
    Posts:
    79
    Can anyone tell me where I can get a free but realistic-looking (human-like) character to use with this amazing tool? Thanks
     
  28. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    732
    Have a look at http://www.manuelbastioni.com
     
    vibedev and HamFar like this.
  29. vibedev

    vibedev

    Joined:
    Nov 1, 2018
    Posts:
    6
    As soon as importing this asset into a Unity project is finished, I get an error message that says: "ExecuteMenuItem target for XR does not exist." Has anyone had the same thing?
     
    HamFar likes this.
  30. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    732
    Hello,
    Blend Shape Preset Tool doesn't use "ExecuteMenuItem", you should try to find this function in your project files.
    What is your version of unity?
    Could you try to import the package in an empty project?
     
    HamFar and vibedev like this.
  31. vibedev

    vibedev

    Joined:
    Nov 1, 2018
    Posts:
    6
    Thanks for your quick reply. I am using Unity 2018.2.17f1 on Windows 10 64 bit with a AutoDesk character that uses facial blendshapes. It might be that "ExecuteMenuItem" is used somewhere in my project files, but it was never thrown as error until I imported BSPT.
     
    HamFar likes this.
  32. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    732
    I don't know why BSPT would generate this error, does it throw an error only once?
    You could try to reimport all your project with BSPT, and without BSPT for checking if it's a bug with BSPT.
    If there's still some issues, could you send me the script with the ExecuteItem function?
    I could check what's going on... ;)
     
    HamFar and vibedev like this.
  33. vibedev

    vibedev

    Joined:
    Nov 1, 2018
    Posts:
    6
    You were absolutely right. This had nothing to do with BSPT. My apologies, and thanks for your offer of help. I am experimenting with BSPT these days, so you will probably see some questions from me here :)
     
    HamFar and kalagaan like this.
  34. vibedev

    vibedev

    Joined:
    Nov 1, 2018
    Posts:
    6
    Thanks to the Doc section on how to get started, I was able to create a couple of presets and save them and apply them to my AutoDesk character that has a blendshape-based face with 65 elements in its Skinned Mesh Renderer array, just like the male|female models you have used in the Demo scenes. However, when I drag&drop the templates that you have created (called Demo1 and Demo2) in the reference field of my character, I get an error message (IndexOutOfRangeException: Array index is out of range) which makes me wonder if I would always have to create a preset from scratch? I understand the meaning of the error message, but given that the array size is defined for each template, I do not understand why this error is thrown? In my simple template, I add only 2 presets; in your two demo templates, you have array sizes 11 and 12 respectively. So, why can I not simply use your templates on my character?
     
    HamFar likes this.
  35. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    732
    Thank you for your feedback,
    I'll fix that error ;)
    You have to create a new template when you want to use a new character, the template is also based on the number of blendshapes, that's why the array of each preset doesn't match with the blendshapes to modify.
     
    vibedev and HamFar like this.
  36. HamFar

    HamFar

    Joined:
    Nov 16, 2014
    Posts:
    79
    A tiny question: All the 66 Action Units (whose values range from 0 to 1) in the Skinned Mesh Renderer component are either pre-fixed or post-fixed with _h but what does this stand for? By the way, do the 66 regions that can be modified (to create a specific blendshape/configuration) really correspond to facial Action Units?
     
  37. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    732
    BSPT uses the blendshapes existing in the skinnedMeshRenderer, so the naming is defined by the creator of the model.
    So I can't answer your question, each model has is own way to deform the parts of the model (face, body...)
     
    Last edited: Dec 10, 2018 at 12:04 PM
    vibedev and HamFar like this.
  38. HamFar

    HamFar

    Joined:
    Nov 16, 2014
    Posts:
    79
    oh I see. Thanks. So, those names are defined by the artist who used Blender or Maya to create the model...

    I attach the following simple script to my character, but as the definition of the API method dictates, I can only set it to a float value (1 here) which is a sudden change from 0.

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. namespace Kalagaan
    4. {
    5.     namespace BlendShapesPresetTool
    6.     {
    7.         public class BlendsAPI : MonoBehaviour
    8.         {
    9.             public BlendShapesPresetControllerBase _BSPT;
    10.  
    11.             private void Start()
    12.             {
    13.                 _BSPT.SetWeight("MyPreset1", 1);
    14.             }
    15.     }
    16. }
    So, I am trying to use Lerp to make the transition from 0 to 1 gradual, as is used in the HeadController.cs script, but over there the GetPresetState is used directly, so I thought I should use a StartCoroutine instead.

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. namespace Kalagaan
    4. {
    5.     namespace BlendShapesPresetTool
    6.     {
    7.         public class BlendsAPI : MonoBehaviour
    8.         {
    9.             public BlendShapesPresetControllerBase _BSPT;
    10.            
    11.             private void Start()
    12.             {
    13.                 StartCoroutine( AnimatePresetTemplate("MyPreset1") );
    14.             }
    15.  
    16.             private IEnumerator AnimatePresetTemplate(string presetTemplateName)
    17.             {
    18.                 _BSPT.GetPresetState("MyPreset1").weight = Mathf.Lerp(0f, _BSPT.GetPresetState("MyPreset1").weight, Time.deltaTime* 10);
    19.  
    20.                 yield return null;
    21.             }
    22.     }
    23. }
    But it doesn't work. What am I doing wrong? How can I programmatically (via the API) smoothly change the values, like a slider?
     
  39. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    732
    The first sample should work,
    be carefull that there's no other script that override the value.
    You can test this one on the demo scene (you'll have to disable the demo script before)
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. using UnityEngine;
    4.  
    5. namespace Kalagaan
    6. {
    7.     namespace BlendShapesPresetTool
    8.     {
    9.         public class BlendsAPI : MonoBehaviour
    10.         {
    11.             public BlendShapesPresetControllerBase _BSPT;
    12.  
    13.             private void Update()
    14.             {
    15.                 _BSPT.SetWeight("Smile", Mathf.Abs(Mathf.Sin(Time.time)));
    16.             }
    17.         }
    18.     }
    19. }
     
    HamFar and vibedev like this.
  40. vibedev

    vibedev

    Joined:
    Nov 1, 2018
    Posts:
    6
    Once, I added a new preset by mistake and then tried to delete it via the little cross that appears when you click on the edit preset icon. It seems to delete the new preset on the spot, but the next time you launch the Unity project, the new preset is still there! I have tried it a few times, so I think it might be a little bug :)
     
  41. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    732
    You can fix it by renaming it to 'UNUSED' :p
    Thank you for the feedback, I'll check that ;)
     
    HamFar and vibedev like this.
  42. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    732
    I've fixed it, I'll push a new version on the asset store.
    To fix it 'manually', you can click twice on the edit button of another preset :p
    It will save the template in the project folder.
     
    HamFar and vibedev like this.
  43. HamFar

    HamFar

    Joined:
    Nov 16, 2014
    Posts:
    79
    Thanks for this. I understand why this works by fluctuating the weight of the Smile preset between 0 and 1.

    Can you please help me also understand why neither of the following two commands works instead of the Sin function?
    Code (CSharp):
    1. _BSPT.GetPresetState("MyPreset").weight = Mathf.Lerp(0f, 1f, Time.deltaTime);
    2. _BSPT.SetWeight("MyPreset", Mathf.Lerp(0f, 1f, Time.deltaTime) );
    How do smoothly lerp from one preset to another in the Update() method, in order to create facial expressions?

    Thanks
     
  44. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    732
    Here a sample ;)

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using Kalagaan.BlendShapesPresetTool;
    4.  
    5. public class BSPTLerp : MonoBehaviour {
    6.  
    7.     public BlendShapesPresetController _BSPT;
    8.     public bool m_smile = true;
    9.     public float m_animationSpeed = 1f;
    10.     float m_weight = 0f;
    11.    
    12.     void Update ()
    13.     {
    14.         if (_BSPT != null)
    15.         {
    16.             m_weight = Mathf.Lerp(m_weight, m_smile ? 1f : 0f, Time.deltaTime * m_animationSpeed);
    17.             _BSPT.SetWeight("Smile", m_weight);
    18.         }
    19.     }
    20. }
     
    HamFar likes this.
  45. HamFar

    HamFar

    Joined:
    Nov 16, 2014
    Posts:
    79
    Excellent! Thank you so much for your help. :)
     
    kalagaan likes this.