How to make Facebook 3D-photo in Unity

How to make Facebook 3D-photo in Unity

A bit of theory

Modern devices with two cameras have a Portrait Mode, which beautifully blurred the background. The phone calculates the distance between the camera and objects in the frame using the offset between the lenses, and then put this data into the image. Using this value, it makes the blur natural.

Facebook created an algorithm that simulates a 3D-Effect when you rotate the phone based on these values. All it needs is a picture with information about pixels remoteness.

You just need to render 2 pictures — Main Image and Depth Mask, then upload them as a 3D photo to Facebook!

Let's do it

Open Unity and follow these steps:

Victory!

If you did everything right (and here it is difficult to make a mistake in something) — you got a 3D photo on Facebook, like what was shown at the beginning of the article. If you want to make 3D Effect stronger you need to make Depth Image more contrast in any graphics editor.

If you have any questions or comments — contact us on social networks or at this email address. Well, and, of course, share with friends, if it was useful!

See you again!

Share if it was useful