The forum on this site is closed for new comments and posts. Continue the conversation in the new forum, and learn more here.

Repeating textures with one trigger

  • Hi Gamze, I modified the new Segmentation Template a bit to take in textures programatically. Then, I created a script that changes the segmentation template's textures called Segmentation Changer. Checkout the example project here:

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

    With the Segmentation Changer object selected, add textures that you want to change to:

    Textures will then change on eyebrows raised. 

    Comment actions Permalink
  • This is excellent - 

    Is there a way to mod it to work with the Face Mask?

    Thanks

    JP

    Comment actions Permalink
  • Hello JP,

    I made a project that will change the Face Mask whenever you raise your eyebrows. you can download the project file here:

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

    With the FaceMaskChanger object selected, add textures that you want to change to:

    Textures on face mask will then change on eyebrows raised. 

     

    Best,

    Amir.

    Comment actions Permalink
  • Hi there,

    I'm hoping you can help me create a Segmentation Script that when you tap it changes the background. 

    Thanks,

    Chris

     

     

    Comment actions Permalink
  • Hey Chris,

    You can use Travis's project file in this thread and modify the SegmentationChanger script from:

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

    // @input Asset.Texture[] textures

    // @input Component.ScriptComponent segmentationController

    var currTexture = 0;

    init();

    function init()

    {

    script.segmentationController.api.imageTexture=script.textures[currTexture];

    script.segmentationController.api.resetSegmentation();

    }

    function browsRaised()

    {

    currTexture++;

    if( currTexture>=script.textures.length )

    {

    currTexture=0;

    }

    script.segmentationController.api.imageTexture=script.textures[currTexture];

    script.segmentationController.api.resetSegmentation();

    }

    var browsRaisedEvent = script.createEvent("BrowsRaisedEvent");

    browsRaisedEvent.bind( browsRaised );
     
    To:
     
    // -----JS CODE-----

    // @input Asset.Texture[] textures

    // @input Component.ScriptComponent segmentationController

    var currTexture = 0;

    init();

    function init()

    {

    script.segmentationController.api.imageTexture=script.textures[currTexture];

    script.segmentationController.api.resetSegmentation();

    }

    function onTapped()

    {

    currTexture++;

    if( currTexture>=script.textures.length )

    {

    currTexture=0;

    }

    script.segmentationController.api.imageTexture=script.textures[currTexture];

    script.segmentationController.api.resetSegmentation();

    }

    var tapEvent = script.createEvent("TapEvent");

    tapEvent.bind( onTapped );
    In the script I just changed the event from eye brows raised to tap. which makes the background change trigger every time the user tap the screen.
    Please read Lens Studio's guide on Script Events here. 
    And also here is the API page for all the Events.
     
    Hope this will help you to fix the problem.
     
    Cheers,
    Amir.
     
    Comment actions Permalink
  • Thanks Amir for getting back so quick!

    Comment actions Permalink
  • Wow that's great Amir!

     

    Thanks - hey looks like you have scripting mastered in LS thanks so much.

    I managed to do something similar but this script is exactly what I was seeking

     

    Thanks

     

    JP

    Comment actions Permalink
  • Hi Amir,

    Made a lens with 20 mascarade masks using your script.

    I can see I can switch params within the script to target other LS objects too..

    here's a link to the just-published lens - 

    https://www.snapchat.com/unlock/?type=SNAPCODE&uuid=8e0bd18154eb49c083664005e8b6312d&metadata=01

     

    enjoy

     

    JP

     

    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!