Skip to main content
Participant
April 9, 2015

[Solved] Distortion doesn't seems right

Hello!
Still learning Oculus integration, and I nearly managed to get all the Oculus features I need to work with my project.
However I noticed that when I enable the distortion shader, stereoscopy just doesn't works. It's even better when I don't activate it Oo

I have a custom C++ code base.
Without distortion, my final rendering looks like this:
http://zylannprods.fr/dl/oculusdev/oculus_1.png

With client rendered distortion, I get this:
http://zylannprods.fr/dl/oculusdev/oculus_2.png

In the scene, the player is basically a 3D object with two child cameras at relative positions (-0.1,0,0) and (0.1,0,0). Each camera renders an eye on the final viewport.

But when distortion is ON, It's like the look directions are crossing and VR doesn't works :s It also seems there is a significant magnifying effect...
Any idea what can cause this issue?

    13 replies

    Inspiring
    April 10, 2015
    "Zylann" wrote:
    Ok, I think I have a clue: the FOV.
    I arbitrarily set angles of 90° on the two eyes, however it's a "classic" FOV, not a VR one.
    I see the parameters are different for the projection matrix in RoomTiny, I will refactor a bit my code in order to feed this kind of FOV to my cameras instead, and see if it works.


    Yes, your problem is your FOV, or more to the point, your projection matrices. Even with the stereo separation set to 0, there should be a significant difference between the left and right eye images in the mono screen shot, because the projection matrix is asymmetrical. However, when I superimpose the left and right eye images, they're identical.

    In order to get it working you need to ensure that you're using the projection matrices returned by ovrMatrix4f_Projection() and you need to use a different matrix for each eye. It is possible to use the same projection matrix for both eyes, but essentially you need to set the left and right degrees on the per-eye ovrFovPorts to the same value, by setting each one to the minimum of the two values. However, by doing so you'll be sacrificing a lot of overall field of view.

    If you're engine can't cope with an asymmetrical projection matrix, then you're fucked until it can.
    Brad Davis - Developer for High Fidelity Co-author of Oculus Rift in Action
    ZylannAuthor
    Participant
    April 10, 2015
    Yep, that was FOV.
    I added a new method in my matrix implementation taking a general field of view as parameter.

    Now this is what I get with distortion:
    http://zylannprods.fr/dl/oculusdev/oculus_stereo_dist_fix1.png
    Without:
    http://zylannprods.fr/dl/oculusdev/oculus_stereo_nodist_fix1.png

    And the involved projection matrix, raw out of testing and not optimized:
        // Row-major, left-handed
    m_v[0] = 2.f / (fov.tanRight + fov.tanLeft);
    m_v[5] = 2.f / (fov.tanUp + fov.tanDown);
    m_v[8] = (fov.tanLeft - fov.tanRight) / (fov.tanRight + fov.tanLeft);
    m_v[9] = (fov.tanUp - fov.tanDown) / (fov.tanUp + fov.tanDown);
    m_v[10] = (near + far) / (far - near);
    m_v[11] = 1.f;
    m_v[14] = -2.f * near * far / (far - near);

    VR looks better! But the image still feels magnified... unless I use bigger framebuffers?
    Inspiring
    April 10, 2015
    That looks much better. I think you are just rendering at a really now resolution. The SDK should provide you with the recommended back-buffer size (which will be larger than the res of the screen).
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV