distortion correction - conformal perspective
- Fu-Bama
-
Topic Author
Interestingly, people of those times described linear perspective as an Italian stylization, as they did not
seen it realistic. Noticeably, even its first practitioners (e.g. Piero Della Francesca) reported that it leads
to numerous, incommodious distortions in the image, especially when a larger angle of view is
required. Leonardo da Vinci, after some unsuccessful attempts at solving this problem, decided that
composition should be fitted in a relatively narrow angle of view.
Linear Projection is mathematically limited to 179° camera view. There is no tangent of 90°.
But human eye can see the world at 180° or more. If you stretch your hands sideways, in a well lit room, you
should be able to see your fingers moving in your peripheral vision.
But at 179° linear perspective distorts image to such extent that it’s unrecognizable, objects are
distorted towards infinity in the center of the screen. Appearance of distortion is even bigger when
a wide angle picture is in motion. Driven by this distortion, a motion-sickness effect appears.
What technique should be used instead? Perfect solution would be as less distracting as possible, so
viewer attention would focus on presented virtual world space, rather then the image appearance.
One kind of perspective provides such sensation, a stereographic perspective.
It has most natural appearing motion, it preserves angles and proportions.
What it means is that face in the corner of the screen doesn't get stretched, due to conformal nature of this perspective.
Shader that I'm presenting here transforms linear perspective image to stereographic.
I can't imagine going back to old perspective.
github.com/Fubaxiusz/reshade-shaders/blo...erfectPerspective.fx
*edit
Perfect Perspective is now part of the official shaders package. Just download reshade-shaders when prompted.
Please Log in or Create an account to join the conversation.
- lowenz
-

NOLF2+4:3 resolution, looking below:

See the curved wood plank

Please Log in or Create an account to join the conversation.
Same issues apply to map making. Linear perspective in cartography is known as Gnomonic projection. It preserves distances, one can draw straight line with ruler and it will be shortest path from point A to B. But you sacrifice proportions and angles. For motion picture it adds artificial movement to the edges of the screen, thus driving eyes there instead to center of the screen where crosshair is.

do these streets cross at a right angle or at an acute angle?
example of not preserving angles
example of not preserving proportions (RAGE)
Please Log in or Create an account to join the conversation.
The biggest difference is in the movement. But you have to put right FOV in shader settings.
Please Log in or Create an account to join the conversation.

Please Log in or Create an account to join the conversation.
- lowenz
-

My intension was only to show the limit of this kind of perspective, so a ReShade user can see the main (absolutely natural) issue of it

Please Log in or Create an account to join the conversation.

You have good point. I posted informations so that everyone can learn something about the topic.

Please Log in or Create an account to join the conversation.
- WSH303
-
Please Log in or Create an account to join the conversation.
- lowenz
-
This is a linear perspective (that's the one who causes *geometric* distortion) alternative.
Please Log in or Create an account to join the conversation.
- WSH303
-
Please Log in or Create an account to join the conversation.
- Martigen
-
Just FPS games? and what are the pros/cons?
Please Log in or Create an account to join the conversation.
- Marty McFly
-
Please Log in or Create an account to join the conversation.
- lowenz
-
Every "hi-FOV" game, 'cause the high FOV introduces an heavy perspective distortion @borders.Martigen wrote: Interesting. So, uh, when do we use a shader like this?
Just FPS games? and what are the pros/cons?
It's why today we use a narrow-ER FOV on widescreen resolutions too (67° vs 90° of 'the 90s and their good old 4:3 resolutions

Please Log in or Create an account to join the conversation.
- Rudy102
-
DOOM 01
DOOM 02
DOOM 03
Dzięki wielkie

Please Log in or Create an account to join the conversation.
You can see what the shader does by dragging the Strength slider in the configurator.
@Martigen, @lowenz has good point. FPP, TPP games tend to have high-fov and a lot of movement.
It also works with some sculpting or modeling software, when you need nail the proportions.
@Rudy102 Nice Doom gallery

Please Log in or Create an account to join the conversation.
Decided to put it in test on Quake (Which suffers a lot from the high fov, especially for me that plays in 100 for more view of the stuff around), and when i used that, it felt like i got more view of the stuff around without the distortion of the 100 fov.
Nice work on it, its a small shader that makes a difference.
Please Log in or Create an account to join the conversation.
- Martigen
-
I've got a 21:9 so, yeah, some games are quite 'wide'lowenz wrote:
Every "hi-FOV" game, 'cause the high FOV introduces an heavy perspective distortion @borders.Martigen wrote: Interesting. So, uh, when do we use a shader like this?
Just FPS games? and what are the pros/cons?
It's why today we use a narrow-ER FOV on widescreen resolutions too (67° vs 90° of 'the 90s and their good old 4:3 resolutions)

So this is a good shader especially for playing first-person games on widesreen? Should you set the in-game FOV or or lower as a result of using this shader?
I did try it out, the change in perspective was... different. But the edges had black corners where the image was bent in and left empty space.
Please Log in or Create an account to join the conversation.
- lowenz
-

It's a *correction* technique (with its side effects).
Please Log in or Create an account to join the conversation.
Martigen wrote: Should you set the in-game FOV or or lower as a result of using this shader?
Shader FOV setting should mach your in-game horizontal FOV. Some games provide option to adjust FOV angle and sometimes it's vertical FOV (Battlefield) or diagonal (RAGE) and sometimes it's weird value (MIND: Path to Thalamus Enhanced Edition).
Basically if you see mustache-like bulging of the image, while moving the camera, Shader FOV is too high.
If image looks right, but spherical objects at the corners of the screen get stretched, Shader FOV is too low.
Right setting should give smooth barrel bending and preserve proportions at the corners.
Skyrim has horizontal FOV setting and looks right if you want to check some reference.
[strike]Otherwise this link or table may come in handy:[/strike]
*edit
New version has drop down menu to choose what kind of FOV is used in-game (horizontal/diagonal/vertical)
[strike] themetalmuncher.github.io/fov-calc/ [/strike]
Martigen wrote: I did try it out, the change in perspective was... different. But the edges had black corners where the image was bent in and left empty space.
Perfect Perspective FX has drop down menu where you can choose 3 modes. [strike]Diagonal[/strike] aligns the image to the corners of the screen, leaving no black space.
*edit
New update setting is more descriptive and shows options "Optimal Borders", "No Borders", "Full View".
PS:
To test your 21:9 setup I wrote simple letterboxing.fx, some can find it useful:
// Letterboxing PS
////////////////////
/////// MENU ///////
////////////////////
uniform float3 Color <
ui_label = "Bars Color";
ui_type = "Color";
> = float3(0.027, 0.027, 0.027);
uniform float UserAspect <
ui_label = "Aspect Ratio";
ui_tooltip = "Desired Aspect Ratio Float";
ui_type = "drag";
ui_min = 1.0; ui_max = 3.0;
> = 2.4;
//////////////////////
/////// SHADER ///////
//////////////////////
#include "ReShade.fxh"
float3 LetterboxingPS(float4 vois : SV_Position, float2 texcoord : TexCoord) : SV_Target
{
// Get Aspect Ratio
float RealAspect = ReShade::AspectRatio;
// Get Bars width
float Bars = (1.0 - RealAspect / UserAspect) * 0.5;
// Sample display image
float3 Display = tex2D(ReShade::BackBuffer, texcoord).rgb;
// Mask out outside-border pixels
if (RealAspect == UserAspect)
{
return Display;
}
else if (RealAspect < UserAspect && texcoord.y < 1.0 - Bars && texcoord.y > Bars)
{
return Display;
}
else if (RealAspect > UserAspect && texcoord.x < 1.0 + Bars * 0.5 && texcoord.x > -0.5 * Bars)
{
return Display;
}
else
{
return Color;
}
}
technique Letterboxing
{
pass
{
VertexShader = PostProcessVS;
PixelShader = LetterboxingPS;
}
}
Please Log in or Create an account to join the conversation.
- Martigen
-
This is a really awesome shader

But I have a suggested solution: If you can read keyboard input, allow the user to set say up to three 'Inventory' or 'menu' keys. Three or so should account for different menus/inventory options in a game. When these keys are pressed and in-game for example the inventory pops up, the StereoGraphic shader disables itself. Pressing it again enables it. So it's a toggle, just like assigning a key to the shader itself -- but this is limited to one key, hence providing more options. Eg for the game Subnautica, I'd assign 'Esc' for the menus and 'Tab' for the inventory, and pressing either toggles the shader off and then back on again when the key is pressed to close the menu/inventory. It won't always be perfect, many UI elements can be exited in more than one way, but if you remember to always use the same key it will appear seamless.
Anyway, just an idea!
Please Log in or Create an account to join the conversation.