Jump to content
Sign in to follow this  
denali

Multi-monitor (dual, triple, etc) Stretch/Fisheye Distortion Fix

Recommended Posts

I've already noted that the fmxl file needs to have an entry as well.  The number doesn't have to match, just the GUID.  just add it to the end of your camera.1.# list.  I'll be checking with the install which number is next in both files.

I don't yet understand how, after adding a camera to camera.cfg, a view shows up on the context menu, but does not seem to hold it's FOV until it's added to <situation>.fxml  .  Do you have any thoughts about that?  I think the menu system is quite quirky; I can't click anything in menus when in full screen.  Based on the font and the grainyness it looks custom rather than winAPI menus.   For views especially there is something not connecting in the FOV stuff.

Share this post


Link to post

 

 


so 1 of the aircraft.cfg-cams already has got nr 019.
 I see.  So I probably need to check here for the aircraft of the default flight.  What about when other aircraft are loaded.  Like I said, don't have a good sense of the logic of that are yet.

Share this post


Link to post

What I plan to do is load up 1 camera in the camera.cfg, and do whatever I need to do elsewhere, so a menu item for the view comes up on the context menu.  It'll be just for the current default scenario.  

Share this post


Link to post

 

I don't yet understand how, after adding a camera to camera.cfg, a view shows up on the context menu, but does not seem to hold it's FOV until it's added to <situation>.fxml  .  Do you have any thoughts about that?

 

Looks like P3D`s own fov-calculator is running when changing flights, probably because the flight is not set to have a sticky FOV.

(btw FOV and the zoom function seem to be very much linked to eachother.)

Probably best to only focus on to create new flights with the perspective correction in it.

 

Are you sure you have the right definitions for the camera.cfg (ObserverVerticalFOV, ObserverHorizontalFOV) ???

 

 

 I see.  So I probably need to check here for the aircraft of the default flight.  What about when other aircraft are loaded.  Like I said, don't have a good sense of the logic of that are yet.

 

I mean that the cams from the aircraft.cfg get the nrs after the "0.18-cam" that comes from the cameras.cfg, after they get injected in the savedflight.fxml.

(so just using a very high nr should be safe enough.)

Share this post


Link to post

 

 


Are you sure you have the right definitions for the camera.cfg (ObserverVerticalFOV, ObserverHorizontalFOV) ???
 They are the only FOV variables I could find.

 

 


(so just using a very high nr should be safe enough.)

 This is not good practice; I'm going to try to respect the logic the ESP team used.  That's why I'm holding on to my uncertainty for how it works, until I'm sure of it.

Another reason why I wonder if the menus are custom, it breaks the VirtuMVP software.  Whenever I try it P3D crashes if I use a menu.


 

 


Would it work with FSX or is it a P3D thing only?
 P3D only.  FSX didn't allow one to load a postprocess.  It may be possible to hijack an existing postprocess, but I don't have FSX loaded anymore to try it.  See what happens if you replace one of the psh files in the postprocess folder.

I don't care for FSX.  It's junk.

Share this post


Link to post

 

 

 They are the only FOV variables I could find.

 

 

 This is not good practice; I'm going to try to respect the logic the ESP team used.  That's why I'm holding on to my uncertainty for how it works, until I'm sure of it.

Another reason why I wonder if the menus are custom, it breaks the VirtuMVP software.  Whenever I try it P3D crashes if I use a menu.

 

 

They seem to be working pretty decently actually.

 

After creating a couple of new flights with the scenario window, the FOV`s were correctly loaded every time.

(This way there probably is also no need to make it nr .91, but just the next available one as you first suggested)

 

It just doesn`t automatically work with flights that already existed before your shader/settings were used, with those you would need to manually add the fovsettings to the savedflight.fxml

Share this post


Link to post

 

 


It just doesn`t automatically work with flights that already existed before your shader/settings were used

Thanks for this.  Thats a good clue.  I wonder if I plug it into the default scenario (or if there is a default template somewhere) if that will help it show for new scenarios.

Share this post


Link to post

Got it going, but unfortunately on a large projected screen the image is too blury/grainy.

 

Thanks for your efforts!

 

Nat

Share this post


Link to post

NatVis, give it another shot later, when I get some of the resolution issues figured out.  You may like the next iteration with a slightly lower FOV.  But I have a few tricks to try later if that doesn't satisfy.  Also, there may be no anti-aliasing happening with the view you saw just yet.  Thanks much for trying.

Share this post


Link to post

OK Thanks.

 

I could only get the UFO shape type image, even with the Prepar3D Views.exe (?)

 

 

Nat

Share this post


Link to post

<codemonkey.grunt>Struggled much of the night to get some old xmlDoc code switched from an old defunct custom class to MS's classes.  Couldn't for the life of me figure out what why my selections wouldn't work, til I understood I was using the wrong DOM.  </codemonkey.grunt> lame.  Moving along now.

Share this post


Link to post

Hi,

 

I've been reading along and I would like to give this a try, Do I Have The Steps Correct?


============================
Prepar3D Multi-Monitor Fisheye Fix
============================

--------
Part 1
--------

Start Copy and Past at line - <SimBase.Document Type="AceXML" version="1,0">



<SimBase.Document Type="AceXML" version="1,0">
 
    <PostProcessEffects.PostProcessDefinition>
        <EffectName>AS01</EffectName>
        <ShaderFileName>AS01.psh</ShaderFileName>
        <ShaderEntryPoint>PsAntiStretchMain</ShaderEntryPoint>
        <ColorRequest>TRUE</ColorRequest>
        <DepthRequest>FALSE</DepthRequest>
    </PostProcessEffects.PostProcessDefinition>
 
</SimBase.Document>



End Copy and Past at line - </SimBase.Document>



Save file as: "AS01.xml" using NOTEPAD (Run Notepad As Administrator) - to save the file,
go to File and select, Save As, Make sure the Save As Type is set at: ALL FILES (*.*)

Save the above file in your: C:\Program Files (x86)\Lockheed Martin\Prepar3D v2\ShadersHLSL\PostProcess   Folder



--------
Part 2
--------

Start Copy and Past at line - // Copyright John Lacquey 2014



// Copyright John Lacquey 2014

#include "Quad.sh"

Texture2D<float4> srcTex;

//static const float PI = 3.14159265f; too much PI is a bad thing

static const float horizontalFOV = 150;
static const float verticalFOV = 70;

// this is not needed at this time
//static const float horizontalRes = 5760;
//static const float verticalRes = 1080;

//
//                   B   
//                  /|
//              / |
//              /  |
//             /   |
//            /    |
//      h    /     |
// hypotenuse /      |a opposite
//         /       |
//        /\       |
//       / Theta   |
//          /____\_____|
//     A       b      C
//          adjacent
//

float4 PsAntiStretchMain(PsQuad vert) : SV_Target
{
// Texture coordinates (0.0 - 1.0)
float X = vert.texcoord.x;
float Y = vert.texcoord.y;

// Texture coordinates normalized to -1.0, 1.0
float normFactor = 0.5f;
float normX = 2 * (X - normFactor);
float normY = 2 * (Y - normFactor);

// Get the source texture dimemsions.
    uint2 uTDim;
    srcTex.GetDimensions(uTDim.x,uTDim.y);

// Get the radians of the new image.  This corresponds to the screen dimensions,
// the spherical rectangle which is the image that we want.
float horizontalFOVRadians_newImageXWidth = radians(horizontalFOV / 2);
float verticalFOVRadians_newImageYHeight = radians(verticalFOV / 2);
float rightAngleRadians = radians(asfloat(90));

// The dimensions of the current distorted image, tangent of FOV Radians,
// the plane tangent to the sphere.
float distortedImageWidth = tan(horizontalFOVRadians_newImageXWidth);
float distortedImageHeight = tan(verticalFOVRadians_newImageYHeight);    

//////
// The ratio of the desired image to the distorted image
// possibly use the inverse of this to clip
float correctXRatio = 1; //(horizontalFOVRadians_newImageXWidth / distortedImageWidth);
float correctYRatio = 1; //(verticalFOVRadians_newImageYHeight / distortedImageHeight);

// Increase the dimensions of the distorted image radian measurement by correct_Ratio
// in order to have more to crop the new image from.
float expandedDistortionWidth = correctXRatio * distortedImageWidth;
float expandedDistortionHeight = correctYRatio * distortedImageHeight;

// normXY will find the radians of the desired pixel.
float horizontalRadiansOfTarget = normX * horizontalFOVRadians_newImageXWidth;
float verticalRadiansOfTarget = normY * verticalFOVRadians_newImageYHeight;

// find the x coordinate for the desired pixel
float targetXPixelRadians_xOfDistortion = tan(horizontalRadiansOfTarget);  // x coordinate of pixel on distortion
float colorU1 = targetXPixelRadians_xOfDistortion / expandedDistortionWidth; // the ratio of the target pixel over

the full distorted dimension radians - to be multiplied by the current image in the final step.
float colorUfinal = colorU1;// * correctXRatio;  // distortion correction

// maintaining all of the color values from the original but distorted image,
// some the y values will reach outside of the rectangular boundings of the original image,
// and render no color
//;float targetYPixelRadians_yOfDistortion = tan(verticalRadiansOfTarget);
 
// find the bottom of the y triangle, the secant of x, reciprocal of cos(A),
float secantX_bottomOfYTriangle = 1 / cos(horizontalRadiansOfTarget);
//float secantX = 1 / (cos(verticalRadiansOfTarget) * sign(normY)) ;
//float secantX = cos(verticalRadiansOfTarget) * sign(normY) ;
// radians for the top angle of the new image at the target pixel
float oppositeTargetAngleRads = radians(90 - degrees(verticalRadiansOfTarget));

// the y dimension, the maximum top angle radians to the original image plane, some being outside of the rectangle,
// needs to be found for every y, for the final ratio, to be multiplied by the current image in the final step.
//;float oppositeMaxYAngleRads = radians(90 - degrees(verticalFOVRadians_newImageYHeight));
// the y dimension needs to be ratioed against the original image radians, not the maximum extrapolated from the new image
// the dimension in radians of the original image rectangle will be constant as x changes,
// so we can use the radians from the maximum degrees of the y FOV, where x = 0, distortedImageHeight
// angles will vary because the secant will change.
//float oppositeMaxYAngleRads = radians(90 - degrees(verticalFOVRadians_newImageYHeight));

// Now we can use the Law of Sines for the maximum and target in y.
// Law of Sines: b/sin(B) = c/sin©
// b = (c * sin(B)) / sin©
float targetYRadians = (secantX_bottomOfYTriangle * sin(verticalRadiansOfTarget)) / sin(oppositeTargetAngleRads);
// float maxYRadians = (secantX_bottomOfYTriangle * sin(verticalFOVRadians_newImageYHeight)) / sin

(oppositeMaxYAngleRads);
// the final ratio, to be multiplied by the current image in the final step
float colorV1 = targetYRadians / distortedImageHeight;
float colorVfinal = colorV1;


//////
// Denormalize
float colorU = (colorUfinal / 2) + normFactor;
float colorV = (colorVfinal / 2) + normFactor;

// u, v coordinates for the new color
    int3 iTexCoord = int3(uTDim.x * colorU, uTDim.y * colorV, 0);

// load them into the buffer  
float4 color = srcTex.Load( iTexCoord );
 
return color;
}



End Copy and Past at line - }


Save file as: "AS01.psh" using NOTEPAD (Run Notepad As Administrator) - to save the file,
go to File and select, Save As, Make sure the Save As Type is set at: ALL FILES (*.*)

Save the above file in your: C:\Program Files (x86)\Lockheed Martin\Prepar3D v2\ShadersHLSL\PostProcess   Folder



--------
Part 3
--------

Edit your Cameras.cfg file located in the following directory:

C:\Users\Mike\AppData\Roaming\Lockheed Martin\Prepar3Dv2



Start Copy and Past at line - [CameraDefinition.019]


[CameraDefinition.019]
Title = AS Virtual Cockpit
Guid = {84304EBD-5823-485e-AEB6-8D1839B84D17}
Description = This is a non-distorted virtual cockpit
Origin = Virtual Cockpit
MomentumEffect = Yes
SnapPbhAdjust = Swivel
SnapPbhReturn = False
PanPbhAdjust = Swivel
PanPbhReturn = False
Track = None
ShowAxis = YES
AllowZoom = TRUE
InitialZoom = 0.6
SmoothZoomTime = 2.0
ZoomPanScalar = 1.0
ShowWeather = Yes
XyzAdjust = TRUE
ShowLensFlare=TRUE
Category = Cockpit
PitchPanRate=30
HeadingPanRate=75
PanAcceleratorTime=0
HotKeySelect=1
ObserverVerticalFOV=70
ObserverHorizontalFOV=150
PostProcess00 = AS01


End Copy and Past at line - PostProcess00 = AS01


Paste the above section to the end of your cameras.cfg file, just change the
number .019 to the next available number if it's not .019.



--------
Part 4
--------


Delete your P3D shaders folder files located in the following directory.

C:\Users\Mike\AppData\Local\Lockheed Martin\Prepar3Dv2\Shaders


---------
Step 5
--------

Download and Install Hotkey version 1, it can be found at the following location:


http://ahkscript.org/download


Next Download Hotkey version 2, it can be found at the following location:

http://ahkscript.org/v2

Extract the files and overwrite version Hotkey version 1.


Former Beta Tester - (for a few companies) - As well as provide Regional Voice Set Recordings

       Four-Intel I9/10900K | One-AMD-7950X3D | Three-Asus TUF 4090s | One-3090 | One-1080TI | Five-64GB DDR5 RAM 6000mhz | Five-Cosair 1300 P/S | Five-Pro900 2TB NVME        One-Eugenius ECS2512 / 2.5 GHz Switch | Five-Ice Giant Elite CPU Coolers | Three-75" 4K UHDTVs | One-24" 1080P Monitor | One-19" 1080P Monitor | One-Boeing 737NG Flight Deck

Share this post


Link to post

Hi,

 

Now the last thing would be to place the following into my default flight.fxml

 

 

  <Section Name="Camera.1.33">

            <Property Name="Guid" Value="{638C9EA3-0158-4a4b-AA52-C3A6B37989EF}" />
            <Property Name="Title" Value="AS Virtual Cockpit" />
            <Property Name="PanelOnlyView" Value="False" />
            <Property Name="Zoom" Value="0.43113842606544495" />
            <Property Name="Translation" Value="0, 0, 0" />
            <Property Name="SensorMode" Value="0" />
            <Property Name="Rotation" Value="0, 0, 0" />
            <Property Name="FieldOfView" Value="140, 50" />
            <Property Name="PostProcess.0" Value="AS01" />
        </Section>

Former Beta Tester - (for a few companies) - As well as provide Regional Voice Set Recordings

       Four-Intel I9/10900K | One-AMD-7950X3D | Three-Asus TUF 4090s | One-3090 | One-1080TI | Five-64GB DDR5 RAM 6000mhz | Five-Cosair 1300 P/S | Five-Pro900 2TB NVME        One-Eugenius ECS2512 / 2.5 GHz Switch | Five-Ice Giant Elite CPU Coolers | Three-75" 4K UHDTVs | One-24" 1080P Monitor | One-19" 1080P Monitor | One-Boeing 737NG Flight Deck

Share this post


Link to post

wow those instructions are crazy I cant even follow them

Share this post


Link to post

wow those instructions are crazy I cant even follow them

 Sorry, that probably didn't come across the way It was meant.  I'm poking fun at how I dumped all this out expecting it to somehow be easy to follow.

Long day,  Still wanting to get an install app out there; it's the best choice on how to proceed now, please be patient.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...