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!