Skip to content

Commit

Permalink
Update PerfectPerspective.fx
Browse files Browse the repository at this point in the history
Changed name to Aximorphic for the perspective (including preprocessor) as axomorpic had already different meaning.

PLEASE UPDATE YOUR PRESETS
  • Loading branch information
Fubaxiusz committed Feb 8, 2024
1 parent c83190d commit 7a2175f
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions Shaders/PerfectPerspective.fx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* >> Description << */

/* Perfect Perspective PS (version 5.8.8)
/* Perfect Perspective PS (version 5.8.9)
Copyright:
This code © 2018-2023 Jakub Maksymilian Fober
Expand Down Expand Up @@ -45,7 +45,7 @@ and
arXiv:2010.04077 [cs.GR] (2020)
https://arxiv.org/abs/2010.04077
and
Axomorphic Perspective Projection Model for Immersive Imagery
Aximorphic Perspective Projection Model for Immersive Imagery
arXiv:2102.12682 [cs.GR] (2021)
https://arxiv.org/abs/2102.12682
by Fober, J. M.
Expand All @@ -56,8 +56,8 @@ by Fober, J. M.
/* Alternative to anamorphic.
1 gives separate distortion option for vertical axis.
2 gives separate option for top and bottom half. */
#ifndef AXOMORPHIC_MODE
#define AXOMORPHIC_MODE 1
#ifndef AXIMORPHIC_MODE
#define AXIMORPHIC_MODE 1
#endif

/* >> Commons << */
Expand Down Expand Up @@ -100,7 +100,7 @@ uniform uint FovType
" choose 'vertical' or '4:3'. For ultra-wide display\n"
" you may want '16:9' instead.\n"
"\n"
#if AXOMORPHIC_MODE
#if AXIMORPHIC_MODE
" This method only works with all k = 0.5.";
#else
" This method only works with k = 0.5 and s = 1.0.";
Expand All @@ -115,7 +115,7 @@ uniform uint FovType

// Perspective

#if AXOMORPHIC_MODE>=2 // vertical axis projection is driven by separate ky top and ky bottom parameter
#if AXIMORPHIC_MODE>=2 // vertical axis projection is driven by separate ky top and ky bottom parameter
uniform float Ky
< __UNIFORM_SLIDER_FLOAT1
ui_category = "Distortion";
Expand Down Expand Up @@ -144,11 +144,11 @@ uniform float Ky
uniform float K
< __UNIFORM_SLIDER_FLOAT1
ui_category = "Distortion";
#if AXOMORPHIC_MODE==1
#if AXIMORPHIC_MODE==1
ui_category_closed = true;
ui_text = "(brightness[-1], distances[-0.5], speed[0], shapes[0.5], straight-lines[1])";
#endif
#if AXOMORPHIC_MODE // k indicates horizontal axis projection type
#if AXIMORPHIC_MODE // k indicates horizontal axis projection type
ui_label = "Projection type 'k' horizontal";
ui_tooltip = "Projection coefficient 'k' horizontal, represents\n"
#else // k represents whole picture projection type
Expand All @@ -172,7 +172,7 @@ uniform float K
ui_min = -1f; ui_max = 1f; ui_step = 0.01;
> = 0.5;

#if AXOMORPHIC_MODE==1 // vertical axis projection is driven by separate k parameter
#if AXIMORPHIC_MODE==1 // vertical axis projection is driven by separate k parameter
uniform float Ky
< __UNIFORM_SLIDER_FLOAT1
ui_category = "Distortion";
Expand All @@ -194,7 +194,7 @@ uniform float Ky
ui_min = -1f; ui_max = 1f; ui_step = 0.01;
> = 0.5;

#elif AXOMORPHIC_MODE>=2 // vertical axis projection is driven by separate ky top and ky bottom parameter
#elif AXIMORPHIC_MODE>=2 // vertical axis projection is driven by separate ky top and ky bottom parameter
uniform float KyA
< __UNIFORM_SLIDER_FLOAT1
ui_category = "Distortion";
Expand Down Expand Up @@ -515,7 +515,7 @@ float get_theta(float radius, float rcp_f, float k) // get spherical θ angle
}
float get_vignette(float theta, float r, float rcp_f) // get vignetting mask in linear color space
{ return sin(theta)/(r*rcp_f); }
float2 get_phi_weights(float2 viewCoord) // get axomorphic interpolation weights
float2 get_phi_weights(float2 viewCoord) // get aximorphic interpolation weights
{
viewCoord *= viewCoord; // squared vector coordinates
return viewCoord/(viewCoord.x+viewCoord.y); // [cos²φ sin²φ] vector
Expand All @@ -539,8 +539,8 @@ float getRadiusOfOmega(float2 viewProportions)
}
}

#if AXOMORPHIC_MODE==1
// Search for corner point radius at diagonal Ω in Axomorphic perspective
#if AXIMORPHIC_MODE==1
// Search for corner point radius at diagonal Ω in Aximorphic perspective
float binarySearchCorner(float halfOmega, float radiusOfOmega, float rcp_focal)
{
float croppingDigonal = 0.5;
Expand All @@ -566,8 +566,8 @@ float binarySearchCorner(float halfOmega, float radiusOfOmega, float rcp_focal)

return croppingDigonal;
}
#elif AXOMORPHIC_MODE>=2
// Search for corner point radius at diagonal Ω in Axomorphic asymmetrical perspective
#elif AXIMORPHIC_MODE>=2
// Search for corner point radius at diagonal Ω in Aximorphic asymmetrical perspective
float2 binarySearchCorner(float halfOmega, float radiusOfOmega, float rcp_focal)
{
float2 croppingDigonal = 0.5;
Expand Down Expand Up @@ -812,7 +812,7 @@ void PerfectPerspectiveVS(
const static float croppingHorizontal = get_radius(
atan(tan(halfOmega)/radiusOfOmega*viewProportions.x),
rcp_focal, K)/viewProportions.x;
#if AXOMORPHIC_MODE==1
#if AXIMORPHIC_MODE==1
// Vertical point radius
const static float croppingVertical = get_radius(
atan(tan(halfOmega)/radiusOfOmega*viewProportions.y),
Expand All @@ -826,7 +826,7 @@ void PerfectPerspectiveVS(
const static float croppedCircle = min(croppingHorizontal, croppingVertical);
// Full-frame
const static float fullFrame = croppingDigonal;
#elif AXOMORPHIC_MODE>=2
#elif AXIMORPHIC_MODE>=2
// Vertical point radius
const static float2 croppingVertical = float2(
get_radius(
Expand Down Expand Up @@ -895,9 +895,9 @@ float3 PerfectPerspectivePS(
//----------------------------------------------
// begin distortion mapping bypass

#if AXOMORPHIC_MODE==1 // take vertical k factor into account
#if AXIMORPHIC_MODE==1 // take vertical k factor into account
if (FovAngle==0u || (K==1f && Ky==1f && !UseVignette))
#elif AXOMORPHIC_MODE>=2 // take both vertical k factors into account
#elif AXIMORPHIC_MODE>=2 // take both vertical k factors into account
if (FovAngle==0u || (K==1f && Ky==1f && KyA==1f && !UseVignette))
#else // consider only global k
if (FovAngle==0u || (K==1f && !UseVignette))
Expand Down Expand Up @@ -957,7 +957,7 @@ float3 PerfectPerspectivePS(
const static float rcp_focal = get_rcp_focal(halfOmega, radiusOfOmega, K);

// Image radius
#if AXOMORPHIC_MODE // simple length function for radius
#if AXIMORPHIC_MODE // simple length function for radius
float radius = length(viewCoord);
#else // derive radius from anamorphic coordinates
float radius = S==1f
Expand All @@ -966,15 +966,15 @@ float3 PerfectPerspectivePS(
float rcp_radius = rsqrt(radius); radius = sqrt(radius);
#endif

#if AXOMORPHIC_MODE // derive θ angle from two distinct projections
// Axomorphic interpolation weights
#if AXIMORPHIC_MODE // derive θ angle from two distinct projections
// Aximorphic interpolation weights
float2 phiMtx = get_phi_weights(viewCoord);
// Horizontal and vertical incident angle
float2 theta2 = float2(
get_theta(radius, rcp_focal, K),
#if AXOMORPHIC_MODE==1
#if AXIMORPHIC_MODE==1
get_theta(radius, rcp_focal, Ky)
#elif AXOMORPHIC_MODE>=2
#elif AXIMORPHIC_MODE>=2
get_theta(radius, rcp_focal, viewCoord.y>=0f ? KyA : Ky)
#endif
);
Expand All @@ -983,7 +983,7 @@ float3 PerfectPerspectivePS(
get_vignette(theta2.x, radius, rcp_focal),
get_vignette(theta2.y, radius, rcp_focal)))+VignetteOffset
: 1f;
float theta = dot(phiMtx, theta2); // axomorphic incident
float theta = dot(phiMtx, theta2); // aximorphic incident
#else // get θ from anamorphic radius
float theta = get_theta(radius, rcp_focal, K);
float vignette;
Expand All @@ -1004,7 +1004,7 @@ float3 PerfectPerspectivePS(
#endif

// Rectilinear perspective transformation
#if AXOMORPHIC_MODE // simple rectilinear transformation
#if AXIMORPHIC_MODE // simple rectilinear transformation
viewCoord = tan(theta)*normalize(viewCoord);
#else // normalize by anamorphic radius
viewCoord *= tan(theta)*rcp_radius;
Expand All @@ -1023,9 +1023,9 @@ float3 PerfectPerspectivePS(
// Sample display image
float3 display =
K!=1f
#if AXOMORPHIC_MODE==1 // take vertical k factor into account
#if AXIMORPHIC_MODE==1 // take vertical k factor into account
|| Ky!=1f
#elif AXOMORPHIC_MODE>=2 // take both vertical k factors into account
#elif AXIMORPHIC_MODE>=2 // take both vertical k factors into account
|| Ky!=1f || KyA!=1f
#endif // consider only global k
? tex2D(BackBuffer, texCoord).rgb // perspective projection lookup
Expand All @@ -1048,9 +1048,9 @@ float3 PerfectPerspectivePS(

// Display border
if (
#if AXOMORPHIC_MODE==1 // take vertical k factor into account
#if AXIMORPHIC_MODE==1 // take vertical k factor into account
(K!=1f || Ky!=1f)
#elif AXOMORPHIC_MODE>=2 // take both vertical k factors into account
#elif AXIMORPHIC_MODE>=2 // take both vertical k factors into account
(K!=1f || Ky!=1f || KyA!=1f)
#else // consider only global k
K!=1f
Expand Down Expand Up @@ -1087,14 +1087,14 @@ float3 PerfectPerspectivePS(

technique PerfectPerspective
<
ui_label = "Perfect Perspective (fisheye, anamorphic, axomorphic)";
ui_label = "Perfect Perspective (fisheye, anamorphic, aximorphic)";
ui_tooltip =
"Adjust perspective for distortion-free picture:\n"
"\n"
" · Fish-eye\n"
" · Panini\n"
" · Axomorphic (*)\n"
" · Axomorphic asymmetrical (**)\n"
" · Aximorphic (*)\n"
" · Aximorphic asymmetrical (**)\n"
" · Anamorphic\n"
" · Vignetting (natural)\n"
"\n"
Expand All @@ -1103,15 +1103,15 @@ technique PerfectPerspective
" 1# select proper FoV angle and type. If FoV type is unknown,\n"
" find a round object within the game and look at it upfront,\n"
" then rotate the camera so that the object is in the corner.\n"
#if AXOMORPHIC_MODE
#if AXIMORPHIC_MODE
" Make sure all 'k' parameters are equal 0.5 and adjust FoV type such that\n"
#else
" Set 'k' to 0.5, change squeeze factor to 1x and adjust FoV type such that\n"
#endif
" the object does not have an egg shape, but a perfect round shape.\n"
"\n"
" 2# adjust perspective type according to game-play style.\n"
#if AXOMORPHIC_MODE
#if AXIMORPHIC_MODE
" If you look mostly at the horizon, 'k.y' can be increased.\n"
#else
" If you look mostly at the horizon, anamorphic squeeze can be increased.\n"
Expand All @@ -1127,7 +1127,7 @@ technique PerfectPerspective
" 5# additionally for sharp image, use sharpening FX or run game at a\n"
" Super-Resolution. Debug options can help you find the proper value.\n"
"\n"
" (*) for more available settings set AXOMORPHIC_MODE value to 0, 1 or 2.\n"
" (*) for more available settings set AXIMORPHIC_MODE value to 0, 1 or 2.\n"
"\n"
"\n"
"The algorithm is part of a scientific article:\n"
Expand Down

0 comments on commit 7a2175f

Please sign in to comment.