What is wrong with my projection?
I'm working on implementing OVR into my program, but have run into a weird issue where my triangles are being skewed incorrectly. Here is an image to demonstrate:
http://i.imgur.com/FtpGXQ6.png
Without oculus
http://i.imgur.com/lq2PJf1.png
So, the cube is not exact as I'm just holding the HMD to get a screenshot...but generally, when the HMD is horizontal (normal orientation) the cube looks rectangular, and when the HMD is rotated, the cube is more square. Where is my setup incorrect?
View matrix:
http://i.imgur.com/FtpGXQ6.png
Without oculus
http://i.imgur.com/lq2PJf1.png
So, the cube is not exact as I'm just holding the HMD to get a screenshot...but generally, when the HMD is horizontal (normal orientation) the cube looks rectangular, and when the HMD is rotated, the cube is more square. Where is my setup incorrect?
// ...
// Setup each eye
for(ovrEyeType eye = ovrEyeType::ovrEye_Left; eye < ovrEyeType::ovrEye_Count; eye = static_cast<ovrEyeType>(eye+1))
{
ovrSizei eyeTextureSize = ovrHmd_GetFovTextureSize(vrHmd, eye, vrHmd->DefaultEyeFov[eye], 1.f);
ovrTextureHeader& eyeTextureHeader = _vrContext.eyeTextures[eye].Header;
eyeTextureHeader.TextureSize = eyeTextureSize;
eyeTextureHeader.RenderViewport.Size = eyeTextureSize;
eyeTextureHeader.API = ovrRenderAPI_OpenGL;
}
// ...
ovrGLConfig cfg;
cfg.OGL.Header.API = ovrRenderAPI_OpenGL;
ovrSizei rtsize;
rtsize.w = _vrContext.resWidth;
rtsize.h = _vrContext.resHeight;
cfg.OGL.Header.BackBufferSize = rtsize;
cfg.OGL.Header.Multisample = 0;
int distortionCaps = 0
| ovrDistortionCap_Vignette
| ovrDistortionCap_Chromatic
| ovrDistortionCap_Overdrive
| ovrDistortionCap_TimeWarp;
// TODO: Special cases on Linux
int configResult = ovrHmd_ConfigureRendering(vrHmd, &cfg.Config, distortionCaps, vrHmd->DefaultEyeFov, _vrContext.eyeRenderDescs);
for(ovrEyeType eye = ovrEyeType::ovrEye_Left; eye < ovrEyeType::ovrEye_Count; eye = static_cast<ovrEyeType>(eye+1))
{
const ovrEyeRenderDesc& eyeRenderDesc = _vrContext.eyeRenderDescs[eye];
// Per Eye projection
_vrContext.eyeProj[eye] = toGLM(ovrMatrix4f_Projection(vrHmd->DefaultEyeFov[eye], 0.1f, 1024.f, true));
_vrContext.eyeOffsets[eye] = eyeRenderDesc.HmdToEyeViewOffset;
_vrContext.eyeFbo[eye] = GL::createFrameBuffer(
_vrContext.eyeTextures[eye].Header.TextureSize.w, _vrContext.eyeTextures[eye].Header.TextureSize.h);
auto& eyeTextureHeader = _vrContext.eyeTextures[eye];
((ovrGLTexture&)eyeTextureHeader).OGL.TexId = _vrContext.eyeFbo[eye].colorBuffer;
}
View matrix:
return glm::scale(glm::inverse(VR::toGLM(VR::_vrContext.eyePoses[eye])), glm::vec3(OVR_DEFAULT_IPD));
