Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
cheery's avatar
cheery
Explorer
10 years ago

Is ovr_GetFovTextureSize special?

Hello. I got lever programming language to fill left eye screen with red and right eye screen with green. But there's one function that causes my app to crash. Also I got no clue how to compute projection matrix out of the weird Fov -struct.

I've opened the LibOVRRT32_0_8.dll dynamically in my app. It's possible that my FFI bindings just handle this one single function wrong. But that'd be statistically very weird. It's not the only struct passing function in this API.

ovrSizei 	ovr_GetFovTextureSize (ovrSession session, ovrEyeType eye, ovrFovPort fov, float pixelsPerDisplayPixel)


It's the only function returning ovrSizei and the structure is really short. It might be I'm facing some optimization not perfectly handled by the flavor of FFI I'm using.

I worked around the problem by setting texture size 1024x1024. I guess I could work around the function entirely if I knew what it did exactly.

Anyways I also have another problem: I can compute perspective projection matrix, but the oculus provides fov -construct with UpTan/DownTan/LeftTan/RightTan.. Can I compute the correct projection from that structure?

7 Replies

  • I pointed out this to people at #pypy, they told me it's because the cpython bunded libffi library had issue with returning structs on windows. It's been fixed but suppressed because cpython has fixed the problem in ctypes instead of libffi.

    They told that the problem is described in rpython/translator/c/src/libffi_msvc/prep_cif.c:119 just mentioning because you tend to find this kind of posts in google without enough information in them.
  • At 0.8.0 version of oculus rift SDK, the answer to FovPort -> Projection can be found from the LibOVR/Src/OVR_StereoProjection.cpp
  • I use ovrMatrix4f_Projection(). You give it the eye fov structure and the desired near and far planes and it returns a perspective matrix.
    The matrix is a little different to normal because the rift screens and lenses are asymmetric, the DK2 lenses aren't centred on the screen horizontally (slightly more fov to the sides of the head than the nose) and the CV1 has more downwards fov than upwards. So the view frustum is skewed.

    For
    "cheery" wrote:
    I guess I could work around the function entirely if I knew what it did exactly.

    ovr_GetFovTextureSize works out what resolution texture you need so that the pixels in the centre of the view are the specified size relative to the native display panel resolution.
    The barrel distortion that the sdk does makes pixels in the centre bulge out bigger. To combat this, you need to render at higher than 1920x1080, so when they bulge (effectively becoming lower res) they become 1920x1080.
    Under standard setting with 1:1 pixel scale the texture resolution returned by ovr_GetFovTextureSize on a DK2 is 1182x1464 (that's for one eye). That's what you need to render at to get 1080p on screen after the distortion step.

    You can pick any values for the texture size though, if you don't mind lower quality. No idea what CV1 will return (we know it's panel resolution: 1080x1200 each eye, but we don't know the distortion values).
  • I have it rendering on DK1, but would like if it worked on CV1. I guess I'll go and try to fix the issue on pypy.

    So far, I've got render on both left and right eye. I also receive tracking data. There is still something weird though. I wonder if I have filled the LayerFov and ViewScaleDesc correct. On the left eye I only see the right corner of the left-side image, and on the right eye I only see the left corner of the right-side image. It is very heavily distorted.

    Here's what I have so far in code: http://pastebin.com/PeWpFi7C

    I hope I also had the equations to calculate the eye poses and respective matrices to position the models. But now even static posing doesn't seem to converge. I'll try it again tmr.
  • On line 408, I had mixed up .x and .y coordinates when I copied over the perspective matrix. That caused this kind of issue with rendering:



    Now I got it solved and the image converges. Once I fix the FFI issue I have, lever will be officially ready for Oculus!
  • galopin's avatar
    galopin
    Heroic Explorer
    I do not see the problem
    20070516-cat-20louche.jpg
  • Four21's avatar
    Four21
    Honored Guest
    Newbie question: What is the difference between pixelsPerDisplayPixel for ovr_GetFovTextureSize and MSAA?

    Sorry I'm borrowing this topic since I'm a new member :)