I am trying to map a portrait 2D video to a 3D sphere in Unity. The video is not a 360 video, so it does not need to be stretched to cover the entire sphere(see the attached sketch).
Instead, I would like to map the video to the sphere so that it maintains its aspect ratio and leaves other parts of the sphere transparent. Say, the video has a resolution of 800 x 1920, which is about 20% of the resolution of a typical 4K 360 video (3840 x 1920).
I am wondering if there is a way to achieve this effect using texture remapping directly in script, or a custom shader.
If the sphere is UV-wrapped in the usual latitude/longitude way, it should be very straightforward to make a shader that lets you use the tiling, offset and clamping modes to the desired area, but give transparent alpha outside those bounds. Or just convert the UV 0~1 ranges directly to the desired image ranges. You’d calculate using the source’s aspect ratio to ensure the right shape.
The next challenge would just be to connect a video source instead of a static image; the old feature is a Movie Texture, the new feature is a Video Player to a Render Texture.