Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Released] Low Pass Filter

Discussion in 'Assets and Asset Store' started by Vatio, Apr 27, 2015.

  1. Vatio

    Vatio

    Joined:
    Sep 26, 2012
    Posts:
    11


    I'd like to introduce my generic Low Pass Filter package. This is a very simple, easy to use, yet powerful tool for smoothing out continuous data. It helps with any kind of noises or instabilities, making for that nice, enjoyable feeling that everything works fluidly. Use it for filtering mouse or accelerometer input, adding a bit of inertia, smoothing out an object's animation and thousands of different little things that are just too small to be perfected manually, but still count. It all works as below:


    Usage is quite simple. Example:

    Code (CSharp):
    1. using Vatio.Filters;
    2. ...
    3. LowPassFilter<Vector3> filter = new LowPassFilter<Vector3>(0.05F, Vector3.zero);
    4. ...
    5. Vector3 filteredValue = filter.Append(unfilteredValue);

    The script works with both Unity free and Pro for all the target platforms. It is 100% written in C#, supplied as the heavily commented source code so it can be easily run anywhere there is Unity now and in the future, and it can easily be modified and extended to suit specific needs. There are three example scenes included - a desktop version, mobile version and a more interesting desktop game. Each of these scenes comes in 3 flavors, for C#, JS and Boo.

    The script can be used with built-in variable types or any other type that supports arithmetic operations (in this case addition, multiplication and subtraction).​

    Supporting files:​
    • The full instruction is available here.
    • A short example demonstrating script working is available here.
    • A more interesting game example sits right here.
    • And the Playmaker binding is here. It includes example scenes made with Playmaker.
    If You have any questions, comments, or requests please write them here or e-mail them at unity3d@vatio.eu.​
     
    Last edited: Apr 28, 2015
    joshcamas and boysenberry like this.
  2. Summanuss

    Summanuss

    Joined:
    Apr 28, 2015
    Posts:
    1
    PLZ fix the link to the asset
     
  3. Vatio

    Vatio

    Joined:
    Sep 26, 2012
    Posts:
    11
    Hi Summanuss, thanks for Your comment. I actually fixed this link about 15 minutes before Your comment. Thanks again!
     
  4. imaginationrabbit

    imaginationrabbit

    Joined:
    Sep 23, 2013
    Posts:
    349
    Hello- I've been using the low pass function from this link http://wiki.unity3d.com/index.php/Low_Pass_Filter

    I'm not getting the result I want from that low pass filter for Vector3's- is your low pass filter similar to this one or can I expect much better results? Thank you.
     
  5. Vatio

    Vatio

    Joined:
    Sep 26, 2012
    Posts:
    11
    Hi, thanks for the question!

    Upon a quick read the principle seems the same - after all a low pass filter is a low pass filter.
    Please post more details including what exactly is wrong with the results - perhaps we can solve this problem.
     
  6. imaginationrabbit

    imaginationrabbit

    Joined:
    Sep 23, 2013
    Posts:
    349
    Thank you for the reply- I have an object in world space- a target- I'm getting that Vector3- applying the low pass filter then converting that to screen space so I can have a crosshair graphic track the target-

    Without the low pass filter the crosshair movement is choppy- with the low pass filter its either very smooth but too slow to track the target- or fast enough to track the target but too choppy-
     
  7. Vatio

    Vatio

    Joined:
    Sep 26, 2012
    Posts:
    11
    I understand Your problem, but I don't think there are any magic solutions. If You can predict in any way the target's movement You could use that to move the crosshair in the direction of the predicted position. Otherwise I'd suggest finding the best value for the filter factor - placing it in the middle between smooth and choppy should result in perhaps not a perfect solution, but a good one.
     
  8. Vatio

    Vatio

    Joined:
    Sep 26, 2012
    Posts:
    11
    Today a new package has been uploaded - I changed directory structure to better follow Unity guidelines. Note however that everything is compatible with previous versions, and update should go without any problems.

    Also I deleted all old packages - the new version will support only Unity 5.3.1 and above. Previous packages were obsolete and contained problems, which caused trouble for some users. The main script should actually be compatible with Unity 4.0+, but tested and officially supported versions are as mentioned 5.3.1+.
     
  9. Autarkis

    Autarkis

    Joined:
    Oct 10, 2011
    Posts:
    318
    Hello,
    I just purchased this asset and am planning on using it with PlayMaker. I downloaded the PM binding package, and I'm getting the following errors:
    (…) does not contain a definition for 'SetA' and no accessible extension method 'SetA' accepting a first argument of type (...).
    Coming in from all the localFilter.setA(a) lines.
     
  10. Vatio

    Vatio

    Joined:
    Sep 26, 2012
    Posts:
    11
    Thanks for letting me know. Will fix and let you know ASAP.
     
  11. Autarkis

    Autarkis

    Joined:
    Oct 10, 2011
    Posts:
    318
    Thanks for the quick response :)
     
  12. Vatio

    Vatio

    Joined:
    Sep 26, 2012
    Posts:
    11
  13. Autarkis

    Autarkis

    Joined:
    Oct 10, 2011
    Posts:
    318
    Works great! Thanks Vatio.