I'm developing an application that requires wide fields of view (HFOV > 140).
To eliminate the distortion at boundaries I'm using pannini projection (D=2)
http://tksharpless.net/vedutismo/Pannini/panini.pdf
All works as expected, but I have problem with mouse interactions, since the deprojection does not take pannini into account.
Is there something like 'reverse pannini' ?
for projection I use: (code stiched from above document)
//
// ScreenSpacePosition - position in screenspace from -1,-1 to 1,1
// d - Pannini D
// s - Pannini S
// FitScale - scaling factor to fit the result to screen
//
float2 PanniniProjection(float2 ScreenSpacePosition, float d, float s, float FitScale)
{
float2 OM = ScreenSpacePosition * float2(ProjectionMatrixInverse[0][0], ProjectionMatrixInverse[1][1]);
float InvL = rsqrt(1.0f + OM.x * OM.x);
float SinPhi = OM.x * InvL;
float TanTheta = OM.y * InvL;
float CosPhi = sqrt(1.0f - SinPhi * SinPhi);
float S = (d + 1.0f) / (d + CosPhi);
float2 Result = S * float2(SinPhi, lerp(TanTheta, TanTheta / CosPhi, s));
return Result * float2(ProjectionMatrix[0][0], ProjectionMatrix[1][1]) * FitScale;
}
so first my mouse coordinates should go thru something like PanniniUnProjection, then oriceed with the usual way ?