The forum on this site is closed for new comments and posts. Continue the conversation in our Snap AR Discord server.

How to control the number of particles depending on how much you open your mouth

  • Hey Reiya,

    You can use Face Landmarks template to create the effects that you're looking for.

    Here is the step by step on how to do this using Face Landmarks template:

    First let's just delete everything in the objects panel but only keep these objects:

    The Mouth Distance is all you need to find the distance between top lip and the bottom lip so we can make an interaction based on that distance.

     

    Than I added a particle system and set it as a child of our head binding in the Objects panel.

    Make sure not to move the Headbinding and if you want move or manipulate the particle, use the particle object it self to move or manipulate.

    Then select the Mouth Distance object and create a script on that by clicking on add new component and select script.

    Then create a script and add it to the component.

    And now we need to do a small scripting. Double click on the script to open it in the script editor and then paste the script below:

    // -----JS CODE-----

    // @input Component.ScriptComponent distanceScript {"label":"Distance Script"}

    // @input Asset.Material particleMaterial

    // @input float amountMultiplier = 1000 {"widget":"slider", "min":0.0, "max":3000.0, "step":0.1}







    var getDistanceFunc = null;

    var particleMainPass;

    var init = false;







    function onLensTurnOn(){

    getDistanceFunc = script.distanceScript.api.getDistance;

    particleMainPass = script.particleMaterial.mainPass;

    init = true;

    }




    function onUpdate(){




    if(init)

    {

    var distance = getDistanceFunc();

    particleMainPass.spawnMaxParticles = distance * script.amountMultiplier;

    }




    }



    var turnOnEvent = script.createEvent( "TurnOnEvent" );

    turnOnEvent.bind(onLensTurnOn);




    var updateEvent = script.createEvent( "UpdateEvent" );

    updateEvent.bind( onUpdate );

    Then save the file.

    Now we need to set the Distance script and the particle material.

    Then set the Amount Multiplier to be around 1000 and now it should be working!

     

    I also attach the project file for you here. 

    https://storage.googleapis.com/snapchat-lens-assets/f1a09194-f02d-43ed-92b8-62e843179ff0/lensStudio/Forum-Helpers/Face-Landmarks-Particles.zip

    But I recommend to do it with the step by step guide here and let me know if you have any problems.

    Also you can learn more about Face Landmarks here:

    https://www.youtube.com/watch?v=IyBMuU-U58c

    https://lensstudio.snapchat.com/templates/face/face-landmarks/

    Hope this will help and have fun creating lenses.

    Cheers,

    Amir.

    Comment actions Permalink

We're here to help! We just need a little bit of information...

What system are you using?

Have you downloaded the latest version of Lens Studio?

Please download the latest version of Lens Studio. If you still run into this issue, please come back and report it!

Is this issue causing Lens Studio to crash?

What system do you run Lens Studio on?

Version

Graphics

Follow the next steps to help us solve your issue:

  • Copy and paste this text into your TerminalCommand Window
    open ~/Library/Preferences/Snap/Lens\ Studio/ %LOCALAPPDATA%\Snap\Lens Studio Copy Text
  • Press ReturnEnter to run the command. The Lens Studio folder will automatically open
  • Prepare to upload your files: zip the "Log" Folder by right-clicking and choosing "compress."
    Locate the Log.txt file right above it.

    Attach a screenshot of the issue:

Name:

Email:

What is this most relevant to?

Please enter a brief description of your issue:

Thanks for submitting this issue.

Unfortunately, it's likely due to the operating system or hardware you're using – since they don't meet the system requirements for Lens Studio.

Still, we hear you loud and clear, and are logging the issue in case there's ever a workaround we can provide!

Minimum Requirements

Operating System: Windows 10 (64 bit); MacOS 10.11+

Hardware: Minimum of Intel Core i3 2.5Ghz or AMD Phenom II 2.6Ghz with 4 GB RAM; Intel HD Graphics 4000 / Nvidia GeForce 710 / AMD Radeon HD 6450 or better; screen resolution of 1280x768 or higher

We'll try to resolve this issue as soon as possible. Thanks for letting us know about it!

Keep an eye out for a followup email from us. We may have a couple more questions for you, or we might already have a solution to offer.

Happy creating!