Projection Correction

Some time ago I had to take a bunch of screenshots of the TTS VR for advertising purposes.
They needed a lot of screenshot for various formats (web banners, magazines, …),
so they tend to recrop the screenshots I send them a lot, depending on the need and space,
because of that I have to add some extra space outside of the actual screenshots, which I simply do by increasing the fov of the camera I render the screenshots with.

The thing is though, that the higher the fov, the more perspective distortion you get away from the center.
(a logical result for a projection of a 3d space onto flat plane)
This isn’t essentially a bad thing though, it’s actually correct, if the image is viewed from straight in front of the center, and at the right distance, so it’s looked at with the same angular size as the image was made (the fov).

The problem, is that these screenshots sometimes get cropped in extreme ways, by which I mean, far to one side, moving focus away from the center.
This causes the image to look strange, as the content is skewed and stretched.

So I decided to make something to counter that.

I figured that if the 2d space that was projected on was a spherical shell instead of a flat plane, there would be no distortion.
A spherical shell however can not be mapped to a flat plane without distortion (obviously, just look at maps of the earth),
but, a cylindrical shell totally can.

So, using math and logic (whoo) I created a post effect that manipulates the image as if it was projected on a cylinder (with either a horizontal or a vertical axis), and then unfolded.

This way it can make sure there is no distortion either horizontally, or vertically, depending on whether the image is in landscape or portrait.
Because of this, you can move focus in this direction (horizontal or vertical), without it looking off.
A side effect of this is that you can easily stitch together screenshots made by rotating around the cylinder-axis.

rendered with projection correctionAn extreme example, the horizontal fov is more than 200 degrees, this isn’t even possible with normal rendering (only <180 degrees).

FullCorrection

There are a few setbacks however,
firstly, unlike normally (projecting on a flat plane), not all straight lines (in 3D) are straight in the image, some are curved,
secondly, a lot of space is wasted in the image (the black parts), because of the extra cylinder-mapping, which means you have to render at a higher resolution for the same detail.
and lastly (and definately least), there is no filtering done in the cylinder-mapping, so the result can be a bit jaggy (and moreso the bigger the fov is).

I also made a second mode, which is a bit simpler and less extreme,
as it only streches 1 of the axes, just so proportions look correcter. This one is actually more difficult to explain, just look at the pictures.

SimpleCorrection

I’ve made this post effect available for free on the Unity Asset Store:

https://www.assetstore.unity3d.com/#/content/9882

It requires a Unity Pro license in order to work though.

Advertisements

4 thoughts on “Projection Correction

  1. Can you make 6 viewports, render each to texture, combine textures into a different type of projection (cylindrical, fisheye, Mercator, equirectangular 360 or whatever else)?

    • @Iwan kelaiah:
      There’s only this (free) version.
      I suppose you’re referring to the screenshot where I state the fov is greater than 200?
      That one was actually 2 screenshots combined, my point there wasn’t that my plugin allowed for fov higher than 180, but that theoretically projecting on a cylinder allowed for a fov higher than 180, whereas that is not even theoretically possible when projecting on a plane.
      However, my plugin simulates projecting on a cylinder by sampling from a normal plane projection, causing this limitation to still exist for this plugin. However, this can easily be faked by combining 2 shots (without having to distort these images, unlike with normal rendering).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s