How can I create clones of myself?
Hello. This is my third ever Lens so bear with me, just trying to learn here :)
I need to create a clone of myself whenever I tap the screen. I've been trying many things like .copyFrame() on the Device Camera Texture and setting the copied texture to a new object, but I'm running into a lot of issues and I haven't been able to figure it out.
This existing Lens does exactly what I need, I'd love to learn how it works!
https://www.snapchat.com/unlock/?type=SNAPCODE&uuid=ea50f54f5abb477b8eec1d3b8ade125f&metadata=01
Hi, Gravix!
I'm glad you're learning! This is a cool lens!
'll try to explain how I would do this. But because the lens already exists I will not share a project with you.
I see that you are already using copyFrame, but I think you probably got stuck on creating a texture with transparent background.
Here is basic idea:
1. Render Image with Device Camera Texture and Portrait Background Segmentation to render Target 1
2. Copy frame of Render Target 1 texture, instantiate new Image and use copied frame as a texture for the newly created image. Render all crated images to another orthographic camera
To implement step 1 please do next :
1. First camera (let's create orthographic one) will render an image with custom material.
This camera has no input, no mask, it has Clear Color enabled and color set to transparent.
Then I created a material --> Add New --> Unlit. Changed blend mode to normal, and enabled Opacity Texture checkbox.
Set Base Texture to Device Camera Texture, opacity texture to the Portrait Background Segmentation texture.
Then assign this material to the Person with Alpha image
So what we have now:
This camera's render target is a texture you would want to copy frame from.
2. Please try to implement step 2 by yourself, looks like you know what to do :)
Best
Olha