0

I am trying to Change my Monocular DirectX Engine into a Stereoscopy Renderengine for Oculus Rift. What is missing, is the Stereoscopic Projection Transformation to achieve a 3D Perception.

For now, I am using still my Standard monocular projection Matrix:

1.50888 0 0 0
0 2.41421 0 0
0 0 1.0001 -0.10001
0 0 1 0

// Setup the projection matrix.
fieldOfView = (float)XM_PI / 4.0f;
screenAspect = (float)screenWidth / (float)screenHeight;

// Create the [Monoscope]projection matrix for 3D rendering.
XMMATRIX projectionMatrix_XmMat = XMMatrixPerspectiveFovLH(fieldOfView, screenAspect, screenNear, screenDepth);
XMStoreFloat4x4(&projectionmatrix_, projectionMatrix_XmMat);

I am already translating the left camera by -0.032 for creating the View Matrix, and my right eye x_translated by 0.032 for creating View Matrix. The Problem is the Stereo off-Center Projection Matrix (which I think I Need). So I guess I Need to do this somehow: http://paulbourke.net/exhibition/vpac/theory2.gif Was trying alot of different calculations, but I just got weird results unfortunately ..

Already researched alot, some People here are succeding doing this http://www.gamedev.net/topic/597564-view-and-projection-matrices-for-vr-window-using-head-tracking/:

// Window Size 1200x800, 3:2
// XMFLOAT3 Position = camera_->GetPosition();
// [Method 1] ------------------------------------------------------------
//float left = screenNear_ * (-3.f - position.x) / position.z;
//float right = screenNear_ * (3.f - position.x) / position.z;
//float bottom = screenNear_ * (-2.f - position.y) / position.z;
//float top = screenNear_ * (2.f - position.y) / position.z;

//XMMATRIX stereomatrix = XMMatrixPerspectiveOffCenterLH(left, right, bottom, top, screenNear_, screenDepth_);
//XMStoreFloat4x4(&stereoprojectionmatrix_, stereomatrix);

But Method 1 causes weird random effects. I am moving my Camera back on the Z-Axis but visually it just can go into -z-axis for -3.f values, all camera values < -3.f don't have any visual effect.

Furthermore, I was also reading through this paper: http://www.google.at/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0CCkQFjAB&url=http%3A%2F%2Fwww.marries.nl%2Fwp-content%2Fuploads%2F2011%2F05%2FApplying-stereoscopic-3D-in-games.pdf&ei=nAydVY6bBcL5UobagJgL&usg=AFQjCNEFhKttlYJYNbWF2-LptmcCi8bTZg&sig2=VOKBq9VE0k8nhHtA3gxN8g

and also reading through NVIDIA presentation: http://www.google.at/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CCIQFjAA&url=http%3A%2F%2Fwww.nvidia.com%2Fcontent%2FGTC-2010%2Fpdfs%2F2010_GTC2010.pdf&ei=xA2dVZe3KYr8UMT6g5gL&usg=AFQjCNGeanxCoryAZvmxC1BDmf2itOgG0w&sig2=Ss2kN5gCYeoLsgJ66-442A&bvm=bv.96952980,d.d24

But I just can't figure out how I Need to change my monocular projection Matrix or how to setup the two off-axis projection matrizes properly ..

Maybe someone can help me with that, I would be very glad about that!

Many thanks!

Max
  • 35
  • 2
  • 7

1 Answers1

0

I just came back here to give an answer to this question, even it's solved already long ago.

I had to set up a Stereo Projection Transformation Matrix to achieve a a 3D projection like this:

Stereo Projection Transformation

To get this into code, I have set up an OculusHMD instance which uses the Oculus SDK. With the Oculus SDK, it's possible to calculate such a Stereo projection Transformation which suits the hmd perfectly. Although it's necessary to configure the Oculus HMD device previously, which means configuring the eyRenderDesc, screenNear and screenDepth etc.

  void GraphicsAPI::StereoProjectionTransformation(int camID)
  {
    Matrix4f proj = ovrMatrix4f_Projection(OculusHMD::instance()->eyeRenderDesc_[camID-1].Fov, screenNear_, screenDepth_, false);

    stereoprojectionmatrix_._11 = proj.M[0][0];
    stereoprojectionmatrix_._21 = proj.M[0][1];
    stereoprojectionmatrix_._31 = proj.M[0][2];
    stereoprojectionmatrix_._41 = proj.M[0][3];

    stereoprojectionmatrix_._12 = proj.M[1][0];
    stereoprojectionmatrix_._22 = proj.M[1][1];
    stereoprojectionmatrix_._32 = proj.M[1][2];
    stereoprojectionmatrix_._42 = proj.M[1][3];

    stereoprojectionmatrix_._13 = proj.M[2][0];
    stereoprojectionmatrix_._23 = proj.M[2][1];
    stereoprojectionmatrix_._33 = proj.M[2][2];
    stereoprojectionmatrix_._43 = proj.M[2][3]; 

    stereoprojectionmatrix_._14 = proj.M[3][0];
    stereoprojectionmatrix_._24 = proj.M[3][1];
    stereoprojectionmatrix_._34 = proj.M[3][2];
    stereoprojectionmatrix_._44 = proj.M[3][3];
}

All I had to do afterwards is to copy the values of the Stereoprojectionmatrix - which is computed by the Oculus SDK in the first line - to my own projection Matrix. And what we get is a very nice 3D effect, like it should look like :)

cheers,

Max
  • 11
  • 3