Better Looking Text and Titles in 360 Video

Previously I have written guidelines, and about the underlying distortions, that go along with simply adding title cards to 360 video in a video editor.

What about when we don't want the text to appear distorted at all? We generally want titles to appear flat like the viewer is looking at a big poster in the scene. This means pre-warping the title text, so that when the equirectangular projection is wrapped (and warped) around a sphere, it appears "correct". By correct, I mean flat. Un-warped.

Stephen Universe Title Cards

This equirectangular image from a Stephen Universe video shows what we are talking about. Another example is this grid, from the previous post about title cards. Just a regular grid

If we pre-warp it, we get this odd shape:

Squished towards the edges.

This image, viewed in a 360 photo viewer, looks like this:

Warped Grid In Viewer

Wow. That just looks exactly like the grid we started with. Perfect!

For Reference, Here is another angle.

Straight Lines Remain Straight

This is what we are trying to do for title text. One small note is that while one can get away with larger titles than without pre-warping the grid because the distortion is not extreme, there is still distortion towards the edges. Not while the viewer is looking straight, but when they turn their heads - as we can see in the above snapshot - perspective distortion is still at play. Larger images will invite the viewer to turn their head in order to view/read the entire image, and end up distorting the image in ways they do not anticipate.

Title Cards, Text Cards, Image Cards, Anything Card.

I'm going to refer to this un-warped flat-looking thing as a card. It could be a title, a logo, some overlayed text; whatever we want.

If we want to do a video, we have to export our video to frames, then apply this effect frame-by-frame. This batch process for video files is not easy with the method I will share, but there are other ways about this process.

I will be sharing a method that uses open source software, doesn't require purchasing any plugins or software (2) (3), installing blender and/or python, or java, and can't easily batch process video frames.

The Underlying Math

Unwarping (or pre-warping?) is more complicated than regular titles, but don't worry, it is not that hard. For starters, let's set some constraints that will simplify the process.

  1. We want the card to appear centered, or roughly centered.
  2. The Title does not need to cover more than 90 degrees of our field of view.

Let's draw out what we are trying to do.

Well, tools that exist to do this gnomonic projection (or rectilinear to equirectangular conversion) are not easy to find. Luckily, a fairly common projection technique uses gnomonic projection: cube maps.

The top part is the cube map. It's just as if a camera were stuck inside of a cube, instead of stuck inside of a sphere. By SharkD - Own work, CC BY-SA 3.0, Link

We can put our title on the face of a cube in a cube map, then run the cube-map through a projection converter that converts it to equirectangular projection.

It's easier than it looks

Really, we only need one face of this cube map for our conversion. The projection method for this is called 'rectilinear', which just means that the projection of 3D space onto a 2D plane is such that straight lines still appear straight. Camera lenses are usually rectilinear. Neat!

Now that we have an idea of what we are trying to do, let's get down to business.

Stiching Software: Free, Easy, Open Source

I chose this method because it was the easiest to use without any advanced computer or programming knowledge. It doesn't use cube maps. Before we get to installing and using Hugin, let me go over some alternatives - you may find something more amenable to your workflow. Remember, all we need to do is convert from a rectilinear image (or a cubemap) into an equirectangular projection.

Alternative Methods

(This is not an exhaustive list)

Hugin

Official Hugin Logo

Hugin is free and open source software for stitching images together into panoramas. I use it to create photosphere images. It's primarily used for stitching multiple images together, just like our 360 cameras do frame-by-frame. It can take an arbitrarily high number of images from a camera (rectilinear images) and stitch them together, and generate an equirectangular image. If it can't cover the entire area, it will leave that part transparent.

We are going to give Hugin one image, tell it to not complain about being unable to stitch this image with zero other images, and spit out an equirectangular version of our image.

Install Hugin

Hugin is cross-platform, open source, and free. Download it from hugin.sourceforge.net.

Prepare Your Image

The advantage of using Hugin over a direct cube map conversion is that there is less work for us to prepare our image card ahead of time. We don't have to worry about setting our card up in the form that a cubemap takes, and we can adjust the scale of the card from Hugin. If you are using cubemaps, the Domemaster Actions Pack for Photoshop is essential. It's still useful otherwise, and one can use it to help create disks to put flat images on the top and bottom of our image. I'll cover this in a later post.

Here is the image I will use to demonstrate (I'm no Saul Bass):

My old graphic design professor is crying somewhere

Note: If we want the image to repeat a few times, a technique we have seen to be effective for titles, we can do that within Hugin, or after the image is distorted in software like Photoshop.

Load Your Image

Launch the Hugin Panorama Editor, where you will see the following screen: The Default Hugin Screen (If your screen looks different, select the Interface drop-down menu, then select Simple).

Step 1, of course, is to load all of the images that are going to stitch together. We aren't really stitching anything together, let's load our one image. In the Assistant tab, we can select 1. Load Images. Select the title card. We get this dialogue box:

Camera and Lens data

What should we enter in for the settings? Our image, created in Photoshop, wasn't captured with a lens! But it is flat. We want to double check that Lens type is "Normal (Rectilinear)". That's the whole point of this process, to go from rectilinear to equirectangular

It doesn't have a focal length. Instead, worry about the HFOV - the horizontal field of view. How much of our circle do we want the image to take up? I chose 50 degrees. 360 is stretched all the way around, 180 is half, 90 is a quarter and the smallest FOV that we can expect a 360 playback viewer to show to us. I want my image to take up about half of the available screen space, so I chose 50. With YouTube's 360 player showing us a 105-degree field of view, and 90 being the minimum, 50 is a nice round number that will amount to about half of the visible screen real estate, leaving our title card readable, although perhaps a little small.

If we make it to big, it will effectively be like the viewer is standing extremely close to a wall with a big poster on it. They will have to really look around, and the perspective distortion will be noticeable. I believe it's better to keep things smaller, at the risk of a viewer not 'finding' the title. We can always repeat it around the frame, or still employ the tricks I talked about last time, such as using a gradient).

We also can easily adjust this later, after we test it out.

Layout

Next, select the Projection tab. We don't need to worry about Preview or Layout. We want to change the field of view (of our final image) to 360x180, and keep the projection mode at equirectangular. By default, our image is in the center of everything, which is what we want.

A Full Equirectangular Frame.

Why 360x180?

360x180 is full coverage. 360 degrees around, 180 pole to pole, covers an entire sphere. In other words, we are asking for a complete equirectangular image. The final image will have a 2:1 aspect ratio, and we can easily drop it into our video project without having to line anything up. Thus we can be sure our title will be pixel-perfect without any additional effort.

Advanced View

If you go back to the Assistant tab, the 2. Align and 3. Create Panorama buttons are gray and unclickable. Oh no! This is because we only have one image, so we can't stitch anything together! Don't worry, we can get around this 'helpful' feature.

At the top of the window, click on the Interface drop-down menu item, then click on Advanced (or Expert).

We're experts!

A new window opens. Now, all we have to do is click on the Output drop-down menu, then select Stitch, or just hit Crtrl+i on your keyboard. Great! Now we can and "stitch" the image, creating our final equirectangular version. This will get saved as a nice large high-quality tiff file. It has transparency, so it's perfect for dropping on our final video file.

Our Final Image

I would show you what this looks like in a 360 video player, but, like the grid above, it just looks like the title we started with.

Adjusting The Cards

We can repeat the card in our video editing software, by copying the layer and using the offset filter. This will work so long as we don't repeat the card vertically, only offsetting it horizontally. We can also do this in Photoshop, or any image editing software, if we just want to deal with a single image for the titles. So long as the image only gets shifted on the horizontal axis, it will be fine. What will change is the apparent angle that the 'flat' image is at around the sphere.

If we want to get fancier, and have cards not on the horizon (equator) axis, we can do this in the Move/Drag tab in Hugin.

If I feel this card is too small, and I want to make it larger. I can't do this in the video editing software, we have to go back to Hugin. We don't have to re-load or start from scratch, just change the image focal length setting in the Assistant tab. This title is with a 12mm focal length, although I did have some transparency on either side of my image originally.

Larger Final Image

That's It

That's all it takes to pre-warp an image so it appears as a flat plane in 360 video.