Welcome, Guest.
Username: Password: Remember me

TOPIC: distortion correction - conformal perspective

distortion correction - conformal perspective 4 months 3 weeks ago #1

Linear perspective was designed by painters in 15th century to reproduce sill images on a canvas.
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.
GitHub
If you want to buy me a coffee, donate :)
Last Edit: 4 months 3 weeks ago by Fu-Bama. Reason: info on official package
The administrator has disabled public write access.
The following user(s) said Thank You: Marty McFly, brussell, Rudy102, turgor128

distortion correction - conformal perspective 4 months 3 weeks ago #2

Good idea, but the stereographic distorsion isn't perfect too :D
NOLF2+4:3 resolution, looking below:



See the curved wood plank :P
Last Edit: 4 months 3 weeks ago by lowenz.
The administrator has disabled public write access.

distortion correction - conformal perspective 4 months 3 weeks ago #3

It's not perfect, there always will be some sacrifice since creating image of a 3D world is representing portion of a sphere onto flat monitor plane.
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.

:P hint
do these streets cross at a right angle or at an acute angle?

example of not preserving angles



example of not preserving proportions (RAGE)
GitHub
If you want to buy me a coffee, donate :)
Last Edit: 4 months 3 weeks ago by Fu-Bama.
The administrator has disabled public write access.

distortion correction - conformal perspective 4 months 3 weeks ago #4

Stereographic perspective preserves angles and proportions, but horizontal and vertical lines are not straight. For motion picture, motion is even in every part of the screen, thus every part of the image is equally important.




The biggest difference is in the movement. But you have to put right FOV in shader settings.
GitHub
If you want to buy me a coffee, donate :)
The administrator has disabled public write access.

distortion correction - conformal perspective 4 months 3 weeks ago #5

I bet you know this movie ;)
Warning: Spoiler! [ Click to expand ]
GitHub
If you want to buy me a coffee, donate :)
Last Edit: 4 months 3 weeks ago by Fu-Bama.
The administrator has disabled public write access.

distortion correction - conformal perspective 4 months 3 weeks ago #6

I know I know :D

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 ;)
Last Edit: 4 months 3 weeks ago by lowenz.
The administrator has disabled public write access.

distortion correction - conformal perspective 4 months 3 weeks ago #7

I know your intention :)
You have good point. I posted informations so that everyone can learn something about the topic. ;)
GitHub
If you want to buy me a coffee, donate :)
The administrator has disabled public write access.

distortion correction - conformal perspective 4 months 3 weeks ago #8

Stuff is nice, but the drawback of it is that the shared blurs the image a bit, I think its because of added distortion.
The administrator has disabled public write access.

distortion correction - conformal perspective 4 months 3 weeks ago #9

Blurring?

This is a linear perspective (that's the one who causes *geometric* distortion) alternative.
Last Edit: 4 months 3 weeks ago by lowenz.
The administrator has disabled public write access.

distortion correction - conformal perspective 4 months 3 weeks ago #10

Yup, blurring. The shader zooms the picture, so it gets blurred.
The administrator has disabled public write access.

distortion correction - conformal perspective 4 months 3 weeks ago #11

Interesting. So, uh, when do we use a shader like this?

Just FPS games? and what are the pros/cons?
The administrator has disabled public write access.

distortion correction - conformal perspective 4 months 3 weeks ago #12

  • Marty McFly
  • Marty McFly's Avatar
  • Offline
  • We've tried nothing and we're all out of ideas!
You could apply automatic zoom to perfectly cover the screen corners. Separately compute scaling amount for screen corner and scale texcoord by before/after ratio.
The administrator has disabled public write access.

distortion correction - conformal perspective 4 months 3 weeks ago #13

Martigen wrote:
Interesting. So, uh, when do we use a shader like this?

Just FPS games? and what are the pros/cons?
Every "hi-FOV" game, 'cause the high FOV introduces an heavy perspective distortion @borders.
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 :D)
Last Edit: 4 months 3 weeks ago by lowenz.
The administrator has disabled public write access.

distortion correction - conformal perspective 4 months 3 weeks ago #14

DOOM 2016 - "Hi-FOV" game, FOV is set in game, by default, to 90 degrees. Three galleries with this shader :

DOOM 01
DOOM 02
DOOM 03

Dzięki wielkie :)
Last Edit: 4 months 3 weeks ago by Rudy102.
The administrator has disabled public write access.
The following user(s) said Thank You: jas01, turgor128

distortion correction - conformal perspective 4 months 3 weeks ago #15

@WSH303, it blurs the image a bit in two out of 3 modes; Horizontal (when borders are touching right and left edge of the screen) and Diagonal (when image fills the screen without borders; this is kind of mode that @Marty McFly mentions). But in Vertical mode image gets contracted, thus more sharp, showing whole field of view, but with the biggest borders. Use Luma Sharpen fx form base effects, it does the trick.
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 :cheer:
GitHub
If you want to buy me a coffee, donate :)
The administrator has disabled public write access.

distortion correction - conformal perspective 4 months 3 weeks ago #16

Boy,i've never needed this shader until i tested it.

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.
The administrator has disabled public write access.

distortion correction - conformal perspective 4 months 3 weeks ago #17

lowenz wrote:
Martigen wrote:
Interesting. So, uh, when do we use a shader like this?

Just FPS games? and what are the pros/cons?
Every "hi-FOV" game, 'cause the high FOV introduces an heavy perspective distortion @borders.
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 :D)
I've got a 21:9 so, yeah, some games are quite 'wide' :)

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.
The administrator has disabled public write access.

distortion correction - conformal perspective 4 months 3 weeks ago #18

The bending is a necessary consequence of the maths :D

It's a *correction* technique (with its side effects).
Last Edit: 4 months 3 weeks ago by lowenz.
The administrator has disabled public write access.

distortion correction - conformal perspective 4 months 3 weeks ago #19

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.

Otherwise this link or table may come in handy:
*edit
New version has drop down menu to choose what kind of FOV is used in-game (horizontal/diagonal/vertical)

themetalmuncher.github.io/fov-calc/

Warning: Spoiler! [ Click to expand ]

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. Diagonal 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:
Warning: Spoiler! [ Click to expand ]
GitHub
If you want to buy me a coffee, donate :)
Last Edit: 4 months 1 week ago by Fu-Bama.
The administrator has disabled public write access.
The following user(s) said Thank You: Rudy102

distortion correction - conformal perspective 4 months 2 weeks ago #20

Thanks Fu-Bama.

This is a really awesome shader :) Just one problem: as it bends the whole screen, when interacting with in-game menus or game inventories the visible button for a is of course now off-center, making it sometimes impossible to use menus or inventories, as where you click for the corrected perspective is of course not where the game is needing to register the click on screen. It can't be helped really, as we're bending the image without considering the interface.

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!
The administrator has disabled public write access.