Trigger texture change on 3D model
Hi,
First of all, I am not so familiar with scripting...but trying to learn as I play around with Lens Studio.
Right now I am trying to figure out how to trigger the texture change of 3D model by mouth open (or eyebrows lifted).
I want to make the mask (3D model)'s facial expression (which is texture) change to smiley face when people move their mouth/eyebrows.
I tried to use Trigger template (https://lensstudio.snapchat.com/templates/face/trigger/), but it only tells me how to trigger 3D/2D animation.
Is there any way I can trigger the texture change on the 3D model via mouth open (or eyebrows lifted)?
Or, I thought about making another same model with a different texture (smiley face) and switch the model triggered via mouth open?
Either way, if there is any way I can achieve what I'm trying to do, that would be great.
Thank you!
Hey there!
You can just change the texture inside a mouth open event. I made a script here you can use to do it, attach the script to the mesh object as you see in the picture, then change the textures to their respective textures.
I added a way to change it back/to another on close but included comments to remove that functionality if you wish. Hope this helps.
Kinda hard to see pic here, see full size image here
I was about to answer but realized Apoc already did. Thanks Apoc!
Here's a quick script that cyles between an array of Materials and applies them to the inputted mesh. You can bind this to MouthOpened so that it moves to the next material each time you open your mouth.
Thank you Apoc and Travis! Sorry for the late reply.
I've copied the scripts and it worked perfectly! I appreciate your guys' help :)
Hey guys, can someone help me, i want to have a standard material which changes into another material when you lower your brows and change back when going into neutral.
I want to do this with several emotion like smile and mouth open.
the one you guys included is amazing!
Hey Maaike,
Have you tried Behavior script?
This script allows you to create simple interaction without writing any custom script.
You can import the Behavior Script by clicking on Add New in the objects panel and search for Behavior Script.
Then you can customize your script to send a custom trigger so we can change the material.
the Send Custom trigger response type sends a custom trigger message as a trigger to other scripts.
With the help of that we need to create a script to change the material when the trigger gets called.
In the custom script we just need to specify which mesh and what material we want to set after trigger gets called.
I attached the project file here which you can see how does that works.
https://storage.googleapis.com/snapchat-lens-assets/f1a09194-f02d-43ed-92b8-62e843179ff0/lensStudio/Forum-Helpers/Change_Material_OnEvent_Example.zip
Please also read the behavior guide linked below:
https://lensstudio.snapchat.com/guides/scripting/helper-scripts/behavior/
Hope this will help you to create an effect that you looking for.
Best,
Amir.