Make background freeze.
I want to create an effect where when the user taps the screen and the backgroud freezes. I tried doing this with the segmentation template and the "freeze camera" from the fullscreen template. However i cant figure out how to add the frozen image to the background. I am using the fullscreen template, so i would like to freeze the background using the Fullscreen template script.
Hi Mathias!
You can make this with an orthographic camera, two screen images, Unlit material and a script.
Make two screen images one on top of another. Set "Stretch Mode" to "Stretch" for both of them.
Make an Unlit material and assign it to the image which is on top. Also activate using Opacity Texture for the Unlit material and set Blend Mode to Normal for the image which is on top. That makes the image to support transparency.
Use Device Camera Texture as a texture for the materials of both images. This way we are just transferring the input video sequence from camera into both images.
Next step is to use Portrait Background Segmentation texture in the alpha channel for the image which is on top. Create the texture and assign in to the Opacity Texture channel in the Unlit material on the top image.
The last thing to do is to write a simple script and assign its inputs:
// @input Asset.Texture sourceTexture
// @input Component.Image background
function onTap() {
var tex = script.sourceTexture.copyFrame()
script.background.mainMaterial.mainPass.baseTex = tex
}
script.createEvent("TapEvent").bind(onTap)
Make sure you have assigned the bottom image into background input of the script, and Device Camera Texture into sourceTexture input.
Now, when user taps the screen, the script will put the copied frame as the base texture for the bottom image. Which in turn will make it freeze!
Hope that help.
Artem.
Thanks a lot, that worked perfectly!