Search Unity

SMD - Create Animated GPU Deformations

Discussion in 'Assets and Asset Store' started by jackmememe, Jul 25, 2017.

  1. jackmememe

    jackmememe

    Joined:
    Jan 21, 2016
    Posts:
    138

    Changelog:
    1.2:
    • New Effect: Melt
    • Improvement the editor interface
    • Now effects can be named
    • Now effects can be ordered
    1.1:
    • Asset now work with animations.


    1.0:

    • Release


    About:

    With this package your can create animated distortions and deformations for you mesh with just a few clicks.

    This package let you update your mesh vertices in real time, it only use a script and don't need to change your existing material or shaders.

    This calculations can be performed in real time or saved as an animation to be used during the game.

    For version 1.0 the animations effects include:
    • Stretch
    • Spin
    • Random
    • Inflate

    You can see the asset in action in this video:

     
    Last edited: Oct 16, 2017
  2. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    655
    Gimme gimme gimme?
    (By that I mean I suspect it'll look great for my cartoon snowmen -- much better than my transform based squashing when they land from a great fall, etc!)
     
  3. jackmememe

    jackmememe

    Joined:
    Jan 21, 2016
    Posts:
    138
    Sent! Thanks for the interest . Let me know what you think later.
     
    Arkade likes this.
  4. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Cool package! Does it work on animated skinned meshes - like a character who is moving and performing animations?
    If so I'd love to see an example of that in the marketing material.
     
    Arkade likes this.
  5. jackmememe

    jackmememe

    Joined:
    Jan 21, 2016
    Posts:
    138
    I got almost working, i am trying to make it to the next version.

    The mesh will distort with animations, but will do the calculations using the default pose, i am trying to think of a way to calculate with the bones without making it to much heavy.

    The only effect that will work correctly for now is the noise effect, later i will make a small gif showing the result.
     
    theANMATOR2b likes this.
  6. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    I haven't seen if effect can be combined together!
     
  7. jackmememe

    jackmememe

    Joined:
    Jan 21, 2016
    Posts:
    138
    Here is the animated examples, first without the animation applied to the distortions, then the nightmare induced animated versions:



    Yes, you can combine as much effects you want, 3 stretch + 2 random + 5 inflate, no problem.

    Here is an example with stretch + spin + random:


    Tomorrow I will be in a business trip, so i may not be able to check this topic, but as soon as i get home I will answer any more questions that i can. Thanks!
     
  8. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    655
    Yep, I totally agree -- some of those are really nightmarish!

    I guess to work with animations, one would either have to (1) apply these effects after the bones are applied or (2) pre-compensate for the bones' changes that frame.

    I guess (2) mandates doing it on the GPU if GPU skinning is enabled. If not GPU skinning, can one affect after? (E.g. I'm using asset ”Dynamic Bone” to animate by snowmen so that might be made to work ... but I had hoped to also apply the effect to normally animated characters too.)

    Could (1) be made to work in any performance friendly way?

    And there are probably other techniques I can't guess :)
     
  9. jackmememe

    jackmememe

    Joined:
    Jan 21, 2016
    Posts:
    138
    Yep, is really tricky, but i managed to make the correct calculations, still gonna have to make a few alterations before releasing as a update, but is a progress:

     
  10. jackmememe

    jackmememe

    Joined:
    Jan 21, 2016
    Posts:
    138
    Version 1.1 release!

    Now the asset work with animated meshes:
     
    neoshaman likes this.
  11. jackmememe

    jackmememe

    Joined:
    Jan 21, 2016
    Posts:
    138
    Asset Update: 1.2
    New Effect: Melt
     
  12. jackmememe

    jackmememe

    Joined:
    Jan 21, 2016
    Posts:
    138
    Simple Mesh Distortion in now with a discount of 50% for a limited time.
     
  13. qkjosh

    qkjosh

    Joined:
    Nov 29, 2015
    Posts:
    33
    Hi there, just started using this and it's pretty nice :) I'm having a small issue getting a distortion animation to start playing.

    I have the Distort and Animated Distort scripts on the mesh, and the distortion's force starts out at zero, since I don't want it to do any distortion just yet. At some later point, I update the distortion's force value via script, but the animation doesn't start playing unless I change one of the distortion's values via the inspector. That's with "Calculate in GPU" checked - when I uncheck that, changing a distortion's force by script works as expected. Any ideas? Thanks.
     
    Last edited: Sep 22, 2017
  14. jackmememe

    jackmememe

    Joined:
    Jan 21, 2016
    Posts:
    138
    Hey there, sorry i was away this weekend, but as soon i get home today i will look at this issue for you and give you a solution. Thanks for your support!
     
  15. jackmememe

    jackmememe

    Joined:
    Jan 21, 2016
    Posts:
    138
    Hey there, wen using the GPU, you need to call the function:
    Code (CSharp):
    1. distortion[i].UpdateObjectDataBuffer();
    After changing any value for the distortion, this will update the GPU buffer for this distortion.
    I'm gonna do an update so this is called automatically if you do some change in the values. But for now please let me know if this solve your problem! Thanks
     
  16. qkjosh

    qkjosh

    Joined:
    Nov 29, 2015
    Posts:
    33
    Ah, thanks. That seems to work, but I'm tweening the distortion force amount, so calling that multiple times throughout the tween probably isn't the best idea. I'll just do it on the CPU. Thanks though!
     
  17. jackmememe

    jackmememe

    Joined:
    Jan 21, 2016
    Posts:
    138
    There is no problem in calling it once a update, it just need to be called manually so it wont create unnecessary data while the force data stay the same.

    Any question or problem just reply in here or start a private conversation with me, i am glad to help!
     
  18. Truofan

    Truofan

    Joined:
    Jun 23, 2017
    Posts:
    3
    Hi there,
    My studio is working on a project which needs to distort meshes at runtime, but the mesh might be rotated and the distortion should follow through.
    I've tried the free version of this but I find it always distorts the mesh in constant directions no matter how I rotate the mesh.
    Am I missing anything or it just can't do it?
    Thank you, wonderful tool still.
     
  19. jackmememe

    jackmememe

    Joined:
    Jan 21, 2016
    Posts:
    138
    Hello, thanks for the complement.
    Right now the distortions are only calculated in world position, but i will try this week to see if i can make it calculate all in local position.
     
  20. Truofan

    Truofan

    Joined:
    Jun 23, 2017
    Posts:
    3
    Hey thank you for reply,
    We are using vertex animations as a makeshift, so it will be a great news for us if you made it!
     
  21. jackmememe

    jackmememe

    Joined:
    Jan 21, 2016
    Posts:
    138
    Hey there, i just updated the package to support local distortions, so please give it a go and let me know if everything is working OK
     
    RendCycle likes this.
  22. machineboy

    machineboy

    Joined:
    Nov 19, 2014
    Posts:
    1
    Hi, this looks really cool. How are they running on mobile devices? Are they usable, or do they take up a lot of CPU/GPU power?
     
  23. jackmememe

    jackmememe

    Joined:
    Jan 21, 2016
    Posts:
    138
    For mobile, if you have one or two simple models, it should not be a problem to create dynamic animations.
    If you have multiple models, or a really complex model, you can pre-calculate the animations and just play them in real time, this is a lot faster to calculate.

    You can try the free version if you want to test, but to save animations you need the full version:
    https://www.assetstore.unity3d.com/en/#!/content/100419
     
    machineboy likes this.
  24. hierro__

    hierro__

    Joined:
    Sep 22, 2014
    Posts:
    59
    Hi, is there a way to inflate by a plane transform and up vector ?
    what i need is to inflate an object when and where is colliding a plane, so i can manage this and other effects just moving my plane over the object.
     
  25. jackmememe

    jackmememe

    Joined:
    Jan 21, 2016
    Posts:
    138
    Do you mean like, if the plane in the middle of the object, only inflate half?
    If you need the ability to rotate the plane, it can be a little trickier.

    You need to find all the places that use Evaluate in the scripts (not that many)
    and do something like this.

    Code (CSharp):
    1.  
    2. if(ObjBounds.Contain(PlanePosition)){
    3. //Check if the object is o front or behind the vertice
    4. if(Vector3.Dot(plane.foward, plane.position - vertice.position) > 0){
    5. return curve.evaluate()
    6. }
    7. else{
    8. return 0;
    9. }
    10. }
    If your object and plane don't rotate, you can get the position percentage inside the object bounds, and edit the curve to create a new curve where value < planePercentage = 0 AND value > planePercentage = OldCurve
     
  26. Archina-Void

    Archina-Void

    Joined:
    Feb 14, 2015
    Posts:
    1
    Hey!

    Is it possible to use the modifiers on part of the mesh only? And can you modify multiple regions of a mesh in different ways?
     
  27. jackmememe

    jackmememe

    Joined:
    Jan 21, 2016
    Posts:
    138
    Hey there, you can affect only parts of the mesh using the Animation curves, just keep the value of 0 for the regions that you don't want it affected. You can try it with the free version of the asset to see if fit your needs.

    You can also affect the same mesh in several ways. Just create two or more distortions in the same mesh and edit the settings. All this options are also available in the free version of the asset.
     
  28. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    330
    Is this fully compatible with Unity 2018.1.6?

    I'm planning to use this to attach the 4 corners of a Net Mesh to individual swimming objects so it will then be vertically aligned while moving and the middle mesh part then has the wavy animation. Then it can change form to sort of a circular orb as it "wraps" over objects if ever it hits/collides with them. Is it possible with this tool?
     
    Last edited: Aug 31, 2018
  29. hl2118

    hl2118

    Joined:
    Feb 15, 2018
    Posts:
    3
    Hi! I have a project involving distorting point cloud in unity. I have applied the distortion and be able to preview the result, also able to see the effects in playmode while cranking up the force.
    However after applying the animated distortion script I cannot control the animation, it prompts an error that it "faild getting triangles, Submesh topology is lines or points.", which is expected, as point cloud doesn't have any face

    but as I am able to preview the result, I wonder if I can bypass the whole topology thing and make it work just for the points? thanks!
     
  30. jackmememe

    jackmememe

    Joined:
    Jan 21, 2016
    Posts:
    138
    I didn't test it with the 2018 version, but it shouldn't have anything preventing it to work. You can use the free version to see if fit your needs. It should work to align vertically, just set the position to global position on the script.
    For the circular orb, just keep the deformation ready in the script. Once you hit the object, animate the "Force" var from 0 to the number that you want.

    I never used point clouds in Unity, so i don't know how to handle them, but if the script is working without animation, it must have some similarities to a regular mesh. Can you PM me a print of the error or post it in here? I can take a look to see if i can fix it.
     
  31. Dobalina

    Dobalina

    Joined:
    Sep 6, 2013
    Posts:
    105
    @jackmememe Hello! The performance and visual results of your deform script is impressive, though a major issue I'm encountering is I'm unable to enable/disable the 'effect' at runtime with Playmaker. Playmaker can easily modify public booleans, though something prevents playmaker from modifying the effect "Enabled" boolean. I suspect if the distortion values were a default component of the Distort.cs script, Playmaker could then access the the variables/bools. Is there a way to completely skip the 'add new deform' button?

    ...or alternatively, if we disable the primary Distort (script)... ideally it would disable/revert the distortion effects with it. Is this possible?
     
    Last edited: Oct 20, 2018
  32. jackmememe

    jackmememe

    Joined:
    Jan 21, 2016
    Posts:
    138
    Hey there,
    the Distort.cs have a list var called "distort"
    so using Distort.distort[0].enabled; Distort.distort[1].enabled you should be able to enable/disable effects. Does this not work in PlayMaker?

    You can also create a function in Distort.cs to enable and disable this effects if it easier. If you don't know how to create a function, i can do it for you.
     
  33. Dobalina

    Dobalina

    Joined:
    Sep 6, 2013
    Posts:
    105
    When I try to access the Distort enable via playmaker, it throws a long error starting with "TargetParameterCountException: parameters do not match signature"

    You can see what parts I have access to here. upload_2018-10-24_2-41-0.png

    I don't have much scripting knowledge outside playmaker. If it's easy enough for you to make that function for me, I'd be super grateful!
     
  34. jackmememe

    jackmememe

    Joined:
    Jan 21, 2016
    Posts:
    138
    Hey there, sorry for the delay. Unfortunate i barely use playmaker, so i don't have sure the best way to handle it. But try to add this functions to the script Distort.cs and call it using the index of the effect you want to enable/disable

    Code (CSharp):
    1.        public void EnableEffect(int effectIndex)
    2.         {
    3.             if(effectIndex >= distort.Count)
    4.             {
    5.                 Debug.LogError("Selected index is bigger than list", this);
    6.                 return;
    7.             }
    8.             distort[effectIndex].enabled = true;
    9.         }
    10.         public void DisableEffect(int effectIndex)
    11.         {
    12.             if (effectIndex >= distort.Count)
    13.             {
    14.                 Debug.LogError("Selected index is bigger than list", this);
    15.                 return;
    16.             }
    17.             distort[effectIndex].enabled = false;
    18.         }
     
  35. Dobalina

    Dobalina

    Joined:
    Sep 6, 2013
    Posts:
    105
    I placed your code into the Distort.cs and it compiled with no errors, though not seeing any new enable/disable booleans appear. I tried toggling what's already there through playmaker, but the 'effect' still isn't getting disabled. Hmm.
     
  36. jackmememe

    jackmememe

    Joined:
    Jan 21, 2016
    Posts:
    138
    With this functions, don't call a boolean. Call this functions and pass a int with the index you want. If i have some time tomorrow I will try to set up PlayMaker to send you some printscreen showing how to do it.
     
  37. jackmememe

    jackmememe

    Joined:
    Jan 21, 2016
    Posts:
    138
    Sorry for the delay, my computer got broken and just now i managed to fix it.

    I made a few changes to my previous functions and was able to test it in playmaker without any problem.
    The updated functions:

    Code (CSharp):
    1.         public void EnableEffect(int effectIndex)
    2.         {
    3.             if(effectIndex >= distort.Count)
    4.             {
    5.                 Debug.LogError("Selected index is bigger than list", this);
    6.                 return;
    7.             }
    8.             distort[effectIndex].enabled = true;
    9.             UpdateDistort();
    10.         }
    11.         public void DisableEffect(int effectIndex)
    12.         {
    13.             if (effectIndex >= distort.Count)
    14.             {
    15.                 Debug.LogError("Selected index is bigger than list", this);
    16.                 return;
    17.             }
    18.             distort[effectIndex].enabled = false;
    19.             UpdateDistort();
    20.         }

    How to set up in PM:
    upload_2018-11-1_8-51-1.png upload_2018-11-1_8-51-11.png
     
  38. Dobalina

    Dobalina

    Joined:
    Sep 6, 2013
    Posts:
    105
    Wonderful! Thank you so much for your help, it works perfectly now.
    I'm sorry to hear about your broken PC.

    Cheers!
     
    jackmememe likes this.
  39. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Hello,

    I'm looking into the asset. Is it compatible with Mobile?

    Thanks,
    jrDev