Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

[Released] Mega-Fiers. A mesh deformation system - RELEASE

Discussion in 'Assets and Asset Store' started by SpookyCat, May 18, 2011.

  1. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,164
    Is it possible to use javascript to code a modifier applied in runtime? Any example?
     
  2. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    Hi angel_m
    Yes you can use Javascript to apply modifiers and alter params at runtime. I will brush up my dusty Javascript coding and do an example hopefully today for you.

    Actually just re reading I am assuming the above is what you mean, but in case you meant can you add a new Modifier to the system which is in Javascript then no that isn't possible but coding a modifier in C# would be very very close to coding it in JS.
    Chris
     
  3. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,164
    I mean simply altering the params of an existing modifier at runtime in order to simulate for example the heart beating.
    Another question: is it possible to add a modifier (bulge for example) only to a part of a skinned mesh and preserve the animation?
    Thanks.
     
    Last edited: Aug 26, 2011
  4. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    In that case yes that is no problem, I will as I said attempt to do an example of that for you.

    Yes you can add any modifier to an animated skinned mesh without breaking the animation so you could add multiple bulges or twists etc to a character, so making it easy to make an avatar builder or for adding extra animations or effects on top of an animation.
    Chris
     
  5. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    :cool:
    Waiting for a demo..

    JP
     
  6. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,164
    Purchased :)
    Please, don't forget to post the javascript example.
     
  7. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    Hi angel_m
    Many thanks for the purchase :) I have done a very simple example of using JavaScript to add and then control a modifier. You may need to relocate the the MegaFiers scripts etc to the Standard Assets folder as Unity gets a bit fussy about order of compilation when C# and JavaScript are mixed. You can find info on that here http://unity3d.com/support/documentation/ScriptReference/index.Script_compilation_28Advanced29.html

    The code below is very simple but is all you need to know for any of the Modifiers, they are all very easy to control from script. On Start it simple adds a MegaModifyObject to the target object and then adds a MegaBend (you could add any number of any type here just using Bend as an example). Then in the Update it just increases the angle value by Time.deltaTime.

    Code (csharp):
    1. var target : GameObject;
    2. private var bendMod : MegaBend;
    3. private var modObj : MegaModifyObject;
    4. private var angle : float = 0.0f;
    5.  
    6. function Start()
    7. {
    8.     if ( target )
    9.     {
    10.         modObj= target.AddComponent.<MegaModifyObject>();
    11.         bendMod = target.AddComponent.<MegaBend>();
    12.     }
    13. }
    14.  
    15. function Update()
    16. {
    17.     angle += Time.deltaTime;
    18.     bendMod.angle = angle;
    19. }
     
  8. phoberman

    phoberman

    Joined:
    Jan 16, 2008
    Posts:
    75
    Hi Chris

    Just purchased Megafiers - it's fantastic! - and tried out your javascript example. Got some errors. Cleaned up code, and it ran, but it didn't do anything. So I tried adding the components first in the editor then using GetComponent instead of AddComponent and it works beautifully:

    Code (csharp):
    1. var target : GameObject;
    2. private var modObj : MegaModifyObject;
    3. private var twistMod : MegaTwist;
    4. private var angle : float = 0.0f;
    5.  
    6. function Start()
    7. {
    8.     if ( target )
    9.     {
    10.         modObj = target.GetComponent(MegaModifyObject);
    11.         twistMod = target.GetComponent(MegaTwist);
    12.         twistMod.axis = MegaAxis.Z;
    13.     }
    14. }
    15.  
    16. function Update()
    17. {
    18.     angle += Time.deltaTime*10;
    19.     twistMod.angle = angle;
    20. }
    So I think there might be a problem adding the components via script, or else there must be some trick to it.
     
  9. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    Sorry I tested it by looking at the inspector value changing so I assumed wrongly the mesh was being updated. I missed that you need to tell the system the mesh has been updated so you need to call modObj.MeshUpdated(); after you are done adding all the mods, this tells all the newly added modifiers about the mesh they are working on. So the Start() becomes:
    Code (csharp):
    1. var target : GameObject;
    2. private var bendMod : MegaBend;
    3. private var modObj : MegaModifyObject;
    4. private var angle : float = 0.0f;
    5.  
    6. function Start()
    7. {
    8.     if ( target )
    9.     {
    10.         modObj= target.AddComponent.<MegaModifyObject>();
    11.         bendMod = target.AddComponent.<MegaBend>();
    12.         modObj.MeshUpdated();
    13.     }
    14. }
    15.  
    16. function Update()
    17. {
    18.     angle += Time.deltaTime;
    19.     bendMod.angle = angle;
    20. }
    I will probably add some more methods for easier script controls soon, I am only now just getting around to using my own system for the purpose I originally wrote it for so look out for that in future updates.
    Chris
     
  10. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    Forgot to say thanks phoberman for the purchase, hope you have fun using it :)
     
  11. Zeronine

    Zeronine

    Joined:
    May 22, 2011
    Posts:
    24
    Looks like you got clones Chris Adam :) Spooky entanglements.
     
  12. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    Hi All
    I have just submitted v1.43 to the Asset Store, the new feature this time is Multi Core support. This can be enabled globally for all modified objects as well as per modified object. In my tests (4 core PC) I have seen more than doubling of frame rates and even better in some scenes. I have only been able to test on a Windows machine so far but it makes use of the C# System.Threading code so should be fairly universal. Would be very interested to hear from Mac/iPhone users as to whether or not there are any issues.

    The multi core only comes into effect during Play Mode in the editor and by default is turned off so you will need to have a little script to turn it on ie:
    Code (csharp):
    1. public class ToggleMultiCore : MonoBehaviour
    2. {
    3.     bool Enabled = true;
    4.  
    5.     void Start()
    6.     {
    7.         MegaModifiers.ThreadingOn = Enabled;
    8.     }
    9.  
    10.     void Update()
    11.     {
    12.         if ( Input.GetKeyDown(KeyCode.T) )
    13.         {
    14.             Enabled = !Enabled;
    15.             MegaModifiers.ThreadingOn = Enabled;
    16.         }
    17.     }
    18. }
    Currently the Morph system doesn't use the MultiCore pipeline but I will be adding that in the next release as well as a very big optimization to the whole morph pipeline.
    Chris
     
    Last edited: Sep 5, 2011
  13. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    I will try the new update at my iPad 2 project , this could give a big performance boost !!!!
    Thanks for the update.

    One question: do i need to enable the Multi Core support for the play mode or its enabled for default?
     
    Last edited: Aug 31, 2011
  14. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    Slightly improved the MegaBook.cs script, fixes a bug with page textures and gives an option for spacing the pages to stop z fighting.
    View attachment $MegaBook.cs
     
  15. Dave@IonGFX

    Dave@IonGFX

    Joined:
    Jul 6, 2011
    Posts:
    44
    I just purchased this and I'm already in love with it! I've used these same modifiers in 3ds Max for a decade so I'm very familiar with them all. Being able to use these same modifiers with Unity will not only save some tweaking time, but the addition of vertex-based animation means that there is no limit to what can be done in Unity with a creative mind. The potential applications are mind blowing.

    My plan is to extend iSpeech to work directly with MegaFiers to create the ultimate Unity3d facial animation morph system. ;) I've been thinking that I need to bring iSpeech back to a standalone product and lower the price. If we can get this all hooked up, I'll do it for sure so that the community can have both products for less than the current cost of iSpeech Indie alone. Nice work on this, SpookyCat!
     
  16. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924
    I would be very interested in that setup;)
     
  17. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    I get randomly errors with Mega-Fiers (V1.45).
    (I did not change the code of Mega-Fiers script files)


    Edit: all Shapes scripts fail at this line.
     
    Last edited: Sep 5, 2011
  18. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    Hi Malzbier
    That looks like something has gone wrong in switching over to the new renamed MegaFiers as PathSpline no longer exists in the asset it is called MegaSpline and the file ArcShape.cs should be MegaArcShape.cs. So it looks like you have a mix of old and new versions of MegaFiers in your project.
    Chris
     
  19. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    Thanks for the fast answer. The Trick do delete all old files works fine.
     
  20. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    Been doing some work on the Morpher and have done a first round of optimization on the code and have improved the speed a lot (not that it was slow to start with :) ). In my test scene of an evolver figure with 6500 vertices and 65 full morph channels the morpher was running at 44ms, that is now down to 13ms so 3x faster, and I have yet to do the major optimizing and the multi core version. Will be submitting to the store today.
    Chris
     
    Last edited: Sep 5, 2011
  21. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    Version 1.46 submitted to the Asset store, changes are:

    • On loading morph file the inspector channels are shown in condensed form.

    • Button to show or hide the Morph channel data in the inspector.

    • Morpher has been optimized with over a 300 percent boost in performance, more to come.
     
  22. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    Been playing some more with the morpher and compressing the data etc and some changes in the pipeline structure the evolver character with 6500+ verts and 65 channels that started out running at 44ms this morning and then at 13ms this afternoon is now under 3ms. This will get even better when I get the morpher threaded. Also the memory footprint will be greatly reduced.
    Chris
     
  23. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    Last edited: Mar 1, 2013
  24. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    Hi,
    I have a simple prefab with mesh I am trying to add some modifers to but I keep getting error

    "Instantiating mesh due to calling MeshFilter.mesh during edit mode. This will leak meshes. Please use MeshFilter.sharedMesh instead.
    UnityEngine.MeshFilter:get_mesh()" in the editor.

    Sometimes it works , othertimes I add another modifier and I get this message and I've lost the whole thing.

    Could you please explain what is going on an how I can add modfiers to a prefab with mesh to avoid this? ty!

    EDIT:
    It seems if I want to add modifiers to a prefab I can't just add them via the project/inspector view.
    I need to drag it into the scene, modify the prefab (breaking connection) then reapply the change.
    Seems to lose the mesh as well, so I need to readd that.
     
    Last edited: Sep 6, 2011
  25. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    @SpookyCat
    Excellent news regarding the speed improvements on the morpher, will this apply to morphs coming in from apps other than Max(Blender for example)? I saw the new video demo on youtube, again, impressive!

    This type of speed increase may allow us to put morpher back into our mobile titles, we had to strip it due to the ms time it was previously taking(but all is well on desktop front).

    Any word on when you'll be submitting your "3ms" build of morpher/mega-fiers, and any rough-eta on a possible release of the threading of the morpher as well?

    Your continued work on Mega-Fiers is greatly appreciated, thank you for all your hard work!
     
  26. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Great to hear about the optimisations.

    Does the noise modifier work with multithreading ok on Windows? I'm on a mac and noise goes crazy and gives me a screen full of messy polygons if I enable multi-threading on an object with noise modifier. (on an 8-core mac pro). A few other modifiers I tried seem to work ok, but I'm not actually sure if they are using all the cores, need to do more testing.
     
  27. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    You can ignore that error message firstly, I have spoken with Unity and authors of other editor scripts such as ezGUI and RageSpline and they all have this issue, Unity themselves told me to not worry about the error as it didn't really mean anything in the editor context and it is not an issue at runtime.

    As for prefabs, you wont be able to add a modifier to a prefab without breaking the prefab firstly so yes you will need to put the object in the scene and apply your changes and make a new prefab. I will be looking at improving this after Unity 3.5 is out and the whole prefab system has been updated and improved, I didn't think it was worth spending sometime making it work with a system that was going to be changed if you see what I mean :)

    Zhx, yeah you should see a big improvement on mobile devices with the latest morpher, the version in the asset store at the moment is already 4 times faster than the one you tried before, I hope to have the latest one up their today or tomorrow, need to do some more testing. The threaded morpher will likely be early next week.
    Chris
     
  28. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    Arr good a Mac user :) Ooops I thought I tested the Noise mod seems I was looking at a couple of ripple warps on an object and assumed it was the noise modifier. I will fix that for you today seems the freq value is messing up. Sorry about that.
     
  29. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    Multithreaded Noise modifier fixed, thanks for spotting that :)
     
  30. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    Version 1.47 submitted to the asset store, if you have a scene with a morph in already right click the Morpher inspector and select 'Compress Morphs' this will optimize the data for the new morph pipeline. This will happen automatically when you load mor files on new objects.

    Changes are:

    • Multithreaded noise working properly.

    • More optimizing to the morpher can now be anything up to 40 times faster than it was.
     
  31. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    @SpookyCat
    Thank you for all the continuous work to optimize the morpher, hope we can put it back in our mobile titles, certainly sounds like we can(or will able to with the next release) :)
     
  32. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    Quick work by Unity, the new version is in the store now :) Also if you have a problem with the Max exporter with evolver morphs send me an email for an updated exporter, done forget to say which version of Max and whether 64 or 32bit.
    Chris
     
  33. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    Been working on the multithreaded morpher. Used an evolver model with 22500 verts and 70+ morphs, the morph in normal mode was taking 8ms and in threaded mode (4 cores) it ranges from 2.2ms to 4.7ms so coming along nicely. In the profile window you can see the morph in non threaded mode on the right.



     
    Last edited: Sep 6, 2011
  34. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
    I want to purchase this, but I'm afraid of not being able to decompress it :( as Joey mentioned he had problems with lion a few pages back. Was that ever sorted out?

    And I have the same error with antares universe paid version.
     
  35. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    thanks for the new build @SpookyCat!
    cant wait to do a thorough Blender test again in one of our iOS titles.
     
  36. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    The Asset store has been updated a few times and I believe those bugs have been sorted, I haven't had anyone email or post again saying they couldn't get the package installed.
    Chris
     
  37. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    Version 1.48 with the multithreaded morpher has been submitted to the Asset Store. This will probably be the last update before the price goes up as mentioned above so if you are thinking about getting the system now is the time :). Also if anyone has problems with the Max exporter email me for a new version.
    Chris
     
    Last edited: Sep 7, 2011
  38. Picassotrue

    Picassotrue

    Joined:
    Sep 7, 2011
    Posts:
    1
    I just buy your MegaFier, and how i can export morph data from max?? Where plugins? On your web site no contacts (
     
  39. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    Hi Picassotrue
    Many thanks for the purchase :)
    My email is on the front page of the MegaFiers page or you can pm or email through the unity forum. Email/pm me with the version you need.
    Chris
     
  40. Pradeep-Patel

    Pradeep-Patel

    Joined:
    Mar 31, 2011
    Posts:
    96
    i have use it is work great

    but i could not bend the object bcoz it need mesh map n other obj extension why it is require...!
     
  41. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    Hi Pradeep
    I am sorry but I don't quite understand what you mean, what is 'mesh map' and what do you mean by other obj extensions. All you need do is add a Modify Object component to the mesh object and then the bend. Could you show me what you have done?
    Chris
     
  42. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
    spookycat, everything decompressed perfect. yay!
     
  43. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    the new optimizations on the morpher sound awesome, cant wait to test it out!
    thanks @SpookyCat

    MegaFiers is by FAR one of the best purchases AVAILABLE in the Asset Store, get it if you havent already!
     
  44. Angrycrow

    Angrycrow

    Joined:
    Jan 29, 2011
    Posts:
    34
    Amazing work! This is precicely what I've been waiting for in Unity. It looks like a very strong plugin. Must resist the urge to purchase. But it's so useful!!!
     
  45. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    Some of you may have noticed on complex objects with uv seams etc that an artifact can appear when normals are recalculated, this is due to the Unity duplicating up vertices for uv seams etc so when a RecalulateNormals is called the original smoothing info is lost and uv seams show up as hard edges, this finally annoyed me so much that I wrote a new normal calculator that respects the original imported smoothing groups. The system is a tiny bit slower than the built in Unity calculator but I will be threading it (and the tangent builder) so in the end it will make the system faster overall. So that will be in the next update. Below is a couple of pictures that show the issue, the first is using Unitys RecalcNormals, the second is using my normal calculator.
    Chris

     
    Last edited: Sep 8, 2011
  46. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    As promised a quick script to show a softbody bounce effect script. This just uses a Stretch modifier to squash the object as it hits the ground, you could extend the system to squash on any plane you just need to set the Gizmo Rot correctly, you could also embellish it with a bit of stretch when moving at speed for example to further emulate a softbody, or instead of a Stretch modifier you could use a Melt modifier and simulate an object going splat on the ground. You could extend the bounce effect by having say a second point attached by a spring and then using the length of that spring to drive the amount of squash, that would give you some stretch as well on rebound or change in direction.
    Anyway the simple bounce script is:
    Code (csharp):
    1. using UnityEngine;
    2.  
    3. [ExecuteInEditMode]
    4. public class BallBounce : MonoBehaviour
    5. {
    6.     public float ground        = 0.0f;        // Ground position
    7.     public float radius        = 1.0f;        // radius of the ball/object
    8.     public float vel        = 0.0f;        // vertical velocity
    9.     public float spring        = 10.0f;    // spring rate of the object
    10.     public float py            = 1.0f;        // vertical position
    11.     public float mass        = 1.0f;        // objects mass
    12.     public float timescale    = 1.0f;        // time multiplier
    13.  
    14.     MegaStretch mod;
    15.     MegaModifyObject modobj;
    16.  
    17.     // Simple physics timsetp
    18.     void FixedUpdate()
    19.     {
    20.         float t = Time.fixedDeltaTime * timescale;
    21.         float fy = -9.81f * t;
    22.  
    23.         if ( py < ground )
    24.             fy += (spring * (ground - py)) / mass;
    25.  
    26.         vel += fy * t;
    27.         py += vel * t;
    28.     }
    29.  
    30.     void Update()
    31.     {
    32.         // Find the stretch mod
    33.         if ( !mod )
    34.         {
    35.             mod = GetComponent<MegaStretch>();
    36.             modobj = GetComponent<MegaModifyObject>();
    37.         }
    38.  
    39.         if ( mod )
    40.         {
    41.             Vector3 pos = transform.position;
    42.  
    43.             float amt = py - ground;
    44.  
    45.             if ( amt > 0.0f )
    46.                 amt = 0.0f;
    47.  
    48.             float y = py;
    49.             if ( y < ground )
    50.                 y = ground;
    51.  
    52.             if ( mod.amount == 0.0f  amt == 0.0f )
    53.                 modobj.enabled = false;
    54.             else
    55.                 modobj.enabled = true;
    56.  
    57.             mod.amount = (amt / radius);
    58.             pos.y = y;
    59.             transform.position = pos;
    60.         }
    61.     }
    62. }
    And it produces this effect.
    [video=youtube;AJw4b0x4PME]http://www.youtube.com/watch?v=AJw4b0x4PME
     
    Last edited: Sep 8, 2011
  47. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    Quick heads up the multithreaded morpher is in the Asset store now, version 1.49. Later today I hope to upload the next version with the improved normal system and multithreaded normal and tangent calculator.
    Chris
     
  48. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    Version 1.50 has just been submitted to the Asset Store, this version includes the new normal re calculator shown above, this will preserve the smoothing group info of the original mesh, this is useful for models that have uv seams in areas which should be smooth such as the neck and arms on the evolver model above. If you import a mesh and have unity calculate the normals then you should keep the default Normal method of Unity as in non threaded mode this is slightly faster, if you use imported normal values then you should use the Mega normal method if you see unsightly seams on the modified object. You may notice a second or so delay on complex meshes if you switch to the Mega Normal method as the system as to analyze the mesh to determine to smoothing groups. You should also select the method before applying any modifiers to the object as once a new set of normals have been applied to a mesh and you then select the Mega normal method the existing normals are used to calculate the smoothing groups.

    The new normal method is a tiny bit slower maybe 2ms for the whole demo scene in the package so not noticeable really, but the plus side is the new method is faster in threaded mode. The tangent calculator has also been optimized a little in this update.
    Chris

    Changes for v1.50:

    • New method of re calculating normals has been added, this is an alternative to the Unity method and unlike that method it preserves smoothing group info from the original imported model.

    • Normal calculator has a multicore version.

    • Tangent calculator has been optimized.
     
  49. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,790
    Just did a quick video showing the rollup effect that can be created with the Bend modifier alone.
     
  50. zipper

    zipper

    Joined:
    Jun 12, 2011
    Posts:
    89
    So, why hasn't Unity hired you yet :)