cancel
Showing results for 
Search instead for 
Did you mean: 

ovr_GetRenderDesc vs ovr_GetFovTextureSize

zhtet
Honored Guest
Hi,

I am running some tests and getting inconsistent numbers with values returned from ovr_GetRenderDesc vs ovr_GetFovTextureSize. So for the default parameters, these are the following values returned:

   Fov Tan Up: 0.889498, Down 1.110925, Left 0.964926, Right 0.715264
   Fov Angles Up: 41.653038, Down 48.008022, Left 43.977371, Right 35.574772
   Texture Size w: 1332, h 1586

ovr_GetRenderDesc then returns PixelsPerTanAngleAtCenter value of (792.760132, 792.760254). So given that PixelsPerTanAngleAtCenter is for a FOV of 45/45 based on the comments, the texture size for the values above should be (792.760132 * (43.977371 + 35.574772) / 45, 792.760254 * (41.653038 + 48.008022) / 45) = (1401, 1580) instead of (1332, 1586). Any idea why this is the case? 

As a test, I tried (fov_tan_left + fov_tan_right) * PixelsPerTanAngleAtCenter, so (0.964926+0.715264) * 792.760132 and that does equate to 1332, which if that is the equation, it doesn't quite make sense suming tangent of angles, does it? (I actually tried this with another set of fov angles, and that behavior seems consistent). Is this intentional or an error? 

Thanks
7 REPLIES 7

volgaksoy
Expert Protege
You actually do want to sum the tangent angles, and not the angles themselves. If we were looking at the spherical ratios of 45/45 vs. your FOVs, then you'd have the first calculation you suggested. However our texture is a flat surface, not a curved one.

In more concrete terms, think about what happens at the extreme FOVs while maintaining the 1:1 pixel ratio at the center of the screen. For example the closer the angles get to 90 degrees (where the full FOV would be 180 degrees), you'd effectively require a resolution that is infinitely large. This can be seen when you use tangent angles in the calculation rather than the angles themselves.

Hope that helps.

zhtet
Honored Guest
Got it. Thanks for the explanation! 

So would that mean if I am trying to get the resolution of a texture which is an equirectangular projection (and with 1-1 display pixel mapping towards middle), I would use the first calculation I suggested, instead of extrapolating from ovr_GetFovTextureSize's values right?

volgaksoy
Expert Protege
Correct

tcarothers
Honored Guest
So let me see if I can summarize/finish the calculations to test my own understanding. Please verify that my calculations are correct.

   PixelsPerTanAngleAtCenter = (792.760132, 792.760254)
   Fov Tan Up: 0.889498, Down 1.110925, Left 0.964926, Right 0.715264
   Fov Angles Up: 41.653038, Down 48.008022, Left 43.977371, Right 35.574772
   Texture Size w: 1332, h 1586

Goal: Get the resolution of a texture which is an equirectangular projection with 1-1 display pixel mapping for the center pixel.

Abbreviations:
    CP = center pixel
    AR = angular resolution(px/deg)

Step 1. Find the angle that the CP occupies for the texture.
Let's first calculate the tan angle for the CP. We know that there is the tan of some angle(theta_cp) that when multiplied by PixelsPerTanAngleAtCenter will equal one pixel(the CP): 
    tan(theta_cp) * PixelsPerTanAngleAtCenter[0] = 1px
    tan(theta_cp) = 1px/792.760132px
    theta_cp = atan(1/792.760132)
    theta_cp = 0.0722737519 degrees

Intuitively, if you think of a tiny FoV with angles [Up, Down, Left, Right] = [theta_cp, theta_cp, theta_cp, theta_cp] then the FoV would perfectly frame the CP.
* NOTE: I really solved for theta_cp in the x dimension since PixelsPerTanAngleAtCenter is a 2D vector. To solve for theta_cp in the y dimension plug in PixelsPerTanAngleAtCenter[1].

Step 2. Find the equirectangular projection resolution with 1:1 mapping to the CP of the above texture.
Assumption: The AR is constant across an equirectangular projection.

All we need to do is get the AR for the CP above and multiply by 360 and 180 to get the equirectangular resolution:
    AR = 1px / theta_cp
    AR = 13.8362818272 px/deg for the CP of the texture

    Equirectangular Resolution = [13.8362818272 px/deg * 360deg, 13.8362818272 px/deg * 180deg]
    Equirectangular Resolution = [4981.06px, 2490.53px]
* NOTE: Once again we would need to solve for AR in the y dimension and multiply by 180. However, PixelsPerTanAngleAtCenter[0] and [1] are so close for the numbers above that they yield the same result up to the second decimal place for Equirectangular Resolution.

tcarothers
Honored Guest
It's been a couple weeks now, any progress on a response to above?

cybereality
Grand Champion
Moving this to the developer forum and I'll see if I can get an answer.

volgaksoy
Expert Protege
tcarothers, that looks correct.